explicitly refer to attestation fork in SSZ consensus object tests (#6399)

Use fully qualified types when referring to attestation related types
in tests. We should also consider to merge these to a single runner.
This commit is contained in:
Etan Kissling 2024-07-03 03:40:47 +02:00 committed by GitHub
parent 12a7ed8c29
commit 1fd246b23e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 67 additions and 55 deletions

View File

@ -173,4 +173,4 @@ suite baseDescription & "Voluntary Exit " & preset():
for path in walkTests(OpVoluntaryExitDir):
runTest[SignedVoluntaryExit, typeof applyVoluntaryExit](
OpVoluntaryExitDir, suiteName, "Voluntary Exit", "voluntary_exit",
applyVoluntaryExit, path)
applyVoluntaryExit, path)

View File

@ -108,10 +108,10 @@ suite "EF - Altair - SSZ consensus objects " & preset():
let hash = loadExpectedHashTreeRoot(path)
case sszType:
of "AggregateAndProof": checkSSZ(AggregateAndProof, path, hash)
of "Attestation": checkSSZ(Attestation, path, hash)
of "AggregateAndProof": checkSSZ(phase0.AggregateAndProof, path, hash)
of "Attestation": checkSSZ(phase0.Attestation, path, hash)
of "AttestationData": checkSSZ(AttestationData, path, hash)
of "AttesterSlashing": checkSSZ(AttesterSlashing, path, hash)
of "AttesterSlashing": checkSSZ(phase0.AttesterSlashing, path, hash)
of "BeaconBlock": checkSSZ(altair.BeaconBlock, path, hash)
of "BeaconBlockBody": checkSSZ(altair.BeaconBlockBody, path, hash)
of "BeaconBlockHeader": checkSSZ(BeaconBlockHeader, path, hash)
@ -126,7 +126,8 @@ suite "EF - Altair - SSZ consensus objects " & preset():
of "Fork": checkSSZ(Fork, path, hash)
of "ForkData": checkSSZ(ForkData, path, hash)
of "HistoricalBatch": checkSSZ(HistoricalBatch, path, hash)
of "IndexedAttestation": checkSSZ(IndexedAttestation, path, hash)
of "IndexedAttestation":
checkSSZ(phase0.IndexedAttestation, path, hash)
of "LightClientBootstrap":
checkSSZ(altair.LightClientBootstrap, path, hash)
of "LightClientHeader":
@ -140,7 +141,7 @@ suite "EF - Altair - SSZ consensus objects " & preset():
of "PendingAttestation": checkSSZ(PendingAttestation, path, hash)
of "ProposerSlashing": checkSSZ(ProposerSlashing, path, hash)
of "SignedAggregateAndProof":
checkSSZ(SignedAggregateAndProof, path, hash)
checkSSZ(phase0.SignedAggregateAndProof, path, hash)
of "SignedBeaconBlock": checkSSZ(altair.SignedBeaconBlock, path, hash)
of "SignedBeaconBlockHeader":
checkSSZ(SignedBeaconBlockHeader, path, hash)

View File

@ -75,7 +75,7 @@ proc runTest[T, U](
suite baseDescription & "Attestation " & preset():
proc applyAttestation(
preState: var bellatrix.BeaconState, attestation: Attestation):
preState: var bellatrix.BeaconState, attestation: phase0.Attestation):
Result[void, cstring] =
var cache: StateCache
let
@ -90,7 +90,7 @@ suite baseDescription & "Attestation " & preset():
ok()
for path in walkTests(OpAttestationsDir):
runTest[Attestation, typeof applyAttestation](
runTest[phase0.Attestation, typeof applyAttestation](
OpAttestationsDir, suiteName, "Attestation", "attestation",
applyAttestation, path)
@ -198,4 +198,4 @@ suite baseDescription & "Voluntary Exit " & preset():
for path in walkTests(OpVoluntaryExitDir):
runTest[SignedVoluntaryExit, typeof applyVoluntaryExit](
OpVoluntaryExitDir, suiteName, "Voluntary Exit", "voluntary_exit",
applyVoluntaryExit, path)
applyVoluntaryExit, path)

View File

