From 24ad42663fd05fd9a09667ae74395feafae8dc37 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Fri, 21 Jun 2019 22:02:03 -0600 Subject: [PATCH] `spectest_with_bls_switch` decorator --- test_libs/pyspec/eth2spec/test/context.py | 6 +++++- .../eth2spec/test/sanity/test_genesis.py | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/test_libs/pyspec/eth2spec/test/context.py b/test_libs/pyspec/eth2spec/test/context.py index 97266acf2..e7560afc6 100644 --- a/test_libs/pyspec/eth2spec/test/context.py +++ b/test_libs/pyspec/eth2spec/test/context.py @@ -27,9 +27,13 @@ def with_state(fn): DEFAULT_BLS_ACTIVE = False +def spectest_with_bls_switch(fn): + return bls_switch(spectest()(fn)) + + # shorthand for decorating @with_state @spectest() 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): diff --git a/test_libs/pyspec/eth2spec/test/sanity/test_genesis.py b/test_libs/pyspec/eth2spec/test/sanity/test_genesis.py index 7e5fd5db4..3c76654e6 100644 --- a/test_libs/pyspec/eth2spec/test/sanity/test_genesis.py +++ b/test_libs/pyspec/eth2spec/test/sanity/test_genesis.py @@ -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 ( prepare_genesis_deposits, ) @with_phases(['phase0']) -@spec_state_test -def test_is_genesis_trigger_false(spec, state): +@spectest_with_bls_switch +def test_is_genesis_trigger_false(spec): deposit_count = 2 genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE) genesis_time = 1234 @@ -18,8 +18,8 @@ def test_is_genesis_trigger_false(spec, state): @with_phases(['phase0']) -@spec_state_test -def test_is_genesis_trigger_true(spec, state): +@spectest_with_bls_switch +def test_is_genesis_trigger_true(spec): deposit_count = spec.GENESIS_ACTIVE_VALIDATOR_COUNT genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE) genesis_time = 1234 @@ -29,9 +29,10 @@ def test_is_genesis_trigger_true(spec, state): yield is_triggered + @with_phases(['phase0']) -@spec_state_test -def test_is_genesis_trigger_not_enough_balance(spec, state): +@spectest_with_bls_switch +def test_is_genesis_trigger_not_enough_balance(spec): deposit_count = spec.GENESIS_ACTIVE_VALIDATOR_COUNT genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE - 1) genesis_time = 1234 @@ -45,8 +46,8 @@ def test_is_genesis_trigger_not_enough_balance(spec, state): @with_phases(['phase0']) -@spec_state_test -def test_genesis(spec, state): +@spectest_with_bls_switch +def test_genesis(spec): deposit_count = spec.GENESIS_ACTIVE_VALIDATOR_COUNT genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE) genesis_time = 1234