mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-24 20:28:33 +00:00
test forks.nim capella and deneb block/state ssz serialization (#4772)
This commit is contained in:
parent
0d051b3da8
commit
ceb24d31d9
@ -223,11 +223,15 @@ OK: 3/3 Fail: 0/3 Skip: 0/3
|
|||||||
+ load altair state OK
|
+ load altair state OK
|
||||||
+ load bellatrix block OK
|
+ load bellatrix block OK
|
||||||
+ load bellatrix state OK
|
+ load bellatrix state OK
|
||||||
|
+ load capella block OK
|
||||||
|
+ load capella state OK
|
||||||
|
+ load deneb block OK
|
||||||
|
+ load deneb state OK
|
||||||
+ load phase0 block OK
|
+ load phase0 block OK
|
||||||
+ load phase0 state OK
|
+ load phase0 state OK
|
||||||
+ should raise on unknown data OK
|
+ should raise on unknown data OK
|
||||||
```
|
```
|
||||||
OK: 7/7 Fail: 0/7 Skip: 0/7
|
OK: 11/11 Fail: 0/11 Skip: 0/11
|
||||||
## Gas limit management [Beacon Node] [Preset: mainnet]
|
## Gas limit management [Beacon Node] [Preset: mainnet]
|
||||||
```diff
|
```diff
|
||||||
+ Configuring the gas limit [Beacon Node] [Preset: mainnet] OK
|
+ Configuring the gas limit [Beacon Node] [Preset: mainnet] OK
|
||||||
@ -636,4 +640,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
|
|||||||
OK: 9/9 Fail: 0/9 Skip: 0/9
|
OK: 9/9 Fail: 0/9 Skip: 0/9
|
||||||
|
|
||||||
---TOTAL---
|
---TOTAL---
|
||||||
OK: 353/358 Fail: 0/358 Skip: 5/358
|
OK: 357/362 Fail: 0/362 Skip: 5/362
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
import
|
|
||||||
unittest2,
|
|
||||||
stew/byteutils,
|
|
||||||
../beacon_chain/spec/[forks, helpers],
|
|
||||||
../beacon_chain/spec/datatypes/[phase0, altair, bellatrix]
|
|
||||||
|
|
||||||
{.used.}
|
{.used.}
|
||||||
|
|
||||||
|
import
|
||||||
|
unittest2,
|
||||||
|
../beacon_chain/spec/forks
|
||||||
|
|
||||||
template testHashedBeaconState(T: type, s: Slot) =
|
template testHashedBeaconState(T: type, s: Slot) =
|
||||||
let
|
let state = (ref T)()
|
||||||
state = (ref T)()
|
|
||||||
state[].slot = s
|
state[].slot = s
|
||||||
let
|
let
|
||||||
bytes = SSZ.encode(state[])
|
bytes = SSZ.encode(state[])
|
||||||
@ -20,11 +17,8 @@ template testHashedBeaconState(T: type, s: Slot) =
|
|||||||
forked.kind == T.toFork()
|
forked.kind == T.toFork()
|
||||||
|
|
||||||
template testTrustedSignedBeaconBlock(T: type, s: Slot) =
|
template testTrustedSignedBeaconBlock(T: type, s: Slot) =
|
||||||
let
|
let blck = (ref T)()
|
||||||
blck = (ref T)()
|
|
||||||
|
|
||||||
blck[].message.slot = s
|
blck[].message.slot = s
|
||||||
|
|
||||||
let
|
let
|
||||||
bytes = SSZ.encode(blck[])
|
bytes = SSZ.encode(blck[])
|
||||||
forked = (ref ForkedSignedBeaconBlock)()
|
forked = (ref ForkedSignedBeaconBlock)()
|
||||||
@ -38,40 +32,84 @@ suite "Type helpers":
|
|||||||
test "BeaconBlockType":
|
test "BeaconBlockType":
|
||||||
check:
|
check:
|
||||||
BeaconBlockType(ConsensusFork.Phase0) is phase0.BeaconBlock
|
BeaconBlockType(ConsensusFork.Phase0) is phase0.BeaconBlock
|
||||||
|
BeaconBlockType(ConsensusFork.Altair) is altair.BeaconBlock
|
||||||
BeaconBlockType(ConsensusFork.Bellatrix) is bellatrix.BeaconBlock
|
BeaconBlockType(ConsensusFork.Bellatrix) is bellatrix.BeaconBlock
|
||||||
|
BeaconBlockType(ConsensusFork.Capella) is capella.BeaconBlock
|
||||||
|
BeaconBlockType(ConsensusFork.Deneb) is deneb.BeaconBlock
|
||||||
|
BeaconBlockBodyType(ConsensusFork.Phase0) is phase0.BeaconBlockBody
|
||||||
BeaconBlockBodyType(ConsensusFork.Altair) is altair.BeaconBlockBody
|
BeaconBlockBodyType(ConsensusFork.Altair) is altair.BeaconBlockBody
|
||||||
BeaconBlockBodyType(ConsensusFork.Bellatrix) is bellatrix.BeaconBlockBody
|
BeaconBlockBodyType(ConsensusFork.Bellatrix) is bellatrix.BeaconBlockBody
|
||||||
|
BeaconBlockBodyType(ConsensusFork.Capella) is capella.BeaconBlockBody
|
||||||
|
BeaconBlockBodyType(ConsensusFork.Deneb) is deneb.BeaconBlockBody
|
||||||
|
|
||||||
suite "Forked SSZ readers":
|
suite "Forked SSZ readers":
|
||||||
var
|
let cfg = block:
|
||||||
cfg = defaultRuntimeConfig
|
var cfg = defaultRuntimeConfig
|
||||||
|
cfg.ALTAIR_FORK_EPOCH = Epoch(1)
|
||||||
cfg.ALTAIR_FORK_EPOCH = Epoch(1)
|
cfg.BELLATRIX_FORK_EPOCH = Epoch(2)
|
||||||
cfg.BELLATRIX_FORK_EPOCH = Epoch(2)
|
cfg.CAPELLA_FORK_EPOCH = Epoch(3)
|
||||||
|
cfg.DENEB_FORK_EPOCH = Epoch(4)
|
||||||
|
cfg
|
||||||
|
|
||||||
test "load phase0 state":
|
test "load phase0 state":
|
||||||
testHashedBeaconState(phase0.BeaconState, 0.Slot)
|
testHashedBeaconState(phase0.BeaconState, 0.Slot)
|
||||||
|
|
||||||
expect(SszError):
|
expect(SszError):
|
||||||
testHashedBeaconState(altair.BeaconState, 0.Slot)
|
testHashedBeaconState(altair.BeaconState, 0.Slot)
|
||||||
expect(SszError):
|
expect(SszError):
|
||||||
testHashedBeaconState(bellatrix.BeaconState, 0.Slot)
|
testHashedBeaconState(bellatrix.BeaconState, 0.Slot)
|
||||||
|
expect(SszError):
|
||||||
|
testHashedBeaconState(capella.BeaconState, 0.Slot)
|
||||||
|
expect(SszError):
|
||||||
|
testHashedBeaconState(deneb.BeaconState, 0.Slot)
|
||||||
|
|
||||||
test "load altair state":
|
test "load altair state":
|
||||||
testHashedBeaconState(altair.BeaconState, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
testHashedBeaconState(altair.BeaconState, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||||
|
|
||||||
expect(SszError):
|
expect(SszError):
|
||||||
testHashedBeaconState(phase0.BeaconState, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
testHashedBeaconState(phase0.BeaconState, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||||
expect(SszError):
|
expect(SszError):
|
||||||
testHashedBeaconState(bellatrix.BeaconState, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
testHashedBeaconState(bellatrix.BeaconState, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testHashedBeaconState(capella.BeaconState, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testHashedBeaconState(deneb.BeaconState, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||||
|
|
||||||
test "load bellatrix state":
|
test "load bellatrix state":
|
||||||
testHashedBeaconState(bellatrix.BeaconState, cfg.BELLATRIX_FORK_EPOCH.start_slot)
|
testHashedBeaconState(bellatrix.BeaconState, cfg.BELLATRIX_FORK_EPOCH.start_slot)
|
||||||
|
|
||||||
expect(SszError):
|
expect(SszError):
|
||||||
testHashedBeaconState(phase0.BeaconState, cfg.BELLATRIX_FORK_EPOCH.start_slot)
|
testHashedBeaconState(phase0.BeaconState, cfg.BELLATRIX_FORK_EPOCH.start_slot)
|
||||||
expect(SszError):
|
expect(SszError):
|
||||||
testHashedBeaconState(altair.BeaconState, cfg.BELLATRIX_FORK_EPOCH.start_slot)
|
testHashedBeaconState(altair.BeaconState, cfg.BELLATRIX_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testHashedBeaconState(capella.BeaconState, cfg.BELLATRIX_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testHashedBeaconState(deneb.BeaconState, cfg.BELLATRIX_FORK_EPOCH.start_slot)
|
||||||
|
|
||||||
|
test "load capella state":
|
||||||
|
testHashedBeaconState(capella.BeaconState, cfg.CAPELLA_FORK_EPOCH.start_slot)
|
||||||
|
|
||||||
|
expect(SszError):
|
||||||
|
testHashedBeaconState(phase0.BeaconState, cfg.CAPELLA_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testHashedBeaconState(altair.BeaconState, cfg.CAPELLA_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testHashedBeaconState(bellatrix.BeaconState, cfg.CAPELLA_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testHashedBeaconState(deneb.BeaconState, cfg.CAPELLA_FORK_EPOCH.start_slot)
|
||||||
|
|
||||||
|
test "load deneb state":
|
||||||
|
testHashedBeaconState(deneb.BeaconState, cfg.DENEB_FORK_EPOCH.start_slot)
|
||||||
|
|
||||||
|
expect(SszError):
|
||||||
|
testHashedBeaconState(phase0.BeaconState, cfg.DENEB_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testHashedBeaconState(altair.BeaconState, cfg.DENEB_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testHashedBeaconState(bellatrix.BeaconState, cfg.DENEB_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testHashedBeaconState(capella.BeaconState, cfg.DENEB_FORK_EPOCH.start_slot)
|
||||||
|
|
||||||
test "should raise on unknown data":
|
test "should raise on unknown data":
|
||||||
let
|
let
|
||||||
@ -80,21 +118,31 @@ suite "Forked SSZ readers":
|
|||||||
discard newClone(readSszForkedHashedBeaconState(cfg, bytes))
|
discard newClone(readSszForkedHashedBeaconState(cfg, bytes))
|
||||||
|
|
||||||
test "load phase0 block":
|
test "load phase0 block":
|
||||||
testTrustedSignedBeaconBlock(phase0.TrustedSignedBeaconBlock, 0.Slot)
|
testTrustedSignedBeaconBlock(phase0.TrustedSignedBeaconBlock, 0.Slot)
|
||||||
expect(SszError):
|
expect(SszError):
|
||||||
testTrustedSignedBeaconBlock(altair.TrustedSignedBeaconBlock, 0.Slot)
|
testTrustedSignedBeaconBlock(altair.TrustedSignedBeaconBlock, 0.Slot)
|
||||||
expect(SszError):
|
expect(SszError):
|
||||||
testTrustedSignedBeaconBlock(bellatrix.TrustedSignedBeaconBlock, 0.Slot)
|
testTrustedSignedBeaconBlock(bellatrix.TrustedSignedBeaconBlock, 0.Slot)
|
||||||
|
expect(SszError):
|
||||||
|
testTrustedSignedBeaconBlock(capella.TrustedSignedBeaconBlock, 0.Slot)
|
||||||
|
expect(SszError):
|
||||||
|
testTrustedSignedBeaconBlock(deneb.TrustedSignedBeaconBlock, 0.Slot)
|
||||||
|
|
||||||
test "load altair block":
|
test "load altair block":
|
||||||
testTrustedSignedBeaconBlock(
|
testTrustedSignedBeaconBlock(
|
||||||
altair.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
altair.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||||
expect(SszError):
|
expect(SszError):
|
||||||
testTrustedSignedBeaconBlock(
|
testTrustedSignedBeaconBlock(
|
||||||
phase0.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
phase0.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||||
expect(SszError):
|
expect(SszError):
|
||||||
testTrustedSignedBeaconBlock(
|
testTrustedSignedBeaconBlock(
|
||||||
bellatrix.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
bellatrix.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testTrustedSignedBeaconBlock(
|
||||||
|
capella.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testTrustedSignedBeaconBlock(
|
||||||
|
deneb.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||||
|
|
||||||
test "load bellatrix block":
|
test "load bellatrix block":
|
||||||
testTrustedSignedBeaconBlock(
|
testTrustedSignedBeaconBlock(
|
||||||
@ -102,10 +150,50 @@ suite "Forked SSZ readers":
|
|||||||
|
|
||||||
expect(SszError):
|
expect(SszError):
|
||||||
testTrustedSignedBeaconBlock(
|
testTrustedSignedBeaconBlock(
|
||||||
phase0.TrustedSignedBeaconBlock, cfg.BELLATRIX_FORK_EPOCH.start_slot)
|
phase0.TrustedSignedBeaconBlock, cfg.BELLATRIX_FORK_EPOCH.start_slot)
|
||||||
expect(SszError):
|
expect(SszError):
|
||||||
testTrustedSignedBeaconBlock(
|
testTrustedSignedBeaconBlock(
|
||||||
altair.TrustedSignedBeaconBlock, cfg.BELLATRIX_FORK_EPOCH.start_slot)
|
altair.TrustedSignedBeaconBlock, cfg.BELLATRIX_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testTrustedSignedBeaconBlock(
|
||||||
|
capella.TrustedSignedBeaconBlock, cfg.BELLATRIX_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testTrustedSignedBeaconBlock(
|
||||||
|
deneb.TrustedSignedBeaconBlock, cfg.BELLATRIX_FORK_EPOCH.start_slot)
|
||||||
|
|
||||||
|
test "load capella block":
|
||||||
|
testTrustedSignedBeaconBlock(
|
||||||
|
capella.TrustedSignedBeaconBlock, cfg.CAPELLA_FORK_EPOCH.start_slot)
|
||||||
|
|
||||||
|
expect(SszError):
|
||||||
|
testTrustedSignedBeaconBlock(
|
||||||
|
phase0.TrustedSignedBeaconBlock, cfg.CAPELLA_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testTrustedSignedBeaconBlock(
|
||||||
|
altair.TrustedSignedBeaconBlock, cfg.CAPELLA_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testTrustedSignedBeaconBlock(
|
||||||
|
bellatrix.TrustedSignedBeaconBlock, cfg.CAPELLA_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testTrustedSignedBeaconBlock(
|
||||||
|
deneb.TrustedSignedBeaconBlock, cfg.CAPELLA_FORK_EPOCH.start_slot)
|
||||||
|
|
||||||
|
test "load deneb block":
|
||||||
|
testTrustedSignedBeaconBlock(
|
||||||
|
deneb.TrustedSignedBeaconBlock, cfg.DENEB_FORK_EPOCH.start_slot)
|
||||||
|
|
||||||
|
expect(SszError):
|
||||||
|
testTrustedSignedBeaconBlock(
|
||||||
|
phase0.TrustedSignedBeaconBlock, cfg.DENEB_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testTrustedSignedBeaconBlock(
|
||||||
|
altair.TrustedSignedBeaconBlock, cfg.DENEB_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testTrustedSignedBeaconBlock(
|
||||||
|
bellatrix.TrustedSignedBeaconBlock, cfg.DENEB_FORK_EPOCH.start_slot)
|
||||||
|
expect(SszError):
|
||||||
|
testTrustedSignedBeaconBlock(
|
||||||
|
capella.TrustedSignedBeaconBlock, cfg.DENEB_FORK_EPOCH.start_slot)
|
||||||
|
|
||||||
test "should raise on unknown data":
|
test "should raise on unknown data":
|
||||||
let
|
let
|
||||||
|
Loading…
x
Reference in New Issue
Block a user