add EF finality tests (#1515)

This commit is contained in:
tersec 2020-08-17 07:19:48 +00:00 committed by GitHub
parent b4f9908d9d
commit ed9bec0147
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 49 deletions

View File

@ -40,6 +40,15 @@ OK: 8/8 Fail: 0/8 Skip: 0/8
+ Slashings - small_penalty [Preset: mainnet] OK
```
OK: 3/3 Fail: 0/3 Skip: 0/3
## Official - Finality [Preset: mainnet]
```diff
+ [Valid] Official - Finality - finality_no_updates_at_genesis [Preset: mainnet] OK
+ [Valid] Official - Finality - finality_rule_1 [Preset: mainnet] OK
+ [Valid] Official - Finality - finality_rule_2 [Preset: mainnet] OK
+ [Valid] Official - Finality - finality_rule_3 [Preset: mainnet] OK
+ [Valid] Official - Finality - finality_rule_4 [Preset: mainnet] OK
```
OK: 5/5 Fail: 0/5 Skip: 0/5
## Official - Operations - Attestations [Preset: mainnet]
```diff
+ [Invalid] after_epoch_slots OK
@ -188,38 +197,38 @@ OK: 9/9 Fail: 0/9 Skip: 0/9
OK: 44/44 Fail: 0/44 Skip: 0/44
## Official - Sanity - Blocks [Preset: mainnet]
```diff
+ [Invalid] double_same_proposer_slashings_same_block OK
+ [Invalid] double_similar_proposer_slashings_same_block OK
+ [Invalid] double_validator_exit_same_block OK
+ [Invalid] duplicate_attester_slashing OK
+ [Invalid] expected_deposit_in_block OK
+ [Invalid] invalid_block_sig OK
+ [Invalid] invalid_proposer_index_sig_from_expected_proposer OK
+ [Invalid] invalid_proposer_index_sig_from_proposer_index OK
+ [Invalid] invalid_state_root OK
+ [Invalid] parent_from_same_slot OK
+ [Invalid] prev_slot_block_transition OK
+ [Invalid] proposal_for_genesis_slot OK
+ [Invalid] same_slot_block_transition OK
+ [Invalid] zero_block_sig OK
+ [Valid] attestation OK
+ [Valid] attester_slashing OK
+ [Valid] balance_driven_status_transitions OK
+ [Valid] deposit_in_block OK
+ [Valid] deposit_top_up OK
+ [Valid] empty_block_transition OK
+ [Valid] empty_epoch_transition OK
+ [Valid] high_proposer_index OK
+ [Valid] historical_batch OK
+ [Valid] multiple_attester_slashings_no_overlap OK
+ [Valid] multiple_attester_slashings_partial_overlap OK
+ [Valid] multiple_different_proposer_slashings_same_block OK
+ [Valid] multiple_different_validator_exits_same_block OK
+ [Valid] proposer_after_inactive_index OK
+ [Valid] proposer_self_slashing OK
+ [Valid] proposer_slashing OK
+ [Valid] skipped_slots OK
+ [Valid] voluntary_exit OK
+ [Invalid] Official - Sanity - Blocks - double_same_proposer_slashings_same_block [Preset: OK
+ [Invalid] Official - Sanity - Blocks - double_similar_proposer_slashings_same_block [Prese OK
+ [Invalid] Official - Sanity - Blocks - double_validator_exit_same_block [Preset: mainnet] OK
+ [Invalid] Official - Sanity - Blocks - duplicate_attester_slashing [Preset: mainnet] OK
+ [Invalid] Official - Sanity - Blocks - expected_deposit_in_block [Preset: mainnet] OK
+ [Invalid] Official - Sanity - Blocks - invalid_block_sig [Preset: mainnet] OK
+ [Invalid] Official - Sanity - Blocks - invalid_proposer_index_sig_from_expected_proposer [ OK
+ [Invalid] Official - Sanity - Blocks - invalid_proposer_index_sig_from_proposer_index [Pre OK
+ [Invalid] Official - Sanity - Blocks - invalid_state_root [Preset: mainnet] OK
+ [Invalid] Official - Sanity - Blocks - parent_from_same_slot [Preset: mainnet] OK
+ [Invalid] Official - Sanity - Blocks - prev_slot_block_transition [Preset: mainnet] OK
+ [Invalid] Official - Sanity - Blocks - proposal_for_genesis_slot [Preset: mainnet] OK
+ [Invalid] Official - Sanity - Blocks - same_slot_block_transition [Preset: mainnet] OK
+ [Invalid] Official - Sanity - Blocks - zero_block_sig [Preset: mainnet] OK
+ [Valid] Official - Sanity - Blocks - attestation [Preset: mainnet] OK
+ [Valid] Official - Sanity - Blocks - attester_slashing [Preset: mainnet] OK
+ [Valid] Official - Sanity - Blocks - balance_driven_status_transitions [Preset: mainnet] OK
+ [Valid] Official - Sanity - Blocks - deposit_in_block [Preset: mainnet] OK
+ [Valid] Official - Sanity - Blocks - deposit_top_up [Preset: mainnet] OK
+ [Valid] Official - Sanity - Blocks - empty_block_transition [Preset: mainnet] OK
+ [Valid] Official - Sanity - Blocks - empty_epoch_transition [Preset: mainnet] OK
+ [Valid] Official - Sanity - Blocks - high_proposer_index [Preset: mainnet] OK
+ [Valid] Official - Sanity - Blocks - historical_batch [Preset: mainnet] OK
+ [Valid] Official - Sanity - Blocks - multiple_attester_slashings_no_overlap [Preset: mai OK
+ [Valid] Official - Sanity - Blocks - multiple_attester_slashings_partial_overlap [Preset OK
+ [Valid] Official - Sanity - Blocks - multiple_different_proposer_slashings_same_block [P OK
+ [Valid] Official - Sanity - Blocks - multiple_different_validator_exits_same_block [Pres OK
+ [Valid] Official - Sanity - Blocks - proposer_after_inactive_index [Preset: mainnet] OK
+ [Valid] Official - Sanity - Blocks - proposer_self_slashing [Preset: mainnet] OK
+ [Valid] Official - Sanity - Blocks - proposer_slashing [Preset: mainnet] OK
+ [Valid] Official - Sanity - Blocks - skipped_slots [Preset: mainnet] OK
+ [Valid] Official - Sanity - Blocks - voluntary_exit [Preset: mainnet] OK
```
OK: 32/32 Fail: 0/32 Skip: 0/32
## Official - Sanity - Slots [Preset: mainnet]
@ -233,4 +242,4 @@ OK: 32/32 Fail: 0/32 Skip: 0/32
OK: 5/5 Fail: 0/5 Skip: 0/5
---TOTAL---
OK: 179/179 Fail: 0/179 Skip: 0/179
OK: 184/184 Fail: 0/184 Skip: 0/184

View File

@ -17,34 +17,34 @@ import
../testutil,
./fixtures_utils
const SanityBlocksDir = SszTestsDir/const_preset/"phase0"/"sanity"/"blocks"/"pyspec_tests"
const
FinalityDir = SszTestsDir/const_preset/"phase0"/"finality"/"finality"/"pyspec_tests"
SanityBlocksDir = SszTestsDir/const_preset/"phase0"/"sanity"/"blocks"/"pyspec_tests"
proc runTest(identifier: string) =
proc runTest(testName, testDir, unitTestName: string) =
# We wrap the tests in a proc to avoid running out of globals
# in the future: Nim supports up to 3500 globals
# but unittest with the macro/templates put everything as globals
# https://github.com/nim-lang/Nim/issues/12084#issue-486866402
let testDir = SanityBlocksDir / identifier
let testPath = testDir / unitTestName
proc `testImpl _ blck _ identifier`() =
let prefix = if existsFile(testDir/"post.ssz"):
"[Valid] "
else:
"[Invalid] "
proc `testImpl _ blck _ testName`() =
let
hasPostState = existsFile(testPath/"post.ssz")
prefix = if hasPostState: "[Valid] " else: "[Invalid] "
timedTest prefix & identifier:
timedTest prefix & testName & " - " & unitTestName & preset():
var
preState = newClone(parseTest(testDir/"pre.ssz", SSZ, BeaconState))
hasPostState = existsFile(testDir/"post.ssz")
preState = newClone(parseTest(testPath/"pre.ssz", SSZ, BeaconState))
hashedPreState = (ref HashedBeaconState)(
data: preState[], root: hash_tree_root(preState[]))
# In test cases with more than 10 blocks the first 10 aren't 0-prefixed,
# so purely lexicographic sorting wouldn't sort properly.
let numBlocks = toSeq(walkPattern(testDir/"blocks_*.ssz")).len
let numBlocks = toSeq(walkPattern(testPath/"blocks_*.ssz")).len
for i in 0 ..< numBlocks:
let blck = parseTest(testDir/"blocks_" & $i & ".ssz", SSZ, SignedBeaconBlock)
let blck = parseTest(testPath/"blocks_" & $i & ".ssz", SSZ, SignedBeaconBlock)
if hasPostState:
let success = state_transition(
@ -57,13 +57,17 @@ proc runTest(identifier: string) =
"We didn't expect these invalid blocks to be processed"
if hasPostState:
let postState = newClone(parseTest(testDir/"post.ssz", SSZ, BeaconState))
let postState = newClone(parseTest(testPath/"post.ssz", SSZ, BeaconState))
when false:
reportDiff(hashedPreState.data, postState)
doAssert hashedPreState.root == postState[].hash_tree_root()
`testImpl _ blck _ identifier`()
`testImpl _ blck _ testName`()
suiteReport "Official - Sanity - Blocks " & preset():
for kind, path in walkDir(SanityBlocksDir, true):
runTest(path)
runTest("Official - Sanity - Blocks", SanityBlocksDir, path)
suiteReport "Official - Finality " & preset():
for kind, path in walkDir(FinalityDir, true):
runTest("Official - Finality", FinalityDir, path)