pluginNewSideBlock covered by stand alone test.

This commit is contained in:
philip-morlier 2023-06-06 11:32:13 -07:00
parent 02d22a5aad
commit 12336c753f

View File

@ -2,6 +2,8 @@ package core
import ( import (
// "reflect" // "reflect"
// "sync/atomic"
"hash"
"fmt" "fmt"
"testing" "testing"
"math/big" "math/big"
@ -16,6 +18,7 @@ import (
"github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
"golang.org/x/crypto/sha3"
) )
var ( 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) { func TestPlugethInjections(t *testing.T) {
@ -109,4 +133,15 @@ func TestPlugethInjections(t *testing.T) {
t.Fatalf("pluginReorg injection in blockChain.Reorg() not called") 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")
}
})
} }