Skip to content

Commit 3969858

Browse files
Fix state test runner not handling invalid tx properly (#7909)
1 parent ac486e4 commit 3969858

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs

+17-11
Original file line numberDiff line numberDiff line change
@@ -133,31 +133,37 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer)
133133
}
134134

135135
ValidationResult txIsValid = _txValidator.IsWellFormed(test.Transaction, spec);
136-
136+
TransactionResult? txResult = null;
137137
if (txIsValid)
138138
{
139-
transactionProcessor.Execute(test.Transaction, new BlockExecutionContext(header), txTracer);
139+
txResult = transactionProcessor.Execute(test.Transaction, new BlockExecutionContext(header), txTracer);
140140
}
141141
else
142142
{
143143
_logger.Info($"Skipping invalid tx with error: {txIsValid.Error}");
144144
}
145145

146146
stopwatch.Stop();
147+
if (txResult is not null && txResult.Value == TransactionResult.Ok)
148+
{
149+
stateProvider.Commit(specProvider.GetSpec((ForkActivation)1));
150+
stateProvider.CommitTree(1);
151+
152+
// '@winsvega added a 0-wei reward to the miner , so we had to add that into the state test execution phase. He needed it for retesteth.'
153+
if (!stateProvider.AccountExists(test.CurrentCoinbase))
154+
{
155+
stateProvider.CreateAccount(test.CurrentCoinbase, 0);
156+
}
147157

148-
stateProvider.Commit(specProvider.GetSpec((ForkActivation)1));
149-
stateProvider.CommitTree(1);
158+
stateProvider.Commit(specProvider.GetSpec((ForkActivation)1));
150159

151-
// '@winsvega added a 0-wei reward to the miner , so we had to add that into the state test execution phase. He needed it for retesteth.'
152-
if (!stateProvider.AccountExists(test.CurrentCoinbase))
160+
stateProvider.RecalculateStateRoot();
161+
}
162+
else
153163
{
154-
stateProvider.CreateAccount(test.CurrentCoinbase, 0);
164+
stateProvider.Reset();
155165
}
156166

157-
stateProvider.Commit(specProvider.GetSpec((ForkActivation)1));
158-
159-
stateProvider.RecalculateStateRoot();
160-
161167
List<string> differences = RunAssertions(test, stateProvider);
162168
EthereumTestResult testResult = new(test.Name, test.ForkName, differences.Count == 0);
163169
testResult.TimeInMs = stopwatch.Elapsed.TotalMilliseconds;

0 commit comments

Comments
 (0)