engine_api: add getPayloadV3 and newPayloadV3 to echangeCapabilities
also add echangeCapabilities test to hive sim
This commit is contained in:
parent
e9630a9200
commit
ec17a5a348
|
@ -67,6 +67,12 @@ proc newPayloadV2*(client: RpcClient,
|
|||
wrapTrySimpleRes:
|
||||
client.engine_newPayloadV2(payload)
|
||||
|
||||
proc exchangeCapabilities*(client: RpcClient,
|
||||
methods: seq[string]):
|
||||
Result[seq[string], string] =
|
||||
wrapTrySimpleRes:
|
||||
client.engine_exchangeCapabilities(methods)
|
||||
|
||||
proc toBlockNumber(n: Option[HexQuantityStr]): common.BlockNumber =
|
||||
if n.isNone:
|
||||
return 0.toBlockNumber
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
import
|
||||
"."/[types, test_env, engine_tests, auths_tests],
|
||||
"."/[types, test_env],
|
||||
../sim_utils
|
||||
|
||||
import
|
||||
./engine_tests,
|
||||
./auths_tests,
|
||||
./exchange_cap_tests
|
||||
|
||||
proc combineTests(): seq[TestSpec] =
|
||||
result = @engineTestList
|
||||
result.add @authTestList
|
||||
|
@ -23,6 +28,12 @@ proc main() =
|
|||
t.stopELClient()
|
||||
stat.inc(x.name, status)
|
||||
|
||||
for x in exchangeCapTestList:
|
||||
let env = setupELClient(x.conf)
|
||||
let status = x.run(env)
|
||||
env.stopELClient()
|
||||
stat.inc(x.name, status)
|
||||
|
||||
let elpd = getTime() - start
|
||||
print(stat, elpd, "engine")
|
||||
echo stat
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
import
|
||||
./test_env,
|
||||
./types,
|
||||
unittest2,
|
||||
chronicles,
|
||||
../../tools/common/helpers,
|
||||
../../nimbus/common/hardforks
|
||||
|
||||
type
|
||||
ECTestSpec* = object
|
||||
name*: string
|
||||
run*: proc(t: TestEnv): TestStatus
|
||||
conf*: ChainConfig
|
||||
|
||||
const
|
||||
ShanghaiCapabilities = [
|
||||
"engine_newPayloadV1",
|
||||
"engine_newPayloadV2",
|
||||
"engine_forkchoiceUpdatedV1",
|
||||
"engine_forkchoiceUpdatedV2",
|
||||
"engine_getPayloadV1",
|
||||
"engine_getPayloadV2",
|
||||
]
|
||||
CancunCapabilities = [
|
||||
"engine_newPayloadV1",
|
||||
"engine_newPayloadV2",
|
||||
"engine_newPayloadV3",
|
||||
"engine_forkchoiceUpdatedV1",
|
||||
"engine_forkchoiceUpdatedV2",
|
||||
"engine_getPayloadV1",
|
||||
"engine_getPayloadV2",
|
||||
"engine_getPayloadV3",
|
||||
]
|
||||
|
||||
proc ecImpl(t: TestEnv, minExpectedCaps: openArray[string]): TestStatus =
|
||||
result = TestStatus.OK
|
||||
let res = t.rpcClient.exchangeCapabilities(@minExpectedCaps)
|
||||
testCond res.isOk:
|
||||
error "Unable request capabilities", msg=res.error
|
||||
|
||||
let returnedCaps = res.get
|
||||
for x in minExpectedCaps:
|
||||
testCond x in returnedCaps:
|
||||
error "Expected capability not found", cap=x
|
||||
|
||||
proc ecShanghai(env: TestEnv): TestStatus =
|
||||
ecImpl(env, ShanghaiCapabilities)
|
||||
|
||||
proc ecCancun(env: TestEnv): TestStatus =
|
||||
ecImpl(env, CancunCapabilities)
|
||||
|
||||
proc getCCShanghai(timestamp: int): ChainConfig =
|
||||
result = getChainConfig("Shanghai")
|
||||
result.shanghaiTime = some(fromUnix(timestamp))
|
||||
|
||||
proc getCCCancun(timestamp: int): ChainConfig =
|
||||
result = getChainConfig("Cancun")
|
||||
result.cancunTime = some(fromUnix(timestamp))
|
||||
|
||||
# const doesn't work with ref object
|
||||
let exchangeCapTestList* = [
|
||||
ECTestSpec(
|
||||
name: "Exchange Capabilities - Shanghai",
|
||||
run: ecShanghai,
|
||||
conf: getCCShanghai(0)
|
||||
),
|
||||
ECTestSpec(
|
||||
name: "Exchange Capabilities - Shanghai (Not active)",
|
||||
run: ecShanghai,
|
||||
conf: getCCShanghai(1000)
|
||||
),
|
||||
ECTestSpec(
|
||||
name: "Exchange Capabilities - Cancun",
|
||||
run: ecCancun,
|
||||
conf: getCCCancun(0)
|
||||
),
|
||||
ECTestSpec(
|
||||
name: "Exchange Capabilities - Cancun (Not active)",
|
||||
run: ecCancun,
|
||||
conf: getCCCancun(1000)
|
||||
)
|
||||
]
|
|
@ -92,7 +92,7 @@ proc setupELClient*(t: TestEnv, chainFile: string, enableAuth: bool) =
|
|||
# so it can know the latest account state
|
||||
let head = t.com.db.getCanonicalHead()
|
||||
doAssert txPool.smartHead(head)
|
||||
|
||||
|
||||
var key: JwtSharedKey
|
||||
let kr = key.fromHex(jwtSecret)
|
||||
if kr.isErr:
|
||||
|
@ -141,6 +141,13 @@ proc setupELClient*(chainFile: string, enableAuth: bool): TestEnv =
|
|||
)
|
||||
setupELClient(result, chainFile, enableAuth)
|
||||
|
||||
proc setupELClient*(conf: ChainConfig): TestEnv =
|
||||
result = TestEnv(
|
||||
conf: makeConfig(@["--engine-signer:658bdf435d810c91414ec09147daa6db62406379", "--custom-network:" & genesisFile])
|
||||
)
|
||||
result.conf.networkParams.config = conf
|
||||
setupELClient(result, "", false)
|
||||
|
||||
proc stopELClient*(t: TestEnv) =
|
||||
waitFor t.rpcClient.close()
|
||||
waitFor t.sealingEngine.stop()
|
||||
|
|
|
@ -468,8 +468,10 @@ const supportedMethods: HashSet[string] =
|
|||
toHashSet([
|
||||
"engine_newPayloadV1",
|
||||
"engine_newPayloadV2",
|
||||
"engine_newPayloadV3",
|
||||
"engine_getPayloadV1",
|
||||
"engine_getPayloadV2",
|
||||
"engine_getPayloadV3",
|
||||
"engine_exchangeTransitionConfigurationV1",
|
||||
"engine_forkchoiceUpdatedV1",
|
||||
"engine_forkchoiceUpdatedV2",
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 04f56c593a035af1b7bebdc726543a2a73826412
|
||||
Subproject commit 943431de3fa16d7349b363c35ba5ea9f80b423d3
|
Loading…
Reference in New Issue