fix basic test

This commit is contained in:
Hsiao-Wei Wang 2019-06-30 05:06:17 +08:00
parent 6d45513605
commit 03a243e96c
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
2 changed files with 13 additions and 13 deletions

View File

@ -1106,7 +1106,7 @@ The genesis state `genesis_state` is the return value of the first call to `get_
def get_genesis_beacon_state(eth1_block_hash: Hash, eth1_timestamp: uint64, deposits: Sequence[Deposit]) -> BeaconState:
state = BeaconState(
genesis_time=eth1_timestamp - eth1_timestamp % SECONDS_PER_DAY + 2 * SECONDS_PER_DAY,
eth1_data=Eth1Data(block_hash=genesis_eth1_block_hash, deposit_count=len(deposits)),
eth1_data=Eth1Data(block_hash=eth1_block_hash, deposit_count=len(deposits)),
latest_block_header=BeaconBlockHeader(body_root=hash_tree_root(BeaconBlockBody())),
)
assert state.genesis_time >= MIN_GENESIS_TIME

View File

@ -6,26 +6,26 @@ from eth2spec.test.helpers.deposits import (
@with_phases(['phase0'])
@spectest_with_bls_switch
def test_genesis(spec):
def test_get_genesis_beacon_state_success(spec):
deposit_count = spec.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT
genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE)
genesis_time = 1546300800
genesis_eth1_block_hash = b'\x12' * 32
deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE)
yield "deposits", genesis_deposits
yield "genesis_time", genesis_time
eth1_block_hash = b'\x12' * 32
eth1_timestamp = spec.MIN_GENESIS_TIME
yield "genesis_eth1_block_hash", genesis_eth1_block_hash
yield "eth1_block_hash", eth1_block_hash
yield "eth1_timestamp", eth1_timestamp
yield "deposits", deposits
genesis_state = spec.get_genesis_beacon_state(
genesis_eth1_block_hash,
genesis_time,
genesis_deposits,
eth1_block_hash,
eth1_timestamp,
deposits,
)
assert genesis_state.genesis_time == genesis_time
assert genesis_state.genesis_time == eth1_timestamp - eth1_timestamp % spec.SECONDS_PER_DAY + 2 * spec.SECONDS_PER_DAY
assert len(genesis_state.validators) == deposit_count
assert genesis_state.eth1_data.deposit_root == deposit_root
assert genesis_state.eth1_data.deposit_count == deposit_count
assert genesis_state.eth1_data.block_hash == genesis_eth1_block_hash
assert genesis_state.eth1_data.block_hash == eth1_block_hash
yield "state", genesis_state