Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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 @@ -164,6 +166,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 @@ -211,7 +237,8 @@ func checkBlockChainState(
// Copy the database over to prevent any issues when re-using [originalDB] after this call.
originalDB, err = copyMemDB(originalDB)
require.NoError(err)
restartedChain, err := create(originalDB, gspec, lastAcceptedBlock.Hash(), oldChainDataDir)
newChainDataDir := copyFlatDir(t, oldChainDataDir)
restartedChain, err := create(originalDB, gspec, lastAcceptedBlock.Hash(), newChainDataDir)
require.NoError(err)
defer restartedChain.Stop()
currentBlock := restartedChain.CurrentBlock()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ go 1.24.8
require (
github.com/VictoriaMetrics/fastcache v1.12.1
github.com/ava-labs/avalanchego v1.13.6-0.20251007213349-63cc1a166a56
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 @@ -28,8 +28,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/ava-labs/avalanchego v1.13.6-0.20251007213349-63cc1a166a56 h1:Q4lnXtjMwsIheyRUkuOU7EZZ9WFf28vMWG4lPCmqhaE=
github.com/ava-labs/avalanchego v1.13.6-0.20251007213349-63cc1a166a56/go.mod h1:EL0MGbL2liE9jp4QtCHR2thkNl8hCkD26DJ+7cmcaqs=
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