mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 13:07:17 +00:00
965d1101f4
* another way to check if account has storage * cleanup * v0 of walk by db version * save progress, to switch to another task. Put tombstone is still not correct. * place tombstone only if exists something to hide * db-based implementation * db-based implementation * db-based implementation * fix prop check * improve prop check logic * Need custom logic to skip subtree for account and storage buckets because storage bucket has incarnation in key * rebase to master * remove all tombstones when account deleted * remove all tombstones when account deleted * added db integrity check * don't rely on account.Root because it valid only about last incarnation * remove all tombstones when account deleted * dial with incarnation in MultiWalk2 * dial with incarnation in MultiWalk2 * when fixedbytes=40 resolver did compare cacheKey with storageKey without removing incarnation * rebase to master * rebase to master Co-authored-by: alex.sharov <alex.sharov@lazada.com>
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/common"
|
|
"github.com/ledgerwatch/turbo-geth/common/dbutils"
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
|
)
|
|
|
|
func TestMigrate(t *testing.T) {
|
|
db := ethdb.NewMemDatabase()
|
|
|
|
err := db.Put(dbutils.AccountsBucket, common.Hex2Bytes("03601462093b5945d1676df093446790fd31b20e7b12a2e8e5e09d068109616b"), common.Hex2Bytes("c8808502540be40080"))
|
|
if err != nil {
|
|
t.Errorf(err.Error())
|
|
}
|
|
|
|
err = db.Put(dbutils.AccountsBucket, common.Hex2Bytes("0fbc62ba90dec43ec1d6016f9dd39dc324e967f2a3459a78281d1f4b2ba962a6"), common.Hex2Bytes("f845806480a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a04f1593970e8f030c0a2c39758181a447774eae7c65653c4e6440e8c18dad69bc"))
|
|
if err != nil {
|
|
t.Errorf(err.Error())
|
|
}
|
|
|
|
err = convertDatabaseToCBOR(db.KV(), 1)
|
|
if err != nil {
|
|
t.Errorf(err.Error())
|
|
}
|
|
|
|
val1, err := db.Get(dbutils.AccountsBucket, common.Hex2Bytes("03601462093b5945d1676df093446790fd31b20e7b12a2e8e5e09d068109616b"))
|
|
if err != nil {
|
|
t.Errorf(err.Error())
|
|
}
|
|
|
|
val2, err := db.Get(dbutils.AccountsBucket, common.Hex2Bytes("0fbc62ba90dec43ec1d6016f9dd39dc324e967f2a3459a78281d1f4b2ba962a6"))
|
|
if err != nil {
|
|
t.Errorf(err.Error())
|
|
}
|
|
|
|
expected1 := "020502540be400"
|
|
expected2 := "120164204f1593970e8f030c0a2c39758181a447774eae7c65653c4e6440e8c18dad69bc"
|
|
|
|
if common.Bytes2Hex(val1) != expected1 {
|
|
t.Errorf("Expected %s, got %s", expected1, common.Bytes2Hex(val1))
|
|
}
|
|
|
|
if common.Bytes2Hex(val2) != expected2 {
|
|
t.Errorf("Expected %s, got %s", expected2, common.Bytes2Hex(val2))
|
|
}
|
|
}
|