`spectest_with_bls_switch` decorator

This commit is contained in:
Hsiao-Wei Wang 2019-06-21 22:02:03 -06:00
parent 7468fd034f
commit 24ad42663f
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
2 changed files with 15 additions and 10 deletions

View File

@ -27,9 +27,13 @@ def with_state(fn):
DEFAULT_BLS_ACTIVE = False DEFAULT_BLS_ACTIVE = False
def spectest_with_bls_switch(fn):
return bls_switch(spectest()(fn))
# shorthand for decorating @with_state @spectest() # shorthand for decorating @with_state @spectest()
def spec_state_test(fn): def spec_state_test(fn):
return with_state(bls_switch(spectest()(fn))) return with_state(spectest_with_bls_switch(fn))
def expect_assertion_error(fn): def expect_assertion_error(fn):

View File

@ -1,12 +1,12 @@
from eth2spec.test.context import spec_state_test, with_phases from eth2spec.test.context import with_phases, spectest_with_bls_switch
from eth2spec.test.helpers.deposits import ( from eth2spec.test.helpers.deposits import (
prepare_genesis_deposits, prepare_genesis_deposits,
) )
@with_phases(['phase0']) @with_phases(['phase0'])
@spec_state_test @spectest_with_bls_switch
def test_is_genesis_trigger_false(spec, state): def test_is_genesis_trigger_false(spec):
deposit_count = 2 deposit_count = 2
genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE) genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE)
genesis_time = 1234 genesis_time = 1234
@ -18,8 +18,8 @@ def test_is_genesis_trigger_false(spec, state):
@with_phases(['phase0']) @with_phases(['phase0'])
@spec_state_test @spectest_with_bls_switch
def test_is_genesis_trigger_true(spec, state): def test_is_genesis_trigger_true(spec):
deposit_count = spec.GENESIS_ACTIVE_VALIDATOR_COUNT deposit_count = spec.GENESIS_ACTIVE_VALIDATOR_COUNT
genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE) genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE)
genesis_time = 1234 genesis_time = 1234
@ -29,9 +29,10 @@ def test_is_genesis_trigger_true(spec, state):
yield is_triggered yield is_triggered
@with_phases(['phase0']) @with_phases(['phase0'])
@spec_state_test @spectest_with_bls_switch
def test_is_genesis_trigger_not_enough_balance(spec, state): def test_is_genesis_trigger_not_enough_balance(spec):
deposit_count = spec.GENESIS_ACTIVE_VALIDATOR_COUNT deposit_count = spec.GENESIS_ACTIVE_VALIDATOR_COUNT
genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE - 1) genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE - 1)
genesis_time = 1234 genesis_time = 1234
@ -45,8 +46,8 @@ def test_is_genesis_trigger_not_enough_balance(spec, state):
@with_phases(['phase0']) @with_phases(['phase0'])
@spec_state_test @spectest_with_bls_switch
def test_genesis(spec, state): def test_genesis(spec):
deposit_count = spec.GENESIS_ACTIVE_VALIDATOR_COUNT deposit_count = spec.GENESIS_ACTIVE_VALIDATOR_COUNT
genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE) genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE)
genesis_time = 1234 genesis_time = 1234