mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-17 13:06:34 +00:00
fix basic test
This commit is contained in:
parent
6d45513605
commit
03a243e96c
@ -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:
|
def get_genesis_beacon_state(eth1_block_hash: Hash, eth1_timestamp: uint64, deposits: Sequence[Deposit]) -> BeaconState:
|
||||||
state = BeaconState(
|
state = BeaconState(
|
||||||
genesis_time=eth1_timestamp - eth1_timestamp % SECONDS_PER_DAY + 2 * SECONDS_PER_DAY,
|
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())),
|
latest_block_header=BeaconBlockHeader(body_root=hash_tree_root(BeaconBlockBody())),
|
||||||
)
|
)
|
||||||
assert state.genesis_time >= MIN_GENESIS_TIME
|
assert state.genesis_time >= MIN_GENESIS_TIME
|
||||||
|
@ -6,26 +6,26 @@ from eth2spec.test.helpers.deposits import (
|
|||||||
|
|
||||||
@with_phases(['phase0'])
|
@with_phases(['phase0'])
|
||||||
@spectest_with_bls_switch
|
@spectest_with_bls_switch
|
||||||
def test_genesis(spec):
|
def test_get_genesis_beacon_state_success(spec):
|
||||||
deposit_count = spec.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT
|
deposit_count = spec.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT
|
||||||
genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE)
|
deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE)
|
||||||
genesis_time = 1546300800
|
|
||||||
genesis_eth1_block_hash = b'\x12' * 32
|
|
||||||
|
|
||||||
yield "deposits", genesis_deposits
|
eth1_block_hash = b'\x12' * 32
|
||||||
yield "genesis_time", genesis_time
|
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_state = spec.get_genesis_beacon_state(
|
||||||
genesis_eth1_block_hash,
|
eth1_block_hash,
|
||||||
genesis_time,
|
eth1_timestamp,
|
||||||
genesis_deposits,
|
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 len(genesis_state.validators) == deposit_count
|
||||||
assert genesis_state.eth1_data.deposit_root == deposit_root
|
assert genesis_state.eth1_data.deposit_root == deposit_root
|
||||||
assert genesis_state.eth1_data.deposit_count == deposit_count
|
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
|
yield "state", genesis_state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user