diff --git a/core/plugeth_injection_test.go b/core/plugeth_injection_test.go index 3068cb68e..06c10f51b 100644 --- a/core/plugeth_injection_test.go +++ b/core/plugeth_injection_test.go @@ -2,6 +2,8 @@ package core import ( // "reflect" + // "sync/atomic" + "hash" "fmt" "testing" "math/big" @@ -16,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" + "golang.org/x/crypto/sha3" ) var ( @@ -61,6 +64,27 @@ var ( } ) +type testHasher struct { + hasher hash.Hash +} + +func newHasher() *testHasher { + return &testHasher{hasher: sha3.NewLegacyKeccak256()} +} + +func (h *testHasher) Reset() { + h.hasher.Reset() +} + +func (h *testHasher) Update(key, val []byte) { + h.hasher.Write(key) + h.hasher.Write(val) +} + +func (h *testHasher) Hash() common.Hash { + return common.BytesToHash(h.hasher.Sum(nil)) +} + func TestPlugethInjections(t *testing.T) { @@ -109,4 +133,15 @@ func TestPlugethInjections(t *testing.T) { t.Fatalf("pluginReorg injection in blockChain.Reorg() not called") } }) + + t.Run(fmt.Sprintf("test NewSideBlock"), func(t *testing.T) { + called := false + injectionCalled = &called + + TestReorgToShorterRemovesCanonMapping(t) + + if *injectionCalled != true { + t.Fatalf("pluginNewSideBlock injection in blockChain.writeBlockAndSetHead() not called") + } + }) } \ No newline at end of file