mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-20 07:29:02 +00:00
Enable Altair genesis tests
This commit is contained in:
parent
8de676fc94
commit
78211a3649
@ -1,14 +1,21 @@
|
||||
from eth2spec.test.context import PHASE0, spec_test, with_phases, single_phase
|
||||
from eth2spec.test.context import PHASE0, ALTAIR, spec_test, with_phases, single_phase, is_post_altair
|
||||
from eth2spec.test.helpers.deposits import (
|
||||
prepare_full_genesis_deposits,
|
||||
prepare_random_genesis_deposits,
|
||||
)
|
||||
|
||||
|
||||
@with_phases(([PHASE0]))
|
||||
def get_post_altair_description(spec):
|
||||
return f"Although it's not phase 0, we may use {spec.fork} spec to start testnets."
|
||||
|
||||
|
||||
@with_phases(([PHASE0, ALTAIR]))
|
||||
@spec_test
|
||||
@single_phase
|
||||
def test_initialize_beacon_state_from_eth1(spec):
|
||||
if is_post_altair(spec):
|
||||
yield 'description', 'meta', get_post_altair_description(spec)
|
||||
|
||||
deposit_count = spec.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT
|
||||
deposits, deposit_root, _ = prepare_full_genesis_deposits(
|
||||
spec,
|
||||
@ -38,10 +45,13 @@ def test_initialize_beacon_state_from_eth1(spec):
|
||||
yield 'state', state
|
||||
|
||||
|
||||
@with_phases([PHASE0])
|
||||
@with_phases([PHASE0, ALTAIR])
|
||||
@spec_test
|
||||
@single_phase
|
||||
def test_initialize_beacon_state_some_small_balances(spec):
|
||||
if is_post_altair(spec):
|
||||
yield 'description', 'meta', get_post_altair_description(spec)
|
||||
|
||||
main_deposit_count = spec.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT
|
||||
main_deposits, _, deposit_data_list = prepare_full_genesis_deposits(
|
||||
spec, spec.MAX_EFFECTIVE_BALANCE,
|
||||
@ -79,10 +89,13 @@ def test_initialize_beacon_state_some_small_balances(spec):
|
||||
yield 'state', state
|
||||
|
||||
|
||||
@with_phases([PHASE0])
|
||||
@with_phases([PHASE0, ALTAIR])
|
||||
@spec_test
|
||||
@single_phase
|
||||
def test_initialize_beacon_state_one_topup_activation(spec):
|
||||
if is_post_altair(spec):
|
||||
yield 'description', 'meta', get_post_altair_description(spec)
|
||||
|
||||
# Submit all but one deposit as MAX_EFFECTIVE_BALANCE
|
||||
main_deposit_count = spec.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT - 1
|
||||
main_deposits, _, deposit_data_list = prepare_full_genesis_deposits(
|
||||
@ -125,10 +138,13 @@ def test_initialize_beacon_state_one_topup_activation(spec):
|
||||
yield 'state', state
|
||||
|
||||
|
||||
@with_phases([PHASE0])
|
||||
@with_phases([PHASE0, ALTAIR])
|
||||
@spec_test
|
||||
@single_phase
|
||||
def test_initialize_beacon_state_random_invalid_genesis(spec):
|
||||
if is_post_altair(spec):
|
||||
yield 'description', 'meta', get_post_altair_description(spec)
|
||||
|
||||
# Make a bunch of random deposits
|
||||
deposits, _, deposit_data_list = prepare_random_genesis_deposits(
|
||||
spec,
|
||||
@ -149,10 +165,13 @@ def test_initialize_beacon_state_random_invalid_genesis(spec):
|
||||
yield 'state', state
|
||||
|
||||
|
||||
@with_phases([PHASE0])
|
||||
@with_phases([PHASE0, ALTAIR])
|
||||
@spec_test
|
||||
@single_phase
|
||||
def test_initialize_beacon_state_random_valid_genesis(spec):
|
||||
if is_post_altair(spec):
|
||||
yield 'description', 'meta', get_post_altair_description(spec)
|
||||
|
||||
# Make a bunch of random deposits
|
||||
random_deposits, _, deposit_data_list = prepare_random_genesis_deposits(
|
||||
spec,
|
||||
|
@ -1,9 +1,13 @@
|
||||
from eth2spec.test.context import PHASE0, spec_test, with_phases, single_phase
|
||||
from eth2spec.test.context import PHASE0, ALTAIR, spec_test, with_phases, single_phase, is_post_altair
|
||||
from eth2spec.test.helpers.deposits import (
|
||||
prepare_full_genesis_deposits,
|
||||
)
|
||||
|
||||
|
||||
def get_post_altair_description(spec):
|
||||
return f"Although it's not phase 0, we may use {spec.fork} spec to start testnets."
|
||||
|
||||
|
||||
def create_valid_beacon_state(spec):
|
||||
deposit_count = spec.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT
|
||||
deposits, _, _ = prepare_full_genesis_deposits(
|
||||
@ -30,39 +34,51 @@ def run_is_valid_genesis_state(spec, state, valid=True):
|
||||
assert is_valid == valid
|
||||
|
||||
|
||||
@with_phases([PHASE0])
|
||||
@with_phases([PHASE0, ALTAIR])
|
||||
@spec_test
|
||||
@single_phase
|
||||
def test_is_valid_genesis_state_true(spec):
|
||||
if is_post_altair(spec):
|
||||
yield 'description', 'meta', get_post_altair_description(spec)
|
||||
|
||||
state = create_valid_beacon_state(spec)
|
||||
|
||||
yield from run_is_valid_genesis_state(spec, state, valid=True)
|
||||
|
||||
|
||||
@with_phases([PHASE0])
|
||||
@with_phases([PHASE0, ALTAIR])
|
||||
@spec_test
|
||||
@single_phase
|
||||
def test_is_valid_genesis_state_false_invalid_timestamp(spec):
|
||||
if is_post_altair(spec):
|
||||
yield 'description', 'meta', get_post_altair_description(spec)
|
||||
|
||||
state = create_valid_beacon_state(spec)
|
||||
state.genesis_time = spec.MIN_GENESIS_TIME - 1
|
||||
|
||||
yield from run_is_valid_genesis_state(spec, state, valid=False)
|
||||
|
||||
|
||||
@with_phases([PHASE0])
|
||||
@with_phases([PHASE0, ALTAIR])
|
||||
@spec_test
|
||||
@single_phase
|
||||
def test_is_valid_genesis_state_true_more_balance(spec):
|
||||
if is_post_altair(spec):
|
||||
yield 'description', 'meta', get_post_altair_description(spec)
|
||||
|
||||
state = create_valid_beacon_state(spec)
|
||||
state.validators[0].effective_balance = spec.MAX_EFFECTIVE_BALANCE + 1
|
||||
|
||||
yield from run_is_valid_genesis_state(spec, state, valid=True)
|
||||
|
||||
|
||||
@with_phases([PHASE0])
|
||||
@with_phases([PHASE0, ALTAIR])
|
||||
@spec_test
|
||||
@single_phase
|
||||
def test_is_valid_genesis_state_true_one_more_validator(spec):
|
||||
if is_post_altair(spec):
|
||||
yield 'description', 'meta', get_post_altair_description(spec)
|
||||
|
||||
deposit_count = spec.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT + 1
|
||||
deposits, _, _ = prepare_full_genesis_deposits(
|
||||
spec,
|
||||
@ -78,10 +94,13 @@ def test_is_valid_genesis_state_true_one_more_validator(spec):
|
||||
yield from run_is_valid_genesis_state(spec, state, valid=True)
|
||||
|
||||
|
||||
@with_phases([PHASE0])
|
||||
@with_phases([PHASE0, ALTAIR])
|
||||
@spec_test
|
||||
@single_phase
|
||||
def test_is_valid_genesis_state_false_not_enough_validator(spec):
|
||||
if is_post_altair(spec):
|
||||
yield 'description', 'meta', get_post_altair_description(spec)
|
||||
|
||||
deposit_count = spec.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT - 1
|
||||
deposits, _, _ = prepare_full_genesis_deposits(
|
||||
spec,
|
||||
|
Loading…
x
Reference in New Issue
Block a user