@ -108,8 +108,8 @@ suite "EF - Bellatrix - SSZ consensus objects " & preset():
let hash = loadExpectedHashTreeRoot(path)
case sszType:
of "AggregateAndProof": checkSSZ(AggregateAndProof, path, hash)
of "Attestation": checkSSZ(Attestation, path, hash)
of "AggregateAndProof": checkSSZ(phase0.AggregateAndProof, path, hash)
of "Attestation": checkSSZ(phase0.Attestation, path, hash)
of "AttestationData": checkSSZ(AttestationData, path, hash)
of "AttesterSlashing": checkSSZ(phase0.AttesterSlashing, path, hash)
of "BeaconBlock": checkSSZ(bellatrix.BeaconBlock, path, hash)
@ -123,9 +123,10 @@ suite "EF - Bellatrix - SSZ consensus objects " & preset():
of "DepositMessage": checkSSZ(DepositMessage, path, hash)
of "Eth1Block": checkSSZ(Eth1Block, path, hash)
of "Eth1Data": checkSSZ(Eth1Data, path, hash)
of "ExecutionPayload": checkSSZ(ExecutionPayload, path, hash)
of "ExecutionPayload":
checkSSZ(bellatrix.ExecutionPayload, path, hash)
of "ExecutionPayloadHeader":
checkSSZ(ExecutionPayloadHeader, path, hash)
checkSSZ(bellatrix.ExecutionPayloadHeader, path, hash)
of "Fork": checkSSZ(Fork, path, hash)
of "ForkData": checkSSZ(ForkData, path, hash)
of "HistoricalBatch": checkSSZ(HistoricalBatch, path, hash)
@ -145,7 +146,7 @@ suite "EF - Bellatrix - SSZ consensus objects " & preset():
of "PowBlock": checkSSZ(PowBlock, path, hash)
of "ProposerSlashing": checkSSZ(ProposerSlashing, path, hash)
of "SignedAggregateAndProof":
checkSSZ(SignedAggregateAndProof, path, hash)
checkSSZ(phase0.SignedAggregateAndProof, path, hash)
of "SignedBeaconBlock":
checkSSZ(bellatrix.SignedBeaconBlock, path, hash)
of "SignedBeaconBlockHeader":
@ -164,4 +165,4 @@ suite "EF - Bellatrix - SSZ consensus objects " & preset():
of "Validator": checkSSZ(Validator, path, hash)
of "VoluntaryExit": checkSSZ(VoluntaryExit, path, hash)
else:
raise newException(ValueError, "Unsupported test: " & sszType)
raise newException(ValueError, "Unsupported test: " & sszType)

View File

@ -79,7 +79,7 @@ proc runTest[T, U](
suite baseDescription & "Attestation " & preset():
proc applyAttestation(
preState: var capella.BeaconState, attestation: Attestation):
preState: var capella.BeaconState, attestation: phase0.Attestation):
Result[void, cstring] =
var cache: StateCache
let
@ -94,14 +94,14 @@ suite baseDescription & "Attestation " & preset():
ok()
for path in walkTests(OpAttestationsDir):
runTest[Attestation, typeof applyAttestation](
runTest[phase0.Attestation, typeof applyAttestation](
OpAttestationsDir, suiteName, "Attestation", "attestation",
applyAttestation, path)
suite baseDescription & "Attester Slashing " & preset():
proc applyAttesterSlashing(
preState: var capella.BeaconState, attesterSlashing: AttesterSlashing):
Result[void, cstring] =
preState: var capella.BeaconState,
attesterSlashing: phase0.AttesterSlashing): Result[void, cstring] =
var cache: StateCache
doAssert (? process_attester_slashing(
defaultRuntimeConfig, preState, attesterSlashing, {strictVerification},
@ -109,7 +109,7 @@ suite baseDescription & "Attester Slashing " & preset():
ok()
for path in walkTests(OpAttSlashingDir):
runTest[AttesterSlashing, typeof applyAttesterSlashing](
runTest[phase0.AttesterSlashing, typeof applyAttesterSlashing](
OpAttSlashingDir, suiteName, "Attester Slashing", "attester_slashing",
applyAttesterSlashing, path)
@ -226,4 +226,4 @@ suite baseDescription & "Withdrawals " & preset():
for path in walkTests(OpWithdrawalsDir):
runTest[capella.ExecutionPayload, typeof applyWithdrawals](
OpWithdrawalsDir, suiteName, "Withdrawals", "execution_payload",
applyWithdrawals, path)
applyWithdrawals, path)

View File

@ -110,10 +110,10 @@ suite "EF - Capella - SSZ consensus objects " & preset():
let hash = loadExpectedHashTreeRoot(path)
case sszType:
of "AggregateAndProof": checkSSZ(AggregateAndProof, path, hash)
of "Attestation": checkSSZ(Attestation, path, hash)
of "AggregateAndProof": checkSSZ(phase0.AggregateAndProof, path, hash)
of "Attestation": checkSSZ(phase0.Attestation, path, hash)
of "AttestationData": checkSSZ(AttestationData, path, hash)
of "AttesterSlashing": checkSSZ(AttesterSlashing, path, hash)
of "AttesterSlashing": checkSSZ(phase0.AttesterSlashing, path, hash)
of "BeaconBlock": checkSSZ(capella.BeaconBlock, path, hash)
of "BeaconBlockBody": checkSSZ(capella.BeaconBlockBody, path, hash)
of "BeaconBlockHeader": checkSSZ(BeaconBlockHeader, path, hash)
@ -126,14 +126,16 @@ suite "EF - Capella - SSZ consensus objects " & preset():
of "DepositMessage": checkSSZ(DepositMessage, path, hash)
of "Eth1Block": checkSSZ(Eth1Block, path, hash)
of "Eth1Data": checkSSZ(Eth1Data, path, hash)
of "ExecutionPayload": checkSSZ(ExecutionPayload, path, hash)
of "ExecutionPayload":
checkSSZ(capella.ExecutionPayload, path, hash)
of "ExecutionPayloadHeader":
checkSSZ(ExecutionPayloadHeader, path, hash)
checkSSZ(capella.ExecutionPayloadHeader, path, hash)
of "Fork": checkSSZ(Fork, path, hash)
of "ForkData": checkSSZ(ForkData, path, hash)
of "HistoricalBatch": checkSSZ(HistoricalBatch, path, hash)
of "HistoricalSummary": checkSSZ(HistoricalSummary, path, hash)
of "IndexedAttestation": checkSSZ(IndexedAttestation, path, hash)
of "IndexedAttestation":
checkSSZ(phase0.IndexedAttestation, path, hash)
of "LightClientBootstrap":
checkSSZ(capella.LightClientBootstrap, path, hash)
of "LightClientHeader":
@ -148,7 +150,7 @@ suite "EF - Capella - SSZ consensus objects " & preset():
of "PowBlock": checkSSZ(PowBlock, path, hash)
of "ProposerSlashing": checkSSZ(ProposerSlashing, path, hash)
of "SignedAggregateAndProof":
checkSSZ(SignedAggregateAndProof, path, hash)
checkSSZ(phase0.SignedAggregateAndProof, path, hash)
of "SignedBeaconBlock":
checkSSZ(capella.SignedBeaconBlock, path, hash)
of "SignedBeaconBlockHeader":

View File

@ -79,7 +79,7 @@ proc runTest[T, U](
suite baseDescription & "Attestation " & preset():
proc applyAttestation(
preState: var deneb.BeaconState, attestation: Attestation):
preState: var deneb.BeaconState, attestation: phase0.Attestation):
Result[void, cstring] =
var cache: StateCache
let
@ -94,14 +94,14 @@ suite baseDescription & "Attestation " & preset():
ok()
for path in walkTests(OpAttestationsDir):
runTest[Attestation, typeof applyAttestation](
runTest[phase0.Attestation, typeof applyAttestation](
OpAttestationsDir, suiteName, "Attestation", "attestation",
applyAttestation, path)
suite baseDescription & "Attester Slashing " & preset():
proc applyAttesterSlashing(
preState: var deneb.BeaconState, attesterSlashing: AttesterSlashing):
Result[void, cstring] =
preState: var deneb.BeaconState,
attesterSlashing: phase0.AttesterSlashing): Result[void, cstring] =
var cache: StateCache
doAssert (? process_attester_slashing(
defaultRuntimeConfig, preState, attesterSlashing, {strictVerification},
@ -109,7 +109,7 @@ suite baseDescription & "Attester Slashing " & preset():
ok()
for path in walkTests(OpAttSlashingDir):
runTest[AttesterSlashing, typeof applyAttesterSlashing](
runTest[phase0.AttesterSlashing, typeof applyAttesterSlashing](
OpAttSlashingDir, suiteName, "Attester Slashing", "attester_slashing",
applyAttesterSlashing, path)
@ -228,4 +228,4 @@ suite baseDescription & "Withdrawals " & preset():
for path in walkTests(OpWithdrawalsDir):
runTest[deneb.ExecutionPayload, typeof applyWithdrawals](
OpWithdrawalsDir, suiteName, "Withdrawals", "execution_payload",
applyWithdrawals, path)
applyWithdrawals, path)

View File

@ -113,10 +113,10 @@ suite "EF - Deneb - SSZ consensus objects " & preset():
let hash = loadExpectedHashTreeRoot(path)
case sszType:
of "AggregateAndProof": checkSSZ(AggregateAndProof, path, hash)
of "Attestation": checkSSZ(Attestation, path, hash)
of "AggregateAndProof": checkSSZ(phase0.AggregateAndProof, path, hash)
of "Attestation": checkSSZ(phase0.Attestation, path, hash)
of "AttestationData": checkSSZ(AttestationData, path, hash)
of "AttesterSlashing": checkSSZ(AttesterSlashing, path, hash)
of "AttesterSlashing": checkSSZ(phase0.AttesterSlashing, path, hash)
of "BeaconBlock": checkSSZ(deneb.BeaconBlock, path, hash)
of "BeaconBlockBody": checkSSZ(deneb.BeaconBlockBody, path, hash)
of "BeaconBlockHeader": checkSSZ(BeaconBlockHeader, path, hash)
@ -131,18 +131,22 @@ suite "EF - Deneb - SSZ consensus objects " & preset():
of "DepositMessage": checkSSZ(DepositMessage, path, hash)
of "Eth1Block": checkSSZ(Eth1Block, path, hash)
of "Eth1Data": checkSSZ(Eth1Data, path, hash)
of "ExecutionPayload": checkSSZ(ExecutionPayload, path, hash)
of "ExecutionPayload":
checkSSZ(deneb.ExecutionPayload, path, hash)
of "ExecutionPayloadHeader":
checkSSZ(ExecutionPayloadHeader, path, hash)
checkSSZ(deneb.ExecutionPayloadHeader, path, hash)
of "Fork": checkSSZ(Fork, path, hash)
of "ForkData": checkSSZ(ForkData, path, hash)
of "HistoricalBatch": checkSSZ(HistoricalBatch, path, hash)
of "HistoricalSummary": checkSSZ(HistoricalSummary, path, hash)
of "IndexedAttestation": checkSSZ(IndexedAttestation, path, hash)
of "IndexedAttestation":
checkSSZ(phase0.IndexedAttestation, path, hash)
of "LightClientBootstrap":
checkSSZ(deneb.LightClientBootstrap, path, hash)
of "LightClientHeader": checkSSZ(deneb.LightClientHeader, path, hash)
of "LightClientUpdate": checkSSZ(deneb.LightClientUpdate, path, hash)
of "LightClientHeader":
checkSSZ(deneb.LightClientHeader, path, hash)
of "LightClientUpdate":
checkSSZ(deneb.LightClientUpdate, path, hash)
of "LightClientFinalityUpdate":
checkSSZ(deneb.LightClientFinalityUpdate, path, hash)
of "LightClientOptimisticUpdate":
@ -151,7 +155,7 @@ suite "EF - Deneb - SSZ consensus objects " & preset():
of "PowBlock": checkSSZ(PowBlock, path, hash)
of "ProposerSlashing": checkSSZ(ProposerSlashing, path, hash)
of "SignedAggregateAndProof":
checkSSZ(SignedAggregateAndProof, path, hash)
checkSSZ(phase0.SignedAggregateAndProof, path, hash)
of "SignedBeaconBlock":
checkSSZ(deneb.SignedBeaconBlock, path, hash)
of "SignedBeaconBlockHeader":

View File

@ -276,4 +276,4 @@ suite baseDescription & "Withdrawals " & preset():
for path in walkTests(OpWithdrawalsDir):
runTest[electra.ExecutionPayload, typeof applyWithdrawals](
OpWithdrawalsDir, suiteName, "Withdrawals", "execution_payload",
applyWithdrawals, path)
applyWithdrawals, path)

View File

@ -136,9 +136,10 @@ suite "EF - Electra - SSZ consensus objects " & preset():
of "DepositRequest": checkSSZ(DepositRequest, path, hash)
of "Eth1Block": checkSSZ(Eth1Block, path, hash)
of "Eth1Data": checkSSZ(Eth1Data, path, hash)
of "ExecutionPayload": checkSSZ(ExecutionPayload, path, hash)
of "ExecutionPayload":
checkSSZ(electra.ExecutionPayload, path, hash)
of "ExecutionPayloadHeader":
checkSSZ(ExecutionPayloadHeader, path, hash)
checkSSZ(electra.ExecutionPayloadHeader, path, hash)
of "Fork": checkSSZ(Fork, path, hash)
of "ForkData": checkSSZ(ForkData, path, hash)
of "HistoricalBatch": checkSSZ(HistoricalBatch, path, hash)
@ -146,8 +147,10 @@ suite "EF - Electra - SSZ consensus objects " & preset():
of "IndexedAttestation": checkSSZ(electra.IndexedAttestation, path, hash)
of "LightClientBootstrap":
checkSSZ(electra.LightClientBootstrap, path, hash)
of "LightClientHeader": checkSSZ(electra.LightClientHeader, path, hash)
of "LightClientUpdate": checkSSZ(electra.LightClientUpdate, path, hash)
of "LightClientHeader":
checkSSZ(electra.LightClientHeader, path, hash)
of "LightClientUpdate":
checkSSZ(electra.LightClientUpdate, path, hash)
of "LightClientFinalityUpdate":
checkSSZ(electra.LightClientFinalityUpdate, path, hash)
of "LightClientOptimisticUpdate":
@ -184,4 +187,4 @@ suite "EF - Electra - SSZ consensus objects " & preset():
of "VoluntaryExit": checkSSZ(VoluntaryExit, path, hash)
of "WithdrawalRequest": checkSSZ(WithdrawalRequest, path, hash)
else:
raise newException(ValueError, "Unsupported test: " & sszType)
raise newException(ValueError, "Unsupported test: " & sszType)

View File

@ -150,4 +150,4 @@ suite baseDescription & "Voluntary Exit " & preset():
for path in walkTests(OpVoluntaryExitDir):
runTest[SignedVoluntaryExit, typeof applyVoluntaryExit](
OpVoluntaryExitDir, suiteName, "Voluntary Exit", "voluntary_exit",
applyVoluntaryExit, path)
applyVoluntaryExit, path)

View File

@ -108,10 +108,10 @@ suite "EF - Phase 0 - SSZ consensus objects " & preset():
let hash = loadExpectedHashTreeRoot(path)
case sszType:
of "AggregateAndProof": checkSSZ(AggregateAndProof, path, hash)
of "Attestation": checkSSZ(Attestation, path, hash)
of "AggregateAndProof": checkSSZ(phase0.AggregateAndProof, path, hash)
of "Attestation": checkSSZ(phase0.Attestation, path, hash)
of "AttestationData": checkSSZ(AttestationData, path, hash)
of "AttesterSlashing": checkSSZ(AttesterSlashing, path, hash)
of "AttesterSlashing": checkSSZ(phase0.AttesterSlashing, path, hash)
of "BeaconBlock": checkSSZ(phase0.BeaconBlock, path, hash)
of "BeaconBlockBody": checkSSZ(phase0.BeaconBlockBody, path, hash)
of "BeaconBlockHeader": checkSSZ(BeaconBlockHeader, path, hash)
@ -125,11 +125,12 @@ suite "EF - Phase 0 - SSZ consensus objects " & preset():
of "Fork": checkSSZ(Fork, path, hash)
of "ForkData": checkSSZ(ForkData, path, hash)
of "HistoricalBatch": checkSSZ(HistoricalBatch, path, hash)
of "IndexedAttestation": checkSSZ(IndexedAttestation, path, hash)
of "IndexedAttestation":
checkSSZ(phase0.IndexedAttestation, path, hash)
of "PendingAttestation": checkSSZ(PendingAttestation, path, hash)
of "ProposerSlashing": checkSSZ(ProposerSlashing, path, hash)
of "SignedAggregateAndProof":
checkSSZ(SignedAggregateAndProof, path, hash)
checkSSZ(phase0.SignedAggregateAndProof, path, hash)
of "SignedBeaconBlock": checkSSZ(phase0.SignedBeaconBlock, path, hash)
of "SignedBeaconBlockHeader":
checkSSZ(SignedBeaconBlockHeader, path, hash)