mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
eth/tracers/live: move testdata + minor nits
This commit is contained in:
parent
8296be8909
commit
7a18fdade2
8 changed files with 9 additions and 7 deletions
|
|
@ -52,7 +52,7 @@ func (bt *blockTest) UnmarshalJSON(data []byte) error {
|
||||||
// The tests have been filled using the executable at
|
// The tests have been filled using the executable at
|
||||||
// eth/tracers/live/tests/supply_filler.go.
|
// eth/tracers/live/tests/supply_filler.go.
|
||||||
func TestSupplyTracerBlockchain(t *testing.T) {
|
func TestSupplyTracerBlockchain(t *testing.T) {
|
||||||
dirPath := filepath.Join("tests", "supply")
|
dirPath := filepath.Join("testdata", "supply")
|
||||||
files, err := os.ReadDir(dirPath)
|
files, err := os.ReadDir(dirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to retrieve tracer test suite: %v", err)
|
t.Fatalf("failed to retrieve tracer test suite: %v", err)
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
@ -137,7 +138,7 @@ func fillSupplyOmittedFields(path string) error {
|
||||||
if err := compareAsJSON(expected, out); err != nil {
|
if err := compareAsJSON(expected, out); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := writeArtifact(filepath.Join(path, "omitted_fields.json"), "omitted_fields_cancun", db, chain, expected, nil); err != nil {
|
if err := writeArtefact(filepath.Join(path, "omitted_fields.json"), "omitted_fields_cancun", db, chain, expected, nil); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -183,7 +184,7 @@ func fillSupplyGenesisAlloc(path string) error {
|
||||||
if err := compareAsJSON(expected, out); err != nil {
|
if err := compareAsJSON(expected, out); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := writeArtifact(filepath.Join(path, "genesis_alloc.json"), "genesis_alloc_grayGlacier", db, chain, expected, nil); err != nil {
|
if err := writeArtefact(filepath.Join(path, "genesis_alloc.json"), "genesis_alloc_grayGlacier", db, chain, expected, nil); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -255,7 +256,7 @@ func fillSupplyEip1559Burn(path string) error {
|
||||||
if err := compareAsJSON(expected, out); err != nil {
|
if err := compareAsJSON(expected, out); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := writeArtifact(filepath.Join(path, "eip1559_burn.json"), "eip1559_burn_grayGlacier", db, chain, expected, nil); err != nil {
|
if err := writeArtefact(filepath.Join(path, "eip1559_burn.json"), "eip1559_burn_grayGlacier", db, chain, expected, nil); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -302,7 +303,7 @@ func fillSupplyWithdrawals(path string) error {
|
||||||
if err := compareAsJSON(expected, out); err != nil {
|
if err := compareAsJSON(expected, out); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := writeArtifact(filepath.Join(path, "withdrawals.json"), "withdrawals_cancun", db, chain, expected, nil); err != nil {
|
if err := writeArtefact(filepath.Join(path, "withdrawals.json"), "withdrawals_cancun", db, chain, expected, nil); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -636,7 +637,7 @@ func fillSupplySelfdestructItselfAndRevert(path string) error {
|
||||||
if err := compareAsJSON(expected, output); err != nil {
|
if err := compareAsJSON(expected, output); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := writeArtifact(filepath.Join(path, "selfdestruct_itself_and_revert.json"), "selfdestruct_itself_and_revert_grayGlacier", db, chain, expected, nil); err != nil {
|
if err := writeArtefact(filepath.Join(path, "selfdestruct_itself_and_revert.json"), "selfdestruct_itself_and_revert_grayGlacier", db, chain, expected, nil); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -717,7 +718,7 @@ func compareAsJSON(expected interface{}, actual interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeArtifact(path, name string, db ethdb.Database, chain *core.BlockChain, expected []supplyInfo, post *types.GenesisAlloc) error {
|
func writeArtefact(path, name string, db ethdb.Database, chain *core.BlockChain, expected []supplyInfo, post *types.GenesisAlloc) error {
|
||||||
bt, err := btFromChain(db, chain, post)
|
bt, err := btFromChain(db, chain, post)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to fill tests from chain: %v", err)
|
return fmt.Errorf("failed to fill tests from chain: %v", err)
|
||||||
|
|
@ -739,6 +740,7 @@ func writeBTs(path string, tests map[string]*blockTest) error {
|
||||||
if err := os.WriteFile(path, enc, 0644); err != nil {
|
if err := os.WriteFile(path, enc, 0644); err != nil {
|
||||||
return fmt.Errorf("failed to write test to file: %v", err)
|
return fmt.Errorf("failed to write test to file: %v", err)
|
||||||
}
|
}
|
||||||
|
slog.Info("Wrote artefact", "file", path)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
Loading…
Reference in a new issue