mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-04 16:25:10 +00:00
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:
|
wrapTrySimpleRes:
|
||||||
client.engine_newPayloadV2(payload)
|
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 =
|
proc toBlockNumber(n: Option[HexQuantityStr]): common.BlockNumber =
|
||||||
if n.isNone:
|
if n.isNone:
|
||||||
return 0.toBlockNumber
|
return 0.toBlockNumber
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
import
|
import
|
||||||
"."/[types, test_env, engine_tests, auths_tests],
|
"."/[types, test_env],
|
||||||
../sim_utils
|
../sim_utils
|
||||||
|
|
||||||
|
import
|
||||||
|
./engine_tests,
|
||||||
|
./auths_tests,
|
||||||
|
./exchange_cap_tests
|
||||||
|
|
||||||
proc combineTests(): seq[TestSpec] =
|
proc combineTests(): seq[TestSpec] =
|
||||||
result = @engineTestList
|
result = @engineTestList
|
||||||
result.add @authTestList
|
result.add @authTestList
|
||||||
@ -23,6 +28,12 @@ proc main() =
|
|||||||
t.stopELClient()
|
t.stopELClient()
|
||||||
stat.inc(x.name, status)
|
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
|
let elpd = getTime() - start
|
||||||
print(stat, elpd, "engine")
|
print(stat, elpd, "engine")
|
||||||
echo stat
|
echo stat
|
||||||
|
82
hive_integration/nodocker/engine/exchange_cap_tests.nim
Normal file
82
hive_integration/nodocker/engine/exchange_cap_tests.nim
Normal file
@ -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
|
# so it can know the latest account state
|
||||||
let head = t.com.db.getCanonicalHead()
|
let head = t.com.db.getCanonicalHead()
|
||||||
doAssert txPool.smartHead(head)
|
doAssert txPool.smartHead(head)
|
||||||
|
|
||||||
var key: JwtSharedKey
|
var key: JwtSharedKey
|
||||||
let kr = key.fromHex(jwtSecret)
|
let kr = key.fromHex(jwtSecret)
|
||||||
if kr.isErr:
|
if kr.isErr:
|
||||||
@ -141,6 +141,13 @@ proc setupELClient*(chainFile: string, enableAuth: bool): TestEnv =
|
|||||||
)
|
)
|
||||||
setupELClient(result, chainFile, enableAuth)
|
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) =
|
proc stopELClient*(t: TestEnv) =
|
||||||
waitFor t.rpcClient.close()
|
waitFor t.rpcClient.close()
|
||||||
waitFor t.sealingEngine.stop()
|
waitFor t.sealingEngine.stop()
|
||||||
|
@ -468,8 +468,10 @@ const supportedMethods: HashSet[string] =
|
|||||||
toHashSet([
|
toHashSet([
|
||||||
"engine_newPayloadV1",
|
"engine_newPayloadV1",
|
||||||
"engine_newPayloadV2",
|
"engine_newPayloadV2",
|
||||||
|
"engine_newPayloadV3",
|
||||||
"engine_getPayloadV1",
|
"engine_getPayloadV1",
|
||||||
"engine_getPayloadV2",
|
"engine_getPayloadV2",
|
||||||
|
"engine_getPayloadV3",
|
||||||
"engine_exchangeTransitionConfigurationV1",
|
"engine_exchangeTransitionConfigurationV1",
|
||||||
"engine_forkchoiceUpdatedV1",
|
"engine_forkchoiceUpdatedV1",
|
||||||
"engine_forkchoiceUpdatedV2",
|
"engine_forkchoiceUpdatedV2",
|
||||||
|
2
vendor/nim-web3
vendored
2
vendor/nim-web3
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 04f56c593a035af1b7bebdc726543a2a73826412
|
Subproject commit 943431de3fa16d7349b363c35ba5ea9f80b423d3
|
Loading…
x
Reference in New Issue
Block a user