aboutsummaryrefslogtreecommitdiffstats
path: root/tests/state_test_util.go
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2018-09-04 16:49:18 +0800
committerFelix Lange <fjl@users.noreply.github.com>2018-09-04 16:49:18 +0800
commit32f28a9360d26a661d55915915f12fd3c70f012b (patch)
tree870134b45677ea479b6fca7983d48eb362c12b4d /tests/state_test_util.go
parent6a33954731658667056466bf7573ed1c397f4750 (diff)
downloadgo-tangerine-32f28a9360d26a661d55915915f12fd3c70f012b.tar
go-tangerine-32f28a9360d26a661d55915915f12fd3c70f012b.tar.gz
go-tangerine-32f28a9360d26a661d55915915f12fd3c70f012b.tar.bz2
go-tangerine-32f28a9360d26a661d55915915f12fd3c70f012b.tar.lz
go-tangerine-32f28a9360d26a661d55915915f12fd3c70f012b.tar.xz
go-tangerine-32f28a9360d26a661d55915915f12fd3c70f012b.tar.zst
go-tangerine-32f28a9360d26a661d55915915f12fd3c70f012b.zip
core/vm, tests: update tests, enable constantinople statetests, fix SAR opcode (#17538)
This commit does a few things at once: - Updates the tests to contain the latest data from ethereum/tests repo. - Enables Constantinople state tests. This is needed to be able to fuzz-test the evm with constantinople rules. - Fixes the error in opSAR that we've known about for some time. I was kind of saving it to see if we hit upon it with the random test generator, but it's difficult to both enable the tests and have the bug there -- we don't want to forget about it, so maybe it's better to just fix it.
Diffstat (limited to 'tests/state_test_util.go')
-rw-r--r--tests/state_test_util.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/state_test_util.go b/tests/state_test_util.go
index 84581fae1..5d2251e52 100644
--- a/tests/state_test_util.go
+++ b/tests/state_test_util.go
@@ -146,7 +146,18 @@ func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) (*state.StateD
if logs := rlpHash(statedb.Logs()); logs != common.Hash(post.Logs) {
return statedb, fmt.Errorf("post state logs hash mismatch: got %x, want %x", logs, post.Logs)
}
- root, _ := statedb.Commit(config.IsEIP158(block.Number()))
+ // Commit block
+ statedb.Commit(config.IsEIP158(block.Number()))
+ // Add 0-value mining reward. This only makes a difference in the cases
+ // where
+ // - the coinbase suicided, or
+ // - there are only 'bad' transactions, which aren't executed. In those cases,
+ // the coinbase gets no txfee, so isn't created, and thus needs to be touched
+ statedb.AddBalance(block.Coinbase(), new(big.Int))
+ // And _now_ get the state root
+ root := statedb.IntermediateRoot(config.IsEIP158(block.Number()))
+ // N.B: We need to do this in a two-step process, because the first Commit takes care
+ // of suicides, and we need to touch the coinbase _after_ it has potentially suicided.
if root != common.Hash(post.Root) {
return statedb, fmt.Errorf("post state root mismatch: got %x, want %x", root, post.Root)
}