From 03a243e96cbfa77c67d6a3ccb2c630ea7405b549 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Sun, 30 Jun 2019 05:06:17 +0800 Subject: [PATCH] fix basic test --- specs/core/0_beacon-chain.md | 2 +- .../eth2spec/test/genesis/test_genesis.py | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 4d8f6332e..7e39a5284 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -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 diff --git a/test_libs/pyspec/eth2spec/test/genesis/test_genesis.py b/test_libs/pyspec/eth2spec/test/genesis/test_genesis.py index 0023fbf5e..9c546b172 100644 --- a/test_libs/pyspec/eth2spec/test/genesis/test_genesis.py +++ b/test_libs/pyspec/eth2spec/test/genesis/test_genesis.py @@ -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