Compare commits
2
Commits
main
...
05c6ca8f5a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05c6ca8f5a | ||
|
|
422f0036fe |
@@ -16,7 +16,7 @@ func ChainDataPaths(chain string) (string, string) {
|
||||
panic("could not get function source path")
|
||||
}
|
||||
|
||||
chainPath := filepath.Join(filepath.Dir(thisPath), "..", "chain", chain)
|
||||
chainPath := filepath.Join(filepath.Dir(thisPath), "..", "data", chain)
|
||||
|
||||
chaindataPath, err := filepath.Abs(chainPath)
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package util_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||
|
||||
"github.com/cerc-io/eth-testing/chaindata/util"
|
||||
)
|
||||
|
||||
func testReadChainData(t *testing.T, name string) {
|
||||
ChainDataPath, AncientDataPath := util.ChainDataPaths(name)
|
||||
|
||||
kvdb, ldberr := rawdb.NewLevelDBDatabase(ChainDataPath, 1024, 256, "vdb-geth", false)
|
||||
if ldberr != nil {
|
||||
t.Fatal(ldberr)
|
||||
}
|
||||
edb, err := rawdb.NewDatabaseWithFreezer(kvdb, AncientDataPath, "vdb-geth", false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer edb.Close()
|
||||
|
||||
hash := rawdb.ReadHeadHeaderHash(edb)
|
||||
height := rawdb.ReadHeaderNumber(edb, hash)
|
||||
if height == nil {
|
||||
t.Fatalf("unable to read header height for header hash %s", hash)
|
||||
}
|
||||
header := rawdb.ReadHeader(edb, hash, *height)
|
||||
if header == nil {
|
||||
t.Fatalf("unable to read canonical header at height %d", height)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadChainData(t *testing.T) {
|
||||
for _, name := range []string{"small", "medium"} {
|
||||
t.Run(name, func(t *testing.T) { testReadChainData(t, name) })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user