Skip to content

Commit

Permalink
eth/tracers/live: move testdata + minor nits
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Nov 20, 2024
1 parent 36fb2cf commit 20ae72c
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion eth/tracers/live/supply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (bt *blockTest) UnmarshalJSON(data []byte) error {
// The tests have been filled using the executable at
// eth/tracers/live/tests/supply_filler.go.
func TestSupplyTracerBlockchain(t *testing.T) {
dirPath := filepath.Join("tests", "supply")
dirPath := filepath.Join("testdata", "supply")
files, err := os.ReadDir(dirPath)
if err != nil {
t.Fatalf("failed to retrieve tracer test suite: %v", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"log/slog"
"math/big"
"os"
"path"
Expand Down Expand Up @@ -137,7 +138,7 @@ func fillSupplyOmittedFields(path string) error {
if err := compareAsJSON(expected, out); err != nil {
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 nil
Expand Down Expand Up @@ -183,7 +184,7 @@ func fillSupplyGenesisAlloc(path string) error {
if err := compareAsJSON(expected, out); err != nil {
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 nil
Expand Down Expand Up @@ -255,7 +256,7 @@ func fillSupplyEip1559Burn(path string) error {
if err := compareAsJSON(expected, out); err != nil {
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 nil
Expand Down Expand Up @@ -302,7 +303,7 @@ func fillSupplyWithdrawals(path string) error {
if err := compareAsJSON(expected, out); err != nil {
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 nil
Expand Down Expand Up @@ -636,7 +637,7 @@ func fillSupplySelfdestructItselfAndRevert(path string) error {
if err := compareAsJSON(expected, output); err != nil {
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 nil
Expand Down Expand Up @@ -717,7 +718,7 @@ func compareAsJSON(expected interface{}, actual interface{}) error {
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)
if err != nil {
return fmt.Errorf("failed to fill tests from chain: %v", err)
Expand All @@ -739,6 +740,7 @@ func writeBTs(path string, tests map[string]*blockTest) error {
if err := os.WriteFile(path, enc, 0644); err != nil {
return fmt.Errorf("failed to write test to file: %v", err)
}
slog.Info("Wrote artefact", "file", path)
return nil
}

Expand Down

0 comments on commit 20ae72c

Please sign in to comment.