mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
WIP: fix flaky TestDisable
This commit is contained in:
parent
045b9718d5
commit
780e13b201
2 changed files with 13 additions and 1 deletions
|
|
@ -310,6 +310,10 @@ func (db *Database) Enable(root common.Hash) error {
|
||||||
stored := types.EmptyRootHash
|
stored := types.EmptyRootHash
|
||||||
if blob := rawdb.ReadAccountTrieNode(db.diskdb, nil); len(blob) > 0 {
|
if blob := rawdb.ReadAccountTrieNode(db.diskdb, nil); len(blob) > 0 {
|
||||||
stored = crypto.Keccak256Hash(blob)
|
stored = crypto.Keccak256Hash(blob)
|
||||||
|
} else {
|
||||||
|
has, err := db.diskdb.Has(nil)
|
||||||
|
fmt.Println("len(blob) == 0", has, err)
|
||||||
|
fmt.Printf("state root mismatch: stored %x, synced %x\n", stored, root)
|
||||||
}
|
}
|
||||||
if stored != root {
|
if stored != root {
|
||||||
return fmt.Errorf("state root mismatch: stored %x, synced %x", stored, root)
|
return fmt.Errorf("state root mismatch: stored %x, synced %x", stored, root)
|
||||||
|
|
|
||||||
|
|
@ -476,6 +476,13 @@ func TestDatabaseRecoverable(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDisableManyTimes(t *testing.T) {
|
||||||
|
for i := 0; i < 1000; i++ {
|
||||||
|
t.Log(i)
|
||||||
|
TestDisable(t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestDisable(t *testing.T) {
|
func TestDisable(t *testing.T) {
|
||||||
// Redefine the diff layer depth allowance for faster testing.
|
// Redefine the diff layer depth allowance for faster testing.
|
||||||
maxDiffLayers = 4
|
maxDiffLayers = 4
|
||||||
|
|
@ -486,13 +493,14 @@ func TestDisable(t *testing.T) {
|
||||||
tester := newTester(t, 0)
|
tester := newTester(t, 0)
|
||||||
defer tester.release()
|
defer tester.release()
|
||||||
|
|
||||||
stored := crypto.Keccak256Hash(rawdb.ReadAccountTrieNode(tester.db.diskdb, nil))
|
|
||||||
if err := tester.db.Disable(); err != nil {
|
if err := tester.db.Disable(); err != nil {
|
||||||
t.Fatalf("Failed to deactivate database: %v", err)
|
t.Fatalf("Failed to deactivate database: %v", err)
|
||||||
}
|
}
|
||||||
|
fmt.Println(tester.db.diskdb.Has(nil))
|
||||||
if err := tester.db.Enable(types.EmptyRootHash); err == nil {
|
if err := tester.db.Enable(types.EmptyRootHash); err == nil {
|
||||||
t.Fatal("Invalid activation should be rejected")
|
t.Fatal("Invalid activation should be rejected")
|
||||||
}
|
}
|
||||||
|
stored := crypto.Keccak256Hash(rawdb.ReadAccountTrieNode(tester.db.diskdb, nil))
|
||||||
if err := tester.db.Enable(stored); err != nil {
|
if err := tester.db.Enable(stored); err != nil {
|
||||||
t.Fatalf("Failed to activate database: %v", err)
|
t.Fatalf("Failed to activate database: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue