mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-26 05:27:19 +00:00
f06db2f37b
* save state * add current index feature * fix test * remove logs * Only execute 1000 blocks * Reset history index * Correct action * Increase batch size * Increase chunk size, print memory stats * Fix linter * Remove unused from * Split into 2 staged * Use storage history gen * remove log * Not to run tx_cacher in staged mode * Not to recover during stage 2 * Not to recover during stage 2 * Remove counter Co-authored-by: b00ris <b00ris@mail.ru>
77 lines
1.6 KiB
Go
77 lines
1.6 KiB
Go
package migrations
|
|
|
|
import (
|
|
"github.com/ledgerwatch/turbo-geth/common/dbutils"
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
|
"testing"
|
|
)
|
|
|
|
func TestApplyWithInit(t *testing.T) {
|
|
db := ethdb.NewMemDatabase()
|
|
migrations = []Migration{
|
|
{
|
|
"one",
|
|
func(db ethdb.Database, history, receipts, txIndex, preImages bool) error {
|
|
return nil
|
|
},
|
|
},
|
|
{
|
|
"two",
|
|
func(db ethdb.Database, history, receipts, txIndex, preImages bool) error {
|
|
return nil
|
|
},
|
|
},
|
|
}
|
|
|
|
migrator := NewMigrator()
|
|
migrator.Migrations = migrations
|
|
err := migrator.Apply(db, false, false, false, false)
|
|
if err != nil {
|
|
t.Fatal()
|
|
}
|
|
v, err := db.Get(dbutils.DatabaseInfoBucket, dbutils.LastAppliedMigration)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if string(v) != migrations[1].Name {
|
|
t.Fatal()
|
|
}
|
|
}
|
|
|
|
func TestApplyWithoutInit(t *testing.T) {
|
|
db := ethdb.NewMemDatabase()
|
|
migrations = []Migration{
|
|
{
|
|
"one",
|
|
func(db ethdb.Database, history, receipts, txIndex, preImages bool) error {
|
|
t.Fatal("shouldn't been executed")
|
|
return nil
|
|
},
|
|
},
|
|
{
|
|
"two",
|
|
func(db ethdb.Database, history, receipts, txIndex, preImages bool) error {
|
|
return nil
|
|
},
|
|
},
|
|
}
|
|
err := db.Put(dbutils.DatabaseInfoBucket, dbutils.LastAppliedMigration, []byte(migrations[0].Name))
|
|
if err != nil {
|
|
t.Fatal()
|
|
}
|
|
|
|
migrator := NewMigrator()
|
|
migrator.Migrations = migrations
|
|
err = migrator.Apply(db, false, false, false, false)
|
|
if err != nil {
|
|
t.Fatal()
|
|
}
|
|
v, err := db.Get(dbutils.DatabaseInfoBucket, dbutils.LastAppliedMigration)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if string(v) != migrations[1].Name {
|
|
t.Fatal()
|
|
}
|
|
}
|