wrap `applyExecutionPayload` in factories for Nim 2.0 (#5395)
In Nim 2.0, the `test_fixture_operations` files fail to compile with: ``` Error: 'result' is of type <Result[system.void, system.cstring]> which cannot be captured as it would violate memory safety, declared here: /nimbus-eth2/tests/consensus_spec/bellatrix/test_fixture_operations.nim(130, 5); using '-d:nimNoLentIterators' helps in some cases. Consider using a <ref Result[system.void, system.cstring]> which can be captured. ``` Wrapping the `applyExecutionPayload` in a factory that takes `path` avoids this problem.
This commit is contained in:
parent
81397342d0
commit
6af70e2f80
|
@ -126,17 +126,19 @@ suite baseDescription & "Deposit " & preset():
|
||||||
OpDepositsDir, suiteName, "Deposit", "deposit", applyDeposit, path)
|
OpDepositsDir, suiteName, "Deposit", "deposit", applyDeposit, path)
|
||||||
|
|
||||||
suite baseDescription & "Execution Payload " & preset():
|
suite baseDescription & "Execution Payload " & preset():
|
||||||
for path in walkTests(OpExecutionPayloadDir):
|
proc makeApplyExecutionPayloadCb(path: string): auto =
|
||||||
proc applyExecutionPayload(
|
return proc(
|
||||||
preState: var bellatrix.BeaconState, body: bellatrix.BeaconBlockBody):
|
preState: var bellatrix.BeaconState, body: bellatrix.BeaconBlockBody):
|
||||||
Result[void, cstring] =
|
Result[void, cstring] =
|
||||||
let payloadValid =
|
let payloadValid = os_ops.readFile(
|
||||||
os_ops.readFile(OpExecutionPayloadDir/"pyspec_tests"/path/"execution.yaml").
|
OpExecutionPayloadDir/"pyspec_tests"/path/"execution.yaml"
|
||||||
contains("execution_valid: true")
|
).contains("execution_valid: true")
|
||||||
func executePayload(_: bellatrix.ExecutionPayload): bool = payloadValid
|
func executePayload(_: bellatrix.ExecutionPayload): bool = payloadValid
|
||||||
process_execution_payload(
|
process_execution_payload(
|
||||||
preState, body.execution_payload, executePayload)
|
preState, body.execution_payload, executePayload)
|
||||||
|
|
||||||
|
for path in walkTests(OpExecutionPayloadDir):
|
||||||
|
let applyExecutionPayload = makeApplyExecutionPayloadCb(path)
|
||||||
runTest[bellatrix.BeaconBlockBody, typeof applyExecutionPayload](
|
runTest[bellatrix.BeaconBlockBody, typeof applyExecutionPayload](
|
||||||
OpExecutionPayloadDir, suiteName, "Execution Payload", "body",
|
OpExecutionPayloadDir, suiteName, "Execution Payload", "body",
|
||||||
applyExecutionPayload, path)
|
applyExecutionPayload, path)
|
||||||
|
|
|
@ -143,17 +143,19 @@ suite baseDescription & "Deposit " & preset():
|
||||||
OpDepositsDir, suiteName, "Deposit", "deposit", applyDeposit, path)
|
OpDepositsDir, suiteName, "Deposit", "deposit", applyDeposit, path)
|
||||||
|
|
||||||
suite baseDescription & "Execution Payload " & preset():
|
suite baseDescription & "Execution Payload " & preset():
|
||||||
for path in walkTests(OpExecutionPayloadDir):
|
proc makeApplyExecutionPayloadCb(path: string): auto =
|
||||||
proc applyExecutionPayload(
|
return proc(
|
||||||
preState: var capella.BeaconState, body: capella.BeaconBlockBody):
|
preState: var capella.BeaconState, body: capella.BeaconBlockBody):
|
||||||
Result[void, cstring] =
|
Result[void, cstring] =
|
||||||
let payloadValid =
|
let payloadValid = os_ops.readFile(
|
||||||
os_ops.readFile(OpExecutionPayloadDir/"pyspec_tests"/path/"execution.yaml").
|
OpExecutionPayloadDir/"pyspec_tests"/path/"execution.yaml"
|
||||||
contains("execution_valid: true")
|
).contains("execution_valid: true")
|
||||||
func executePayload(_: capella.ExecutionPayload): bool = payloadValid
|
func executePayload(_: capella.ExecutionPayload): bool = payloadValid
|
||||||
process_execution_payload(
|
process_execution_payload(
|
||||||
preState, body.execution_payload, executePayload)
|
preState, body.execution_payload, executePayload)
|
||||||
|
|
||||||
|
for path in walkTests(OpExecutionPayloadDir):
|
||||||
|
let applyExecutionPayload = makeApplyExecutionPayloadCb(path)
|
||||||
runTest[capella.BeaconBlockBody, typeof applyExecutionPayload](
|
runTest[capella.BeaconBlockBody, typeof applyExecutionPayload](
|
||||||
OpExecutionPayloadDir, suiteName, "Execution Payload", "body",
|
OpExecutionPayloadDir, suiteName, "Execution Payload", "body",
|
||||||
applyExecutionPayload, path)
|
applyExecutionPayload, path)
|
||||||
|
|
|
@ -146,16 +146,18 @@ suite baseDescription & "Deposit " & preset():
|
||||||
OpDepositsDir, suiteName, "Deposit", "deposit", applyDeposit, path)
|
OpDepositsDir, suiteName, "Deposit", "deposit", applyDeposit, path)
|
||||||
|
|
||||||
suite baseDescription & "Execution Payload " & preset():
|
suite baseDescription & "Execution Payload " & preset():
|
||||||
for path in walkTests(OpExecutionPayloadDir):
|
proc makeApplyExecutionPayloadCb(path: string): auto =
|
||||||
proc applyExecutionPayload(
|
return proc(
|
||||||
preState: var deneb.BeaconState, body: deneb.BeaconBlockBody):
|
preState: var deneb.BeaconState, body: deneb.BeaconBlockBody):
|
||||||
Result[void, cstring] =
|
Result[void, cstring] =
|
||||||
let payloadValid =
|
let payloadValid = os_ops.readFile(
|
||||||
os_ops.readFile(OpExecutionPayloadDir/"pyspec_tests"/path/"execution.yaml").
|
OpExecutionPayloadDir/"pyspec_tests"/path/"execution.yaml"
|
||||||
contains("execution_valid: true")
|
).contains("execution_valid: true")
|
||||||
func executePayload(_: deneb.ExecutionPayload): bool = payloadValid
|
func executePayload(_: deneb.ExecutionPayload): bool = payloadValid
|
||||||
process_execution_payload(preState, body, executePayload)
|
process_execution_payload(preState, body, executePayload)
|
||||||
|
|
||||||
|
for path in walkTests(OpExecutionPayloadDir):
|
||||||
|
let applyExecutionPayload = makeApplyExecutionPayloadCb(path)
|
||||||
runTest[deneb.BeaconBlockBody, typeof applyExecutionPayload](
|
runTest[deneb.BeaconBlockBody, typeof applyExecutionPayload](
|
||||||
OpExecutionPayloadDir, suiteName, "Execution Payload", "body",
|
OpExecutionPayloadDir, suiteName, "Execution Payload", "body",
|
||||||
applyExecutionPayload, path)
|
applyExecutionPayload, path)
|
||||||
|
|
Loading…
Reference in New Issue