Several changes before I break everything
This commit is contained in:
parent
77b29f4960
commit
becda4f463
|
@ -10,10 +10,9 @@ from tests.phase0.helpers import (
|
|||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
"--config", action="store", default="minimal", help="config: make the p yspec use the specified configuration"
|
||||
"--config", action="store", default="minimal", help="config: make the pyspec use the specified configuration"
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def config(request):
|
||||
config_name = request.config.getoption("--config")
|
||||
|
@ -24,12 +23,10 @@ def config(request):
|
|||
def num_validators(config):
|
||||
return spec.SLOTS_PER_EPOCH * 8
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def deposit_data_leaves():
|
||||
return list()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def state(num_validators, deposit_data_leaves):
|
||||
return create_genesis_state(num_validators, deposit_data_leaves)
|
||||
|
|
|
@ -61,14 +61,14 @@ def test_reveal_from_current_epoch(state):
|
|||
|
||||
return pre_state, randao_key_reveal, post_state
|
||||
|
||||
# Not currently possible as we are testing at epoch 0
|
||||
#
|
||||
#def test_reveal_from_past_epoch(state):
|
||||
# randao_key_reveal = get_valid_early_derived_secret_reveal(state, get_current_epoch(state) - 1)
|
||||
#
|
||||
# pre_state, post_state = run_early_derived_secret_reveal_processing(state, randao_key_reveal, False)
|
||||
#
|
||||
# return pre_state, randao_key_reveal, post_state
|
||||
|
||||
@pytest.mark.skip(reason="Not currently possible as we are testing at epoch 0")
|
||||
def test_reveal_from_past_epoch(state):
|
||||
randao_key_reveal = get_valid_early_derived_secret_reveal(state, get_current_epoch(state) - 1)
|
||||
|
||||
pre_state, post_state = run_early_derived_secret_reveal_processing(state, randao_key_reveal, False)
|
||||
|
||||
return pre_state, randao_key_reveal, post_state
|
||||
|
||||
def test_reveal_with_custody_padding(state):
|
||||
randao_key_reveal = get_valid_early_derived_secret_reveal(state, get_current_epoch(state) + CUSTODY_PERIOD_TO_RANDAO_PADDING)
|
||||
|
@ -88,7 +88,7 @@ def test_double_reveal(state):
|
|||
pre_state, intermediate_state = run_early_derived_secret_reveal_processing(state, randao_key_reveal1)
|
||||
|
||||
randao_key_reveal2 = get_valid_early_derived_secret_reveal(intermediate_state, get_current_epoch(pre_state) + RANDAO_PENALTY_EPOCHS + 1)
|
||||
intermediate_state_, post_state = run_early_derived_secret_reveal_processing(intermediate_state, randao_key_reveal2, False)
|
||||
_, post_state = run_early_derived_secret_reveal_processing(intermediate_state, randao_key_reveal2, False)
|
||||
|
||||
return pre_state, [randao_key_reveal1, randao_key_reveal2], post_state
|
||||
|
||||
|
|
|
@ -1,9 +1,26 @@
|
|||
import pytest
|
||||
|
||||
from eth2spec.phase1 import spec
|
||||
from preset_loader import loader
|
||||
|
||||
from tests.phase0.helpers import (
|
||||
create_genesis_state,
|
||||
)
|
||||
|
||||
from tests.phase0.conftest import (
|
||||
pytest_addoption,
|
||||
config,
|
||||
num_validators,
|
||||
deposit_data_leaves,
|
||||
state,
|
||||
)
|
||||
|
||||
# This is redfined so that the constants are re-applied
|
||||
@pytest.fixture(autouse=True)
|
||||
def config(request):
|
||||
config_name = request.config.getoption("--config")
|
||||
presets = loader.load_presets('../../configs/', config_name)
|
||||
spec.apply_constants_preset(presets)
|
||||
|
||||
#This is redefined so that the BeaconState is the new SSZ Object
|
||||
@pytest.fixture
|
||||
def state(num_validators, deposit_data_leaves):
|
||||
return create_genesis_state(num_validators, deposit_data_leaves)
|
||||
|
|
|
@ -15,7 +15,18 @@ from eth2spec.phase1.spec import (
|
|||
)
|
||||
|
||||
from tests.phase0.helpers import (
|
||||
advance_slot,
|
||||
get_balance,
|
||||
build_deposit_data,
|
||||
build_empty_block_for_next_slot,
|
||||
fill_aggregate_attestation,
|
||||
get_state_root,
|
||||
get_valid_attestation,
|
||||
get_valid_attester_slashing,
|
||||
get_valid_proposer_slashing,
|
||||
next_slot,
|
||||
privkeys,
|
||||
pubkeys,
|
||||
)
|
||||
|
||||
def get_valid_early_derived_secret_reveal(state, epoch=None):
|
||||
|
|
|
@ -17,9 +17,6 @@ from tests.phase0.helpers import (
|
|||
next_epoch,
|
||||
)
|
||||
|
||||
# mark entire file as 'state'
|
||||
# pytestmark = pytest.mark.state
|
||||
|
||||
from tests.phase0.test_finality import (
|
||||
pytestmark,
|
||||
check_finality,
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
from copy import deepcopy
|
||||
|
||||
import pytest
|
||||
|
||||
from py_ecc import bls
|
||||
import eth2spec.phase1.spec as spec
|
||||
|
||||
from eth2spec.utils.minimal_ssz import signing_root
|
||||
from eth2spec.phase1.spec import (
|
||||
# constants
|
||||
ZERO_HASH,
|
||||
SLOTS_PER_HISTORICAL_ROOT,
|
||||
# SSZ
|
||||
Deposit,
|
||||
Transfer,
|
||||
VoluntaryExit,
|
||||
# functions
|
||||
get_active_validator_indices,
|
||||
get_beacon_proposer_index,
|
||||
get_block_root_at_slot,
|
||||
get_current_epoch,
|
||||
get_domain,
|
||||
process_slot,
|
||||
verify_merkle_branch,
|
||||
state_transition,
|
||||
hash,
|
||||
)
|
||||
from eth2spec.utils.merkle_minimal import (
|
||||
calc_merkle_tree_from_leaves,
|
||||
get_merkle_proof,
|
||||
get_merkle_root,
|
||||
)
|
||||
from .helpers import (
|
||||
advance_slot,
|
||||
get_balance,
|
||||
build_deposit_data,
|
||||
build_empty_block_for_next_slot,
|
||||
fill_aggregate_attestation,
|
||||
get_state_root,
|
||||
get_valid_attestation,
|
||||
get_valid_attester_slashing,
|
||||
get_valid_proposer_slashing,
|
||||
next_slot,
|
||||
privkeys,
|
||||
pubkeys,
|
||||
)
|
||||
|
||||
|
||||
# mark entire file as 'sanity'
|
||||
pytestmark = pytest.mark.sanity
|
||||
|
||||
from tests.phase0.test_sanity import (
|
||||
test_slot_transition,
|
||||
test_empty_block_transition,
|
||||
test_skipped_slots,
|
||||
test_empty_epoch_transition,
|
||||
test_empty_epoch_transition_not_finalizing,
|
||||
test_proposer_slashing,
|
||||
test_attester_slashing,
|
||||
test_deposit_in_block,
|
||||
test_deposit_top_up,
|
||||
test_attestation,
|
||||
test_voluntary_exit,
|
||||
test_transfer,
|
||||
test_balance_driven_status_transitions,
|
||||
test_historical_batch,
|
||||
test_eth1_data_votes,
|
||||
)
|
Loading…
Reference in New Issue