Skip to content

Commit

Permalink
properly construct genesis latest block header in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
djrtwo committed Jun 25, 2019
1 parent d9b9757 commit ff7f537
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
10 changes: 0 additions & 10 deletions test_libs/pyspec/eth2spec/test/fork_choice/test_on_attestation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ def run_on_attestation(spec, state, store, attestation, valid=True):
@with_state
@bls_switch
def test_on_attestation(spec, state):
state.latest_block_header = spec.BeaconBlockHeader(body_root=hash_tree_root(spec.BeaconBlockBody()))

store = spec.get_genesis_store(state)
time = 100
spec.on_tick(store, time)
Expand All @@ -52,8 +50,6 @@ def test_on_attestation(spec, state):
@with_state
@bls_switch
def test_on_attestation_target_not_in_store(spec, state):
state.latest_block_header = spec.BeaconBlockHeader(body_root=hash_tree_root(spec.BeaconBlockBody()))

store = spec.get_genesis_store(state)
time = 100
spec.on_tick(store, time)
Expand All @@ -74,8 +70,6 @@ def test_on_attestation_target_not_in_store(spec, state):
@with_state
@bls_switch
def test_on_attestation_future_epoch(spec, state):
state.latest_block_header = spec.BeaconBlockHeader(body_root=hash_tree_root(spec.BeaconBlockBody()))

store = spec.get_genesis_store(state)
time = 3 * spec.SECONDS_PER_SLOT
spec.on_tick(store, time)
Expand All @@ -98,8 +92,6 @@ def test_on_attestation_future_epoch(spec, state):
@with_state
@bls_switch
def test_on_attestation_same_slot(spec, state):
state.latest_block_header = spec.BeaconBlockHeader(body_root=hash_tree_root(spec.BeaconBlockBody()))

store = spec.get_genesis_store(state)
time = 1 * spec.SECONDS_PER_SLOT
spec.on_tick(store, time)
Expand All @@ -117,8 +109,6 @@ def test_on_attestation_same_slot(spec, state):
@with_state
@bls_switch
def test_on_attestation_invalid_attestation(spec, state):
state.latest_block_header = spec.BeaconBlockHeader(body_root=hash_tree_root(spec.BeaconBlockBody()))

store = spec.get_genesis_store(state)
time = 3 * spec.SECONDS_PER_SLOT
spec.on_tick(store, time)
Expand Down
8 changes: 0 additions & 8 deletions test_libs/pyspec/eth2spec/test/fork_choice/test_on_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ def run_on_block(spec, state, store, block, valid=True):
@with_state
@bls_switch
def test_basic(spec, state):
state.latest_block_header = spec.BeaconBlockHeader(body_root=hash_tree_root(spec.BeaconBlockBody()))

# Initialization
store = spec.get_genesis_store(state)
time = 100
Expand All @@ -48,8 +46,6 @@ def test_basic(spec, state):
@with_state
@bls_switch
def test_on_block_future_block(spec, state):
state.latest_block_header = spec.BeaconBlockHeader(body_root=hash_tree_root(spec.BeaconBlockBody()))

# Initialization
store = spec.get_genesis_store(state)

Expand All @@ -64,8 +60,6 @@ def test_on_block_future_block(spec, state):
@with_state
@bls_switch
def test_on_block_bad_parent_root(spec, state):
state.latest_block_header = spec.BeaconBlockHeader(body_root=hash_tree_root(spec.BeaconBlockBody()))

# Initialization
store = spec.get_genesis_store(state)
time = 100
Expand All @@ -81,8 +75,6 @@ def test_on_block_bad_parent_root(spec, state):
@with_state
@bls_switch
def test_on_block_before_finalized(spec, state):
state.latest_block_header = spec.BeaconBlockHeader(body_root=hash_tree_root(spec.BeaconBlockBody()))

# Initialization
store = spec.get_genesis_store(state)
time = 100
Expand Down
5 changes: 4 additions & 1 deletion test_libs/pyspec/eth2spec/test/helpers/genesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ def create_genesis_state(spec, num_validators):
deposit_root=deposit_root,
deposit_count=num_validators,
block_hash=spec.ZERO_HASH,
))
),
latest_block_header=spec.BeaconBlockHeader(body_root=spec.hash_tree_root(spec.BeaconBlockBody())),
)


# We "hack" in the initial validators,
# as it is much faster than creating and processing genesis deposits for every single test case.
Expand Down

0 comments on commit ff7f537

Please sign in to comment.