Update execution_types with latest engine_api_type changes (#156)
This commit is contained in:
parent
fc226d4511
commit
914b9ff5a1
|
@ -72,11 +72,17 @@ suite "Execution types tests":
|
|||
index: 9.Quantity
|
||||
)
|
||||
|
||||
exit = WithdrawalRequestV1(
|
||||
withdrawal = WithdrawalRequestV1(
|
||||
sourceAddress: address(7),
|
||||
validatorPublicKey: FixedBytes[48].conv(9)
|
||||
)
|
||||
|
||||
consolidation = ConsolidationRequestV1(
|
||||
sourceAddress: address(8),
|
||||
sourcePubkey: FixedBytes[48].conv(10),
|
||||
targetPubkey: FixedBytes[48].conv(11)
|
||||
)
|
||||
|
||||
test "payload version":
|
||||
var badv31 = payload
|
||||
badv31.blobGasUsed = Opt.none(Quantity)
|
||||
|
@ -168,7 +174,8 @@ suite "Execution types tests":
|
|||
test "payload version 4":
|
||||
var v4 = payload
|
||||
v4.depositRequests = Opt.some(@[deposit])
|
||||
v4.exits = Opt.some(@[exit])
|
||||
v4.withdrawalRequests = Opt.some(@[withdrawal])
|
||||
v4.consolidationRequests = Opt.some(@[consolidation])
|
||||
check v4.version == Version.V4
|
||||
|
||||
var bad41 = v4
|
||||
|
@ -176,16 +183,27 @@ suite "Execution types tests":
|
|||
check bad41.version == Version.V4
|
||||
|
||||
var bad42 = v4
|
||||
bad42.exits = Opt.none(seq[WithdrawalRequestV1])
|
||||
bad42.withdrawalRequests = Opt.none(seq[WithdrawalRequestV1])
|
||||
check bad42.version == Version.V4
|
||||
|
||||
var bad43 = v4
|
||||
bad43.consolidationRequests = Opt.none(seq[ConsolidationRequestV1])
|
||||
check bad43.version == Version.V4
|
||||
|
||||
let v41 = bad41.V4
|
||||
check v41.depositRequests == newSeq[DepositRequestV1]()
|
||||
check v41.withdrawalRequests == v4.exits.get
|
||||
check v41.withdrawalRequests == v4.withdrawalRequests.get
|
||||
check v41.consolidationRequests == v4.consolidationRequests.get
|
||||
|
||||
let v42 = bad42.V4
|
||||
check v42.depositRequests == v4.depositRequests.get
|
||||
check v42.withdrawalRequests == newSeq[WithdrawalRequestV1]()
|
||||
check v41.consolidationRequests == v4.consolidationRequests.get
|
||||
|
||||
let v43 = bad43.V4
|
||||
check v43.depositRequests == v4.depositRequests.get
|
||||
check v43.withdrawalRequests == v4.withdrawalRequests.get
|
||||
check v43.consolidationRequests == newSeq[ConsolidationRequestV1]()
|
||||
|
||||
# roundtrip
|
||||
let v4p = v4.V4
|
||||
|
|
|
@ -35,7 +35,8 @@ type
|
|||
blobGasUsed*: Opt[Quantity]
|
||||
excessBlobGas*: Opt[Quantity]
|
||||
depositRequests*: Opt[seq[DepositRequestV1]]
|
||||
exits*: Opt[seq[WithdrawalRequestV1]]
|
||||
withdrawalRequests*: Opt[seq[WithdrawalRequestV1]]
|
||||
consolidationRequests*:Opt[seq[ConsolidationRequestV1]]
|
||||
|
||||
PayloadAttributes* = object
|
||||
timestamp*: Quantity
|
||||
|
@ -64,7 +65,9 @@ type
|
|||
{.push raises: [].}
|
||||
|
||||
func version*(payload: ExecutionPayload): Version =
|
||||
if payload.depositRequests.isSome or payload.exits.isSome:
|
||||
if payload.depositRequests.isSome or
|
||||
payload.withdrawalRequests.isSome or
|
||||
payload.consolidationRequests.isSome:
|
||||
Version.V4
|
||||
elif payload.blobGasUsed.isSome or payload.excessBlobGas.isSome:
|
||||
Version.V3
|
||||
|
@ -273,7 +276,8 @@ func V4*(p: ExecutionPayload): ExecutionPayloadV4 =
|
|||
blobGasUsed: p.blobGasUsed.get(0.Quantity),
|
||||
excessBlobGas: p.excessBlobGas.get(0.Quantity),
|
||||
depositRequests: p.depositRequests.get(newSeq[DepositRequestV1]()),
|
||||
withdrawalRequests: p.exits.get(newSeq[WithdrawalRequestV1]())
|
||||
withdrawalRequests: p.withdrawalRequests.get(newSeq[WithdrawalRequestV1]()),
|
||||
consolidationRequests: p.consolidationRequests.get(newSeq[ConsolidationRequestV1]()),
|
||||
)
|
||||
|
||||
func V1*(p: ExecutionPayloadV1OrV2): ExecutionPayloadV1 =
|
||||
|
@ -391,7 +395,8 @@ func executionPayload*(p: ExecutionPayloadV4): ExecutionPayload =
|
|||
blobGasUsed: Opt.some(p.blobGasUsed),
|
||||
excessBlobGas: Opt.some(p.excessBlobGas),
|
||||
depositRequests: Opt.some(p.depositRequests),
|
||||
exits: Opt.some(p.withdrawalRequests)
|
||||
withdrawalRequests: Opt.some(p.withdrawalRequests),
|
||||
consolidationRequests: Opt.some(p.consolidationRequests),
|
||||
)
|
||||
|
||||
func executionPayload*(p: ExecutionPayloadV1OrV2): ExecutionPayload =
|
||||
|
|
Loading…
Reference in New Issue