forked from cerc-io/plugeth
Merge remote-tracking branch 'origin/bugfix/engine-hook-test' into merge/geth-v1.13.6
This commit is contained in:
commit
d0d5d38a59
@ -17,6 +17,7 @@ var (
|
|||||||
backend restricted.Backend
|
backend restricted.Backend
|
||||||
log core.Logger
|
log core.Logger
|
||||||
events core.Feed
|
events core.Feed
|
||||||
|
createEngineCalled bool
|
||||||
)
|
)
|
||||||
|
|
||||||
var httpApiFlagName = "http.api"
|
var httpApiFlagName = "http.api"
|
||||||
@ -107,6 +108,7 @@ func (e *engine) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CreateEngine(chainConfig *params.ChainConfig, db restricted.Database) consensus.Engine {
|
func CreateEngine(chainConfig *params.ChainConfig, db restricted.Database) consensus.Engine {
|
||||||
|
createEngineCalled = true
|
||||||
return &engine{}
|
return &engine{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/openrelayxyz/plugeth-utils/core"
|
"github.com/openrelayxyz/plugeth-utils/core"
|
||||||
|
"github.com/openrelayxyz/plugeth-utils/restricted"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,6 +38,15 @@ func GetAPIs(stack core.Node, backend core.Backend) []core.API {
|
|||||||
return apis
|
return apis
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func InitializeNode(stack core.Node, b restricted.Backend) {
|
||||||
|
go func() {
|
||||||
|
m := map[string]struct{}{
|
||||||
|
"InitializeNode":struct{}{},
|
||||||
|
}
|
||||||
|
hookChan <- m
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
// func OnShutdown(){
|
// func OnShutdown(){
|
||||||
// this injection is covered by another test in this package. See documentation for details.
|
// this injection is covered by another test in this package. See documentation for details.
|
||||||
// }
|
// }
|
||||||
@ -187,6 +197,17 @@ func OpCodeSelect() []int {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eth/ethconfig
|
||||||
|
|
||||||
|
func pseudoCreateEngine() {
|
||||||
|
if createEngineCalled {
|
||||||
|
m := map[string]struct{}{
|
||||||
|
"CreateEngine":struct{}{},
|
||||||
|
}
|
||||||
|
hookChan <- m
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// rpc/
|
// rpc/
|
||||||
|
|
||||||
|
|
||||||
@ -239,6 +260,8 @@ func Is160(num *big.Int) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var plugins map[string]struct{} = map[string]struct{}{
|
var plugins map[string]struct{} = map[string]struct{}{
|
||||||
|
"InitializeNode":struct{}{},
|
||||||
|
"CreateEngine":struct{}{},
|
||||||
"OnShutdown": struct{}{},
|
"OnShutdown": struct{}{},
|
||||||
"SetTrieFlushIntervalClone":struct{}{},
|
"SetTrieFlushIntervalClone":struct{}{},
|
||||||
"StateUpdate": struct{}{},
|
"StateUpdate": struct{}{},
|
||||||
|
@ -53,6 +53,10 @@ func BlockChain() {
|
|||||||
var ok bool
|
var ok bool
|
||||||
f := func(key string) bool {_, ok = m[key]; return ok}
|
f := func(key string) bool {_, ok = m[key]; return ok}
|
||||||
switch {
|
switch {
|
||||||
|
case f("InitializeNode"):
|
||||||
|
delete(plugins, "InitializeNode")
|
||||||
|
case f("CreateEngine"):
|
||||||
|
delete(plugins, "CreateEngine")
|
||||||
case f("OnShutdown"):
|
case f("OnShutdown"):
|
||||||
delete(plugins, "OnShutdown")
|
delete(plugins, "OnShutdown")
|
||||||
case f("StateUpdate"):
|
case f("StateUpdate"):
|
||||||
@ -139,6 +143,7 @@ func BlockChain() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
pseudoCreateEngine()
|
||||||
txFactory()
|
txFactory()
|
||||||
txTracer()
|
txTracer()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user