@@ -144,11 +144,29 @@ func (t *StateTest) Subtests() []StateSubtest {
144
144
return sub
145
145
}
146
146
147
- // Run executes a specific subtest.
147
+ // Run executes a specific subtest and verifies the post-state and logs
148
148
func (t * StateTest ) Run (subtest StateSubtest , vmconfig vm.Config ) (* state.StateDB , error ) {
149
+ statedb , root , err := t .RunNoVerify (subtest , vmconfig )
150
+ if err != nil {
151
+ return statedb , err
152
+ }
153
+ post := t .json .Post [subtest .Fork ][subtest .Index ]
154
+ // N.B: We need to do this in a two-step process, because the first Commit takes care
155
+ // of suicides, and we need to touch the coinbase _after_ it has potentially suicided.
156
+ if root != common .Hash (post .Root ) {
157
+ return statedb , fmt .Errorf ("post state root mismatch: got %x, want %x" , root , post .Root )
158
+ }
159
+ if logs := rlpHash (statedb .Logs ()); logs != common .Hash (post .Logs ) {
160
+ return statedb , fmt .Errorf ("post state logs hash mismatch: got %x, want %x" , logs , post .Logs )
161
+ }
162
+ return statedb , nil
163
+ }
164
+
165
+ // RunNoVerify runs a specific subtest and returns the statedb and post-state root
166
+ func (t * StateTest ) RunNoVerify (subtest StateSubtest , vmconfig vm.Config ) (* state.StateDB , common.Hash , error ) {
149
167
config , eips , err := getVMConfig (subtest .Fork )
150
168
if err != nil {
151
- return nil , UnsupportedForkError {subtest .Fork }
169
+ return nil , common. Hash {}, UnsupportedForkError {subtest .Fork }
152
170
}
153
171
vmconfig .ExtraEips = eips
154
172
block := t .genesis (config ).ToBlock (nil )
@@ -157,7 +175,7 @@ func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) (*state.StateD
157
175
post := t .json .Post [subtest .Fork ][subtest .Index ]
158
176
msg , err := t .json .Tx .toMessage (post )
159
177
if err != nil {
160
- return nil , err
178
+ return nil , common. Hash {}, err
161
179
}
162
180
context := core .NewEVMContext (msg , block .Header (), nil , & t .json .Env .Coinbase )
163
181
context .GetHash = vmTestBlockHash
@@ -179,15 +197,7 @@ func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) (*state.StateD
179
197
statedb .AddBalance (block .Coinbase (), new (big.Int ))
180
198
// And _now_ get the state root
181
199
root := statedb .IntermediateRoot (config .IsEIP158 (block .Number ()))
182
- // N.B: We need to do this in a two-step process, because the first Commit takes care
183
- // of suicides, and we need to touch the coinbase _after_ it has potentially suicided.
184
- if root != common .Hash (post .Root ) {
185
- return statedb , fmt .Errorf ("post state root mismatch: got %x, want %x" , root , post .Root )
186
- }
187
- if logs := rlpHash (statedb .Logs ()); logs != common .Hash (post .Logs ) {
188
- return statedb , fmt .Errorf ("post state logs hash mismatch: got %x, want %x" , logs , post .Logs )
189
- }
190
- return statedb , nil
200
+ return statedb , root , nil
191
201
}
192
202
193
203
func (t * StateTest ) gasLimit (subtest StateSubtest ) uint64 {
0 commit comments