Changes to core/blockchain_hook_test, core/state/plugin_hooks, and eth/plugin_hooks to reslove issues discovered in pull review 9-17-21
This commit is contained in:
@@ -1,22 +1,29 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/ethereum/go-ethereum/plugins"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/plugins"
|
||||
"github.com/openrelayxyz/plugeth-utils/core"
|
||||
)
|
||||
|
||||
|
||||
func TestReorgLongHeadersHook(t *testing.T) {
|
||||
invoked := false
|
||||
done := plugins.HookTester("NewHead", func(b *types.Block, h common.Hash, logs []*types.Log) {
|
||||
// invoked = true
|
||||
if b == nil { t.Errorf("Expected block to be non-nil") }
|
||||
if h == (common.Hash{}) { t.Errorf("Expected hash to be non-empty") }
|
||||
if len(logs) > 0 { t.Errorf("Expected some logs") }
|
||||
})
|
||||
defer done()
|
||||
testReorgLong(t, true)
|
||||
if !invoked { t.Errorf("Expected plugin invocation")}
|
||||
invoked := false
|
||||
done := plugins.HookTester("NewHead", func(b []byte, h core.Hash, logs [][]byte) {
|
||||
invoked = true
|
||||
if b == nil {
|
||||
t.Errorf("Expected block to be non-nil")
|
||||
}
|
||||
if h == (core.Hash{}) {
|
||||
t.Errorf("Expected hash to be non-empty")
|
||||
}
|
||||
if len(logs) > 0 {
|
||||
t.Errorf("Expected some logs")
|
||||
}
|
||||
})
|
||||
defer done()
|
||||
testReorgLong(t, true)
|
||||
if !invoked {
|
||||
t.Errorf("Expected plugin invocation")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import (
|
||||
"github.com/openrelayxyz/plugeth-utils/core"
|
||||
)
|
||||
|
||||
// TODO (philip): change common.Hash to core.Hash,
|
||||
|
||||
func PluginStateUpdate(pl *plugins.PluginLoader, blockRoot, parentRoot common.Hash, destructs map[common.Hash]struct{}, accounts map[common.Hash][]byte, storage map[common.Hash]map[common.Hash][]byte) {
|
||||
fnList := pl.Lookup("StateUpdate", func(item interface{}) bool {
|
||||
_, ok := item.(func(core.Hash, core.Hash, map[core.Hash]struct{}, map[core.Hash][]byte, map[core.Hash]map[core.Hash][]byte))
|
||||
|
||||
Reference in New Issue
Block a user