From a32eaccaee6ed1c75e52958f9e6e4ee0b2341b2d Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Sun, 16 Mar 2025 20:33:28 +0800 Subject: [PATCH] core/rawdb: fix tests --- core/rawdb/freezer.go | 5 ++--- core/rawdb/freezer_memory_test.go | 10 ++++++++-- core/rawdb/freezer_test.go | 10 ++++++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/core/rawdb/freezer.go b/core/rawdb/freezer.go index 4862256c79..b0d046b1f7 100644 --- a/core/rawdb/freezer.go +++ b/core/rawdb/freezer.go @@ -346,7 +346,6 @@ func (f *Freezer) validate() error { if len(f.tables) == 0 { return nil } - var ( head uint64 prunedTail *uint64 @@ -364,7 +363,7 @@ func (f *Freezer) validate() error { if !table.config.prunable { // non-prunable tables have to start at 0 if table.itemHidden.Load() != 0 { - return fmt.Errorf("freezer table %s has a differing head: %d != %d", kind, table.items.Load(), 0) + return fmt.Errorf("non-prunable freezer table '%s' has a non-zero tail: %d", kind, table.itemHidden.Load()) } } else { // prunable tables have to have the same length @@ -408,7 +407,7 @@ func (f *Freezer) repair() error { if !table.config.prunable { // non-prunable tables have to start at 0 if table.itemHidden.Load() != 0 { - panic(fmt.Sprintf("freezer table %s has non-zero tail: %v", kind, table.itemHidden.Load())) + panic(fmt.Sprintf("non-prunable freezer table %s has non-zero tail: %v", kind, table.itemHidden.Load())) } } else { // prunable tables have to have the same length diff --git a/core/rawdb/freezer_memory_test.go b/core/rawdb/freezer_memory_test.go index 00f9704b93..4bd31d8027 100644 --- a/core/rawdb/freezer_memory_test.go +++ b/core/rawdb/freezer_memory_test.go @@ -27,14 +27,20 @@ func TestMemoryFreezer(t *testing.T) { ancienttest.TestAncientSuite(t, func(kinds []string) ethdb.AncientStore { tables := make(map[string]freezerTableConfig) for _, kind := range kinds { - tables[kind] = freezerTableConfig{noSnappy: true} + tables[kind] = freezerTableConfig{ + noSnappy: true, + prunable: true, + } } return NewMemoryFreezer(false, tables) }) ancienttest.TestResettableAncientSuite(t, func(kinds []string) ethdb.ResettableAncientStore { tables := make(map[string]freezerTableConfig) for _, kind := range kinds { - tables[kind] = freezerTableConfig{noSnappy: true} + tables[kind] = freezerTableConfig{ + noSnappy: true, + prunable: true, + } } return NewMemoryFreezer(false, tables) }) diff --git a/core/rawdb/freezer_test.go b/core/rawdb/freezer_test.go index 3e750eb381..150734d3ac 100644 --- a/core/rawdb/freezer_test.go +++ b/core/rawdb/freezer_test.go @@ -403,7 +403,10 @@ func TestFreezerSuite(t *testing.T) { ancienttest.TestAncientSuite(t, func(kinds []string) ethdb.AncientStore { tables := make(map[string]freezerTableConfig) for _, kind := range kinds { - tables[kind] = freezerTableConfig{noSnappy: true} + tables[kind] = freezerTableConfig{ + noSnappy: true, + prunable: true, + } } f, _ := newFreezerForTesting(t, tables) return f @@ -411,7 +414,10 @@ func TestFreezerSuite(t *testing.T) { ancienttest.TestResettableAncientSuite(t, func(kinds []string) ethdb.ResettableAncientStore { tables := make(map[string]freezerTableConfig) for _, kind := range kinds { - tables[kind] = freezerTableConfig{noSnappy: true} + tables[kind] = freezerTableConfig{ + noSnappy: true, + prunable: true, + } } f, _ := newResettableFreezer(t.TempDir(), "", false, 2048, tables) return f