Skip to content

Commit

Permalink
tests,fix: Clear decoder cache between tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-smith committed Sep 23, 2023
1 parent 1fd5854 commit 17941a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions eth/tracers/blocknative/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ func finalizeCallFrame(call *CallFrame, output []byte, gasUsed uint64, err error
call.Output = bytesToHex(output)
}

// EmptyCache is for testing purposes. It clears the global cache so tests don't
// interfere with each other.
func EmptyCache() {
decoderCache = decoder.NewCaches()
}

//
// Unused interface methods.
//
Expand Down
2 changes: 2 additions & 0 deletions eth/tracers/internal/tracetest/blocknative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ func loadTestTxs(dirPath string) ([]*blocknativeTracerTest, error) {
}

func executeTestCase(test *blocknativeTracerTest, t testing.TB, checkResult bool) {
blocknative.EmptyCache()

st := core.NewStateTransition(test.evm, test.msg, new(core.GasPool).AddGas(test.tx.Gas()))
if _, err := st.TransitionDb(); err != nil {
t.Fatalf("failed to execute transaction: %v", err)
Expand Down

0 comments on commit 17941a5

Please sign in to comment.