mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
tests: validate snapshot after test
This commit is contained in:
parent
fc378fa0c8
commit
976c209c8b
1 changed files with 14 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ import (
|
|||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/core/state/snapshot"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
|
@ -144,6 +145,19 @@ func (t *BlockTest) Run(snapshotter bool) error {
|
|||
if err = t.validatePostState(newDB); err != nil {
|
||||
return fmt.Errorf("post state validation failed: %v", err)
|
||||
}
|
||||
// Cross-check the snapshot-to-hash against the trie hash
|
||||
if snapshotter {
|
||||
snapTree := chain.Snapshot()
|
||||
root := chain.CurrentBlock().Root()
|
||||
it, err := snapTree.AccountIterator(root, common.Hash{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("Could not create iterator for root %x: %v", root, err)
|
||||
}
|
||||
generatedRoot := snapshot.GenerateTrieRoot(it)
|
||||
if generatedRoot != root {
|
||||
return fmt.Errorf("Snapshot corruption, got %d exp %d", generatedRoot, root)
|
||||
}
|
||||
}
|
||||
return t.validateImportedHeaders(chain, validBlocks)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue