nimbus-eth1/hive_integration/nodocker/engine/engine_tests.nim

373 lines
8.7 KiB
Nim
Raw Normal View History

import
2023-08-21 02:08:54 +00:00
./engine/engine_spec,
./types,
./test_env
2023-08-21 02:08:54 +00:00
proc specExecute(ws: BaseSpec): bool =
var
ws = EngineSpec(ws)
env = TestEnv.new(ws.chainFile, false)
env.engine.setRealTTD(ws.ttd)
env.setupCLMock()
2023-08-21 02:08:54 +00:00
if ws.slotsToFinalized != 0:
env.slotsToFinalized(ws.slotsToFinalized)
if ws.slotsToSafe != 0:
env.slotsToSafe(ws.slotsToSafe)
2023-08-21 02:08:54 +00:00
result = ws.exec(env)
env.close()
2022-06-17 00:53:33 +00:00
2023-08-21 02:08:54 +00:00
let engineTestList* = [
2022-06-01 13:32:07 +00:00
# Engine API Negative Test Cases
2023-08-21 02:08:54 +00:00
TestDesc(
name: "Invalid Terminal Block in ForkchoiceUpdated",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidTerminalBlockForkchoiceUpdated,
ttd: 1000000
))#[,
TestDesc(
name: "Invalid GetPayload Under PoW",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidGetPayloadUnderPoW,
ttd: 1000000
)),
TestDesc(
name: "Invalid Terminal Block in NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidTerminalBlockNewPayload,
ttd: 1000000,
)),
TestDesc(
2022-06-01 13:32:07 +00:00
name: "Inconsistent Head in ForkchoiceState",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: inconsistentForkchoiceState1,
)),
TestDesc(
2022-06-01 13:32:07 +00:00
name: "Inconsistent Safe in ForkchoiceState",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: inconsistentForkchoiceState2,
)),
TestDesc(
2022-06-01 13:32:07 +00:00
name: "Inconsistent Finalized in ForkchoiceState",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: inconsistentForkchoiceState3,
)),
TestDesc(
name: "Unknown HeadBlockHash",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: unknownHeadBlockHash,
)),
TestDesc(
name: "Unknown SafeBlockHash",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: unknownSafeBlockHash,
)),
TestDesc(
name: "Unknown FinalizedBlockHash",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: unknownFinalizedBlockHash,
)),
TestDesc(
2022-06-01 13:32:07 +00:00
name: "ForkchoiceUpdated Invalid Payload Attributes",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayloadAttributes1,
)),
TestDesc(
2022-06-01 13:32:07 +00:00
name: "ForkchoiceUpdated Invalid Payload Attributes (Syncing)",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayloadAttributes2,
)),
TestDesc(
name: "Pre-TTD ForkchoiceUpdated After PoS Switch",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: preTTDFinalizedBlockHash,
ttd: 2,
)),
2022-06-01 13:32:07 +00:00
# Invalid Payload Tests
2023-08-21 02:08:54 +00:00
TestDesc(
name: "Bad Hash on NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: badHashOnNewPayload1,
)),
TestDesc(
2022-06-01 13:32:07 +00:00
name: "Bad Hash on NewPayload Syncing",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: badHashOnNewPayload2,
)),
TestDesc(
2022-06-01 13:32:07 +00:00
name: "Bad Hash on NewPayload Side Chain",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: badHashOnNewPayload3,
)),
TestDesc(
2022-06-01 13:32:07 +00:00
name: "Bad Hash on NewPayload Side Chain Syncing",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: badHashOnNewPayload4,
)),
TestDesc(
name: "ParentHash==BlockHash on NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: parentHashOnExecPayload,
)),
TestDesc(
2022-06-17 00:53:33 +00:00
name: "Invalid Transition Payload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidTransitionPayload,
ttd: 393504,
chainFile: "blocks_2_td_393504.rlp",
)),
TestDesc(
name: "Invalid ParentHash NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload1,
)),
TestDesc(
name: "Invalid StateRoot NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload2,
)),
TestDesc(
2022-06-13 09:42:01 +00:00
name: "Invalid StateRoot NewPayload, Empty Transactions",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload3,
)),
TestDesc(
name: "Invalid ReceiptsRoot NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload4,
)),
TestDesc(
name: "Invalid Number NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload5,
)),
TestDesc(
name: "Invalid GasLimit NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload6,
)),
TestDesc(
name: "Invalid GasUsed NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload7,
)),
TestDesc(
name: "Invalid Timestamp NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload8,
)),
TestDesc(
name: "Invalid PrevRandao NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload9,
)),
TestDesc(
name: "Invalid Incomplete Transactions NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload10,
)),
TestDesc(
name: "Invalid Transaction Signature NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload11,
)),
TestDesc(
name: "Invalid Transaction Nonce NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload12,
)),
TestDesc(
name: "Invalid Transaction GasPrice NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload13,
)),
TestDesc(
name: "Invalid Transaction Gas NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload14,
)),
TestDesc(
name: "Invalid Transaction Value NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidPayload15,
)),
# Invalid Ancestor Re-Org Tests (Reveal via newPayload)
2023-08-21 02:08:54 +00:00
TestDesc(
name: "Invalid Ancestor Chain Re-Org, Invalid StateRoot, Invalid P1', Reveal using newPayload",
slotsToFinalized: 20,
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidMissingAncestor1,
)),
TestDesc(
name: "Invalid Ancestor Chain Re-Org, Invalid StateRoot, Invalid P9', Reveal using newPayload",
slotsToFinalized: 20,
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidMissingAncestor2,
)),
TestDesc(
name: "Invalid Ancestor Chain Re-Org, Invalid StateRoot, Invalid P10', Reveal using newPayload",
slotsToFinalized: 20,
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: invalidMissingAncestor3,
)),
# Eth RPC Status on ForkchoiceUpdated Events
2023-08-21 02:08:54 +00:00
TestDesc(
name: "Latest Block after NewPayload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: blockStatusExecPayload1,
)),
TestDesc(
2022-06-01 13:32:07 +00:00
name: "Latest Block after NewPayload (Transition Block)",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: blockStatusExecPayload2,
ttd: 5,
)),
TestDesc(
name: "Latest Block after New HeadBlock",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: blockStatusHeadBlock1,
)),
TestDesc(
2022-06-01 13:32:07 +00:00
name: "Latest Block after New HeadBlock (Transition Block)",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: blockStatusHeadBlock2,
ttd: 5,
)),
TestDesc(
name: "safe Block after New SafeBlockHash",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: blockStatusSafeBlock,
ttd: 5,
)),
TestDesc(
name: "finalized Block after New FinalizedBlockHash",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: blockStatusFinalizedBlock,
ttd: 5,
)),
TestDesc(
name: "Latest Block after Reorg",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: blockStatusReorg,
)),
# Payload Tests
2023-08-21 02:08:54 +00:00
TestDesc(
name: "Re-Execute Payload",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: reExecPayloads,
)),
TestDesc(
name: "Multiple New Payloads Extending Canonical Chain",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: multipleNewCanonicalPayloads,
)),
TestDesc(
name: "Out of Order Payload Execution",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: outOfOrderPayloads,
)),
# Transaction Reorg using Engine API
2023-08-21 02:08:54 +00:00
TestDesc(
name: "Transaction Reorg",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: transactionReorg,
)),
TestDesc(
name: "Sidechain Reorg",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: sidechainReorg,
)),
TestDesc(
2022-06-01 13:32:07 +00:00
name: "Re-Org Back into Canonical Chain",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: reorgBack,
)),
TestDesc(
2022-06-01 13:32:07 +00:00
name: "Re-Org Back to Canonical Chain From Syncing Chain",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: reorgBackFromSyncing,
)),
# Suggested Fee Recipient in Payload creation
2023-08-21 02:08:54 +00:00
TestDesc(
name: "Suggested Fee Recipient Test",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: suggestedFeeRecipient,
)),
# PrevRandao opcode tests
2023-08-21 02:08:54 +00:00
TestDesc(
2022-04-20 07:57:50 +00:00
name: "PrevRandao Opcode Transactions",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: prevRandaoOpcodeTx,
ttd: 10,
)),
# Multi-Client Sync tests
2023-08-21 02:08:54 +00:00
TestDesc(
name: "Sync Client Post Merge",
2023-08-21 02:08:54 +00:00
run: specExecute,
spec: EngineSpec(
exec: postMergeSync,
ttd: 10,
)),]#
]