Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion core/blockchain_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package core
import (
"fmt"
"math/big"
"os"
"path/filepath"
"slices"
"testing"

Expand Down Expand Up @@ -139,6 +141,30 @@ func copyMemDB(db ethdb.Database) (ethdb.Database, error) {
return newDB, nil
}

// This copies all files from a flat directory [src] to a new temporary directory and returns
// the path to the new directory.
func copyFlatDir(t *testing.T, src string) string {
t.Helper()
if src == "" {
return ""
}

dst := t.TempDir()
ents, err := os.ReadDir(src)
require.NoError(t, err)

for _, e := range ents {
require.False(t, e.IsDir(), "expected flat directory")
name := e.Name()
data, err := os.ReadFile(filepath.Join(src, name))
require.NoError(t, err)
info, err := e.Info()
require.NoError(t, err)
require.NoError(t, os.WriteFile(filepath.Join(dst, name), data, info.Mode().Perm()))
}
return dst
}

// checkBlockChainState creates a new BlockChain instance and checks that exporting each block from
// genesis to last accepted from the original instance yields the same last accepted block and state
// root.
Expand Down Expand Up @@ -205,7 +231,8 @@ func checkBlockChainState(
if err != nil {
t.Fatal(err)
}
restartedChain, err := create(originalDB, gspec, lastAcceptedBlock.Hash(), oldChainDataDir)
newChainDataDir := copyFlatDir(t, oldChainDataDir)
restartedChain, err := create(originalDB, gspec, lastAcceptedBlock.Hash(), newChainDataDir)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/VictoriaMetrics/fastcache v1.12.1
github.com/antithesishq/antithesis-sdk-go v0.3.8
github.com/ava-labs/avalanchego v1.13.6-rc.1
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.12
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.13
github.com/ava-labs/libevm v1.13.15-0.20251002164226-35926db4d661
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/deckarep/golang-set/v2 v2.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ github.com/ava-labs/avalanchego v1.13.6-rc.1 h1:O4qeGhxRVO5O8vfu2LMpwU5AdES/8bB2
github.com/ava-labs/avalanchego v1.13.6-rc.1/go.mod h1:27SGpJ0L+3jVMfjY8X5nmgkZ3sFSc7vGeJj+SFjAKL0=
github.com/ava-labs/coreth v0.15.4-rc.4 h1:ze7/IwDptWG1u2d32uUZz9Ix9ycVUtlB8JufuSKSSS4=
github.com/ava-labs/coreth v0.15.4-rc.4/go.mod h1:yVwuMyPkZ48xzZ0y2OdIwaoUqvSsgPYoodyX9BZJ2uo=
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.12 h1:aMcrLbpJ/dyu2kZDf/Di/4JIWsUcYPyTDKymiHpejt0=
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.12/go.mod h1:cq89ua3iiZ5wPBALTEQS5eG8DIZcs7ov6OiL4YR1BVY=
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.13 h1:obPwnVCkF5+B2f8WbTepHj0ZgiW21vKUgFCtATuAYNY=
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.13/go.mod h1:gsGr1ICjokI9CyPaaRHMqDoDCaT1VguC/IyOTx6rJ14=
github.com/ava-labs/libevm v1.13.15-0.20251002164226-35926db4d661 h1:lt4yQE1HMvxWrdD5RFj+h9kWUsZK2rmNohvkeQsbG9M=
github.com/ava-labs/libevm v1.13.15-0.20251002164226-35926db4d661/go.mod h1:ivRC/KojP8sai7j8WnpXIReQpcRklL2bIzoysnjpARQ=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
Expand Down
Loading