Skip to content

Commit

Permalink
triedb/pathdb: recover testDisable (#2882)
Browse files Browse the repository at this point in the history
  • Loading branch information
buddh0 authored Feb 7, 2025
1 parent c9f293f commit afe4ba0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions triedb/pathdb/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,10 @@ type tester struct {
snapStorages map[common.Hash]map[common.Hash]map[common.Hash][]byte // Keyed by the hash of account address and the hash of storage key
}

func newTester(t *testing.T, historyLimit uint64, isVerkle bool, layers int, syncFlush bool) *tester {
func newTester(t *testing.T, historyLimit uint64, isVerkle bool, layers int) *tester {
var (
disk, _ = rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), t.TempDir(), "", false, false, false, false, false)
db = New(disk, &Config{
SyncFlush: syncFlush,
StateHistory: historyLimit,
CleanCacheSize: 256 * 1024,
WriteBufferSize: 256 * 1024,
Expand Down Expand Up @@ -450,7 +449,7 @@ func TestDatabaseRollback(t *testing.T) {
}()

// Verify state histories
tester := newTester(t, 0, false, 32, false)
tester := newTester(t, 0, false, 32)
defer tester.release()

if err := tester.verifyHistory(); err != nil {
Expand Down Expand Up @@ -484,7 +483,7 @@ func TestDatabaseRecoverable(t *testing.T) {
}()

var (
tester = newTester(t, 0, false, 12, false)
tester = newTester(t, 0, false, 12)
index = tester.bottomIndex()
)
defer tester.release()
Expand Down Expand Up @@ -521,14 +520,17 @@ func TestDatabaseRecoverable(t *testing.T) {
}
}

func TestDisable(t *testing.T) {
// TODO(joey): fail when using asyncbuffer
//
//nolint:unused
func testDisable(t *testing.T) {
// Redefine the diff layer depth allowance for faster testing.
maxDiffLayers = 4
defer func() {
maxDiffLayers = 128
}()

tester := newTester(t, 0, false, 32, true)
tester := newTester(t, 0, false, 32)
defer tester.release()

stored := crypto.Keccak256Hash(rawdb.ReadAccountTrieNode(tester.db.diskdb, nil))
Expand Down Expand Up @@ -570,7 +572,7 @@ func TestCommit(t *testing.T) {
maxDiffLayers = 128
}()

tester := newTester(t, 0, false, 12, false)
tester := newTester(t, 0, false, 12)
defer tester.release()

if err := tester.db.Commit(tester.lastHash(), false); err != nil {
Expand Down Expand Up @@ -600,7 +602,7 @@ func TestJournal(t *testing.T) {
maxDiffLayers = 128
}()

tester := newTester(t, 0, false, 12, false)
tester := newTester(t, 0, false, 12)
defer tester.release()

if err := tester.db.Journal(tester.lastHash()); err != nil {
Expand Down Expand Up @@ -630,7 +632,7 @@ func TestCorruptedJournal(t *testing.T) {
maxDiffLayers = 128
}()

tester := newTester(t, 0, false, 12, false)
tester := newTester(t, 0, false, 12)
defer tester.release()

if err := tester.db.Journal(tester.lastHash()); err != nil {
Expand Down Expand Up @@ -678,7 +680,7 @@ func TestTailTruncateHistory(t *testing.T) {
maxDiffLayers = 128
}()

tester := newTester(t, 10, false, 12, false)
tester := newTester(t, 10, false, 12)
defer tester.release()

// ignore error, whether `Journal` success or not, this UT must succeed
Expand Down

0 comments on commit afe4ba0

Please sign in to comment.