document genesis test vector format, fix missing label and assertion in tests

This commit is contained in:
protolambda 2019-06-30 14:58:53 +02:00
parent 992a51b587
commit da090b67f6
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
4 changed files with 52 additions and 3 deletions

View File

@ -0,0 +1,8 @@
# Genesis tests
The aim of the genesis tests is to provide a baseline to test genesis-state initialization and test
if the proposed genesis-validity conditions are working.
There are two handlers, documented individually:
- [`validity`](./validity.md): Tests if a genesis state is valid, i.e. if it counts as trigger to launch.
- [`initialization`](./initialization.md): Tests the initialization of a genesis state based on Eth1 data.

View File

@ -0,0 +1,22 @@
# Genesis creation testing
Tests the initialization of a genesis state based on Eth1 data.
## Test case format
```yaml
description: string -- description of test case, purely for debugging purposes
bls_setting: int -- see general test-format spec.
eth1_block_hash: Bytes32 -- the root of the Eth-1 block, hex encoded, with prefix 0x
eth1_timestamp: int -- the timestamp of the block, in seconds.
deposits: [Deposit] -- list of deposits to build the genesis state with
state: BeaconState -- the expected genesis state.
```
To process this test, build a genesis state with the provided `eth1_block_hash`, `eth1_timestamp` and `deposits`:
`initialize_beacon_state_from_eth1(eth1_block_hash, eth1_timestamp, deposits)`,
as described in the Beacon Chain specification.
## Condition
The resulting state should match the expected `state`.

View File

@ -0,0 +1,19 @@
# Genesis validity testing
Tests if a genesis state is valid, i.e. if it counts as trigger to launch.
## Test case format
```yaml
description: string -- description of test case, purely for debugging purposes
bls_setting: int -- see general test-format spec.
genesis: BeaconState -- state to validate.
is_valid: bool -- true if the genesis state is deemed valid as to launch with, false otherwise.
```
To process the data, call `is_valid_genesis_state(genesis)`.
## Condition
The result of calling `is_valid_genesis_state(genesis)` should match the expected `is_valid` boolean.

View File

@ -16,13 +16,13 @@ def create_valid_beacon_state(spec):
def run_is_valid_genesis_state(spec, state, valid=True):
"""
Run ``is_valid_genesis_state``, yielding:
- state ('state')
- genesis ('state')
- is_valid ('is_valid')
If ``valid == False``, run expecting ``AssertionError``
"""
yield state
yield 'genesis', state
is_valid = spec.is_valid_genesis_state(state)
yield 'is_valid', is_valid
assert is_valid == valid
@with_phases(['phase0'])