From bd88d359b0751edcf4779418382936ca9665aafe Mon Sep 17 00:00:00 2001 From: lilasxie Date: Sat, 1 Jun 2024 11:36:31 +0800 Subject: [PATCH] Revert "WIP: fix flaky `TestDisable`" This reverts commit 7936ffcc6964dd21b032ab4555b0a6d7ccc0fbeb. --- triedb/pathdb/database.go | 4 ---- triedb/pathdb/database_test.go | 10 +--------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/triedb/pathdb/database.go b/triedb/pathdb/database.go index 2802efc586..450c3a8f4f 100644 --- a/triedb/pathdb/database.go +++ b/triedb/pathdb/database.go @@ -310,10 +310,6 @@ func (db *Database) Enable(root common.Hash) error { stored := types.EmptyRootHash if blob := rawdb.ReadAccountTrieNode(db.diskdb, nil); len(blob) > 0 { 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 { return fmt.Errorf("state root mismatch: stored %x, synced %x", stored, root) diff --git a/triedb/pathdb/database_test.go b/triedb/pathdb/database_test.go index 4dc3ce34eb..229f5ca37f 100644 --- a/triedb/pathdb/database_test.go +++ b/triedb/pathdb/database_test.go @@ -476,13 +476,6 @@ 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) { // Redefine the diff layer depth allowance for faster testing. maxDiffLayers = 4 @@ -493,14 +486,13 @@ func TestDisable(t *testing.T) { tester := newTester(t, 0) defer tester.release() + stored := crypto.Keccak256Hash(rawdb.ReadAccountTrieNode(tester.db.diskdb, nil)) if err := tester.db.Disable(); err != nil { t.Fatalf("Failed to deactivate database: %v", err) } - fmt.Println(tester.db.diskdb.Has(nil)) if err := tester.db.Enable(types.EmptyRootHash); err == nil { t.Fatal("Invalid activation should be rejected") } - stored := crypto.Keccak256Hash(rawdb.ReadAccountTrieNode(tester.db.diskdb, nil)) if err := tester.db.Enable(stored); err != nil { t.Fatalf("Failed to activate database: %v", err) }