Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
billettc committed Sep 17, 2024
1 parent dffc6aa commit bb5e033
Show file tree
Hide file tree
Showing 8 changed files with 1,779 additions and 1,829 deletions.
3 changes: 0 additions & 3 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,6 @@ func (st *StateTransition) innerTransitionDb() (*ExecutionResult, error) {
t.OnGasChange(st.gasRemaining, st.gasRemaining-gas, tracing.GasChangeTxIntrinsicGas)
}
}
if t := st.evm.Config.Tracer; t != nil && t.OnGasChange != nil {
t.OnGasChange(st.gasRemaining, st.gasRemaining-gas, tracing.GasChangeTxIntrinsicGas)
}
st.gasRemaining -= gas

if rules.IsEIP4762 {
Expand Down
36 changes: 3 additions & 33 deletions eth/tracers/internal/tracetest/firehose/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package firehose_test

import (
"fmt"
"hash"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/trie"
"math/big"
"os"
"testing"
Expand All @@ -11,15 +12,13 @@ import (
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/tracing"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/tests"
"github.com/stretchr/testify/require"
"golang.org/x/crypto/sha3"
)

func runPrestateBlock(t *testing.T, prestatePath string, hooks *tracing.Hooks) {
Expand Down Expand Up @@ -48,7 +47,7 @@ func runPrestateBlock(t *testing.T, prestatePath string, hooks *tracing.Hooks) {
GasLimit: context.GasLimit,
BaseFee: context.BaseFee,
ParentBeaconRoot: ptr(common.Hash{}),
}, &types.Body{Transactions: []*types.Transaction{tx}}, nil, nil)
}, &types.Body{Transactions: []*types.Transaction{tx}}, nil, trie.NewStackTrie(nil))

hooks.OnBlockchainInit(prestate.Genesis.Config)
hooks.OnBlockStart(tracing.BlockEvent{
Expand Down Expand Up @@ -97,35 +96,6 @@ func newBlockchain(t *testing.T, alloc types.GenesisAlloc, context vm.BlockConte
return genesis, blockchain
}

// testHasher is the helper tool for transaction/receipt list hashing.
// The original hasher is trie, in order to get rid of import cycle,
// use the testing hasher instead.
type testHasher struct {
hasher hash.Hash
}

// NewHasher returns a new testHasher instance.
func NewHasher() *testHasher {
return &testHasher{hasher: sha3.NewLegacyKeccak256()}
}

// Reset resets the hash state.
func (h *testHasher) Reset() {
h.hasher.Reset()
}

// Update updates the hash state with the given key and value.
func (h *testHasher) Update(key, val []byte) error {
h.hasher.Write(key)
h.hasher.Write(val)
return nil
}

// Hash returns the hash value.
func (h *testHasher) Hash() common.Hash {
return common.BytesToHash(h.hasher.Sum(nil))
}

type ignoreValidateStateValidator struct {
core.Validator
}
Expand Down
Loading

0 comments on commit bb5e033

Please sign in to comment.