From 17941a579a34921f1df8fdd75448722268b563b8 Mon Sep 17 00:00:00 2001 From: Tyler Smith Date: Sat, 23 Sep 2023 16:18:27 -0400 Subject: [PATCH] tests,fix: Clear decoder cache between tests. --- eth/tracers/blocknative/tracer.go | 6 ++++++ eth/tracers/internal/tracetest/blocknative_test.go | 2 ++ 2 files changed, 8 insertions(+) diff --git a/eth/tracers/blocknative/tracer.go b/eth/tracers/blocknative/tracer.go index c407548b309d..7fa4841a7b35 100644 --- a/eth/tracers/blocknative/tracer.go +++ b/eth/tracers/blocknative/tracer.go @@ -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. // diff --git a/eth/tracers/internal/tracetest/blocknative_test.go b/eth/tracers/internal/tracetest/blocknative_test.go index c09d29ebdb6b..cb5f9c07d1e7 100644 --- a/eth/tracers/internal/tracetest/blocknative_test.go +++ b/eth/tracers/internal/tracetest/blocknative_test.go @@ -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)