mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
core/rawdb: fix tests
This commit is contained in:
parent
3e032ccd7a
commit
a32eaccaee
3 changed files with 18 additions and 7 deletions
|
|
@ -346,7 +346,6 @@ func (f *Freezer) validate() error {
|
||||||
if len(f.tables) == 0 {
|
if len(f.tables) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
head uint64
|
head uint64
|
||||||
prunedTail *uint64
|
prunedTail *uint64
|
||||||
|
|
@ -364,7 +363,7 @@ func (f *Freezer) validate() error {
|
||||||
if !table.config.prunable {
|
if !table.config.prunable {
|
||||||
// non-prunable tables have to start at 0
|
// non-prunable tables have to start at 0
|
||||||
if table.itemHidden.Load() != 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 {
|
} else {
|
||||||
// prunable tables have to have the same length
|
// prunable tables have to have the same length
|
||||||
|
|
@ -408,7 +407,7 @@ func (f *Freezer) repair() error {
|
||||||
if !table.config.prunable {
|
if !table.config.prunable {
|
||||||
// non-prunable tables have to start at 0
|
// non-prunable tables have to start at 0
|
||||||
if table.itemHidden.Load() != 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 {
|
} else {
|
||||||
// prunable tables have to have the same length
|
// prunable tables have to have the same length
|
||||||
|
|
|
||||||
|
|
@ -27,14 +27,20 @@ func TestMemoryFreezer(t *testing.T) {
|
||||||
ancienttest.TestAncientSuite(t, func(kinds []string) ethdb.AncientStore {
|
ancienttest.TestAncientSuite(t, func(kinds []string) ethdb.AncientStore {
|
||||||
tables := make(map[string]freezerTableConfig)
|
tables := make(map[string]freezerTableConfig)
|
||||||
for _, kind := range kinds {
|
for _, kind := range kinds {
|
||||||
tables[kind] = freezerTableConfig{noSnappy: true}
|
tables[kind] = freezerTableConfig{
|
||||||
|
noSnappy: true,
|
||||||
|
prunable: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NewMemoryFreezer(false, tables)
|
return NewMemoryFreezer(false, tables)
|
||||||
})
|
})
|
||||||
ancienttest.TestResettableAncientSuite(t, func(kinds []string) ethdb.ResettableAncientStore {
|
ancienttest.TestResettableAncientSuite(t, func(kinds []string) ethdb.ResettableAncientStore {
|
||||||
tables := make(map[string]freezerTableConfig)
|
tables := make(map[string]freezerTableConfig)
|
||||||
for _, kind := range kinds {
|
for _, kind := range kinds {
|
||||||
tables[kind] = freezerTableConfig{noSnappy: true}
|
tables[kind] = freezerTableConfig{
|
||||||
|
noSnappy: true,
|
||||||
|
prunable: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NewMemoryFreezer(false, tables)
|
return NewMemoryFreezer(false, tables)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -403,7 +403,10 @@ func TestFreezerSuite(t *testing.T) {
|
||||||
ancienttest.TestAncientSuite(t, func(kinds []string) ethdb.AncientStore {
|
ancienttest.TestAncientSuite(t, func(kinds []string) ethdb.AncientStore {
|
||||||
tables := make(map[string]freezerTableConfig)
|
tables := make(map[string]freezerTableConfig)
|
||||||
for _, kind := range kinds {
|
for _, kind := range kinds {
|
||||||
tables[kind] = freezerTableConfig{noSnappy: true}
|
tables[kind] = freezerTableConfig{
|
||||||
|
noSnappy: true,
|
||||||
|
prunable: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
f, _ := newFreezerForTesting(t, tables)
|
f, _ := newFreezerForTesting(t, tables)
|
||||||
return f
|
return f
|
||||||
|
|
@ -411,7 +414,10 @@ func TestFreezerSuite(t *testing.T) {
|
||||||
ancienttest.TestResettableAncientSuite(t, func(kinds []string) ethdb.ResettableAncientStore {
|
ancienttest.TestResettableAncientSuite(t, func(kinds []string) ethdb.ResettableAncientStore {
|
||||||
tables := make(map[string]freezerTableConfig)
|
tables := make(map[string]freezerTableConfig)
|
||||||
for _, kind := range kinds {
|
for _, kind := range kinds {
|
||||||
tables[kind] = freezerTableConfig{noSnappy: true}
|
tables[kind] = freezerTableConfig{
|
||||||
|
noSnappy: true,
|
||||||
|
prunable: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
f, _ := newResettableFreezer(t.TempDir(), "", false, 2048, tables)
|
f, _ := newResettableFreezer(t.TempDir(), "", false, 2048, tables)
|
||||||
return f
|
return f
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue