mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-20 07:29:02 +00:00
bugfix block proc transfer test
This commit is contained in:
parent
90bcbd6ff4
commit
b0aea2a111
@ -28,6 +28,17 @@ def expect_assertion_error(fn):
|
|||||||
raise AssertionError('expected an assertion error, but got none.')
|
raise AssertionError('expected an assertion error, but got none.')
|
||||||
|
|
||||||
|
|
||||||
|
def never_bls(fn):
|
||||||
|
"""
|
||||||
|
Decorator to apply on ``bls_switch`` decorator to force BLS de-activation. Useful to mark tests as BLS-ignorant.
|
||||||
|
"""
|
||||||
|
def entry(*args, **kw):
|
||||||
|
# override bls setting
|
||||||
|
kw['bls_active'] = False
|
||||||
|
fn(*args, **kw)
|
||||||
|
return entry
|
||||||
|
|
||||||
|
|
||||||
def always_bls(fn):
|
def always_bls(fn):
|
||||||
"""
|
"""
|
||||||
Decorator to apply on ``bls_switch`` decorator to force BLS activation. Useful to mark tests as BLS-dependent.
|
Decorator to apply on ``bls_switch`` decorator to force BLS activation. Useful to mark tests as BLS-dependent.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Access constants from spec pkg reference.
|
# Access constants from spec pkg reference.
|
||||||
import eth2spec.phase0.spec as spec
|
import eth2spec.phase0.spec as spec
|
||||||
|
|
||||||
from eth2spec.phase0.spec import get_current_epoch, get_active_validator_indices, Transfer, ZERO_HASH, get_domain
|
from eth2spec.phase0.spec import get_current_epoch, get_active_validator_indices, Transfer, get_domain
|
||||||
from eth2spec.test.helpers.keys import pubkeys, privkeys
|
from eth2spec.test.helpers.keys import pubkeys, privkeys
|
||||||
from eth2spec.test.helpers.state import get_balance
|
from eth2spec.test.helpers.state import get_balance
|
||||||
from eth2spec.utils.bls import bls_sign
|
from eth2spec.utils.bls import bls_sign
|
||||||
@ -30,7 +30,6 @@ def get_valid_transfer(state, slot=None, sender_index=None, amount=None, fee=Non
|
|||||||
fee=fee,
|
fee=fee,
|
||||||
slot=slot,
|
slot=slot,
|
||||||
pubkey=transfer_pubkey,
|
pubkey=transfer_pubkey,
|
||||||
signature=ZERO_HASH,
|
|
||||||
)
|
)
|
||||||
if signed:
|
if signed:
|
||||||
sign_transfer(state, transfer, transfer_privkey)
|
sign_transfer(state, transfer, transfer_privkey)
|
||||||
|
@ -4,11 +4,10 @@ import eth2spec.phase0.spec as spec
|
|||||||
from eth2spec.phase0.state_transition import (
|
from eth2spec.phase0.state_transition import (
|
||||||
state_transition,
|
state_transition,
|
||||||
)
|
)
|
||||||
from .context import spec_state_test
|
from .context import spec_state_test, never_bls
|
||||||
from .helpers.state import next_epoch
|
from .helpers.state import next_epoch
|
||||||
from .helpers.block import build_empty_block_for_next_slot, apply_empty_block
|
from .helpers.block import build_empty_block_for_next_slot, apply_empty_block
|
||||||
from .helpers.attestations import (
|
from .helpers.attestations import (
|
||||||
fill_aggregate_attestation,
|
|
||||||
get_current_epoch,
|
get_current_epoch,
|
||||||
get_epoch_start_slot,
|
get_epoch_start_slot,
|
||||||
get_valid_attestation,
|
get_valid_attestation,
|
||||||
@ -66,6 +65,7 @@ def next_epoch_with_attestations(state,
|
|||||||
return state, blocks, post_state
|
return state, blocks, post_state
|
||||||
|
|
||||||
|
|
||||||
|
@never_bls
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_finality_rule_4(state):
|
def test_finality_rule_4(state):
|
||||||
yield 'pre', state
|
yield 'pre', state
|
||||||
@ -93,6 +93,7 @@ def test_finality_rule_4(state):
|
|||||||
yield 'post', state
|
yield 'post', state
|
||||||
|
|
||||||
|
|
||||||
|
@never_bls
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_finality_rule_1(state):
|
def test_finality_rule_1(state):
|
||||||
# get past first two epochs that finality does not run on
|
# get past first two epochs that finality does not run on
|
||||||
@ -122,6 +123,7 @@ def test_finality_rule_1(state):
|
|||||||
yield 'post', state
|
yield 'post', state
|
||||||
|
|
||||||
|
|
||||||
|
@never_bls
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_finality_rule_2(state):
|
def test_finality_rule_2(state):
|
||||||
# get past first two epochs that finality does not run on
|
# get past first two epochs that finality does not run on
|
||||||
@ -153,6 +155,7 @@ def test_finality_rule_2(state):
|
|||||||
yield 'post', state
|
yield 'post', state
|
||||||
|
|
||||||
|
|
||||||
|
@never_bls
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_finality_rule_3(state):
|
def test_finality_rule_3(state):
|
||||||
"""
|
"""
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
from py_ecc import bls
|
|
||||||
import eth2spec.phase0.spec as spec
|
import eth2spec.phase0.spec as spec
|
||||||
|
from eth2spec.utils.bls import bls_sign
|
||||||
|
|
||||||
from eth2spec.utils.minimal_ssz import signing_root
|
from eth2spec.utils.minimal_ssz import signing_root
|
||||||
from eth2spec.phase0.spec import (
|
from eth2spec.phase0.spec import (
|
||||||
@ -24,7 +24,7 @@ from .helpers.state import (
|
|||||||
get_state_root
|
get_state_root
|
||||||
)
|
)
|
||||||
from .helpers.transfers import get_valid_transfer
|
from .helpers.transfers import get_valid_transfer
|
||||||
from .helpers.block import build_empty_block_for_next_slot
|
from .helpers.block import build_empty_block_for_next_slot, sign_block
|
||||||
from .helpers.keys import (
|
from .helpers.keys import (
|
||||||
privkeys,
|
privkeys,
|
||||||
pubkeys,
|
pubkeys,
|
||||||
@ -58,7 +58,7 @@ def test_empty_block_transition(state):
|
|||||||
|
|
||||||
yield 'pre', state
|
yield 'pre', state
|
||||||
|
|
||||||
block = build_empty_block_for_next_slot(state)
|
block = build_empty_block_for_next_slot(state, signed=True)
|
||||||
yield 'blocks', [block], [spec.BeaconBlock]
|
yield 'blocks', [block], [spec.BeaconBlock]
|
||||||
|
|
||||||
state_transition(state, block)
|
state_transition(state, block)
|
||||||
@ -73,8 +73,9 @@ def test_skipped_slots(state):
|
|||||||
pre_slot = state.slot
|
pre_slot = state.slot
|
||||||
yield 'pre', state
|
yield 'pre', state
|
||||||
|
|
||||||
block = build_empty_block_for_next_slot(state)
|
block = build_empty_block_for_next_slot(state, signed=False)
|
||||||
block.slot += 3
|
block.slot += 3
|
||||||
|
sign_block(state, block)
|
||||||
yield 'blocks', [block], [spec.BeaconBlock]
|
yield 'blocks', [block], [spec.BeaconBlock]
|
||||||
|
|
||||||
state_transition(state, block)
|
state_transition(state, block)
|
||||||
@ -90,8 +91,9 @@ def test_empty_epoch_transition(state):
|
|||||||
pre_slot = state.slot
|
pre_slot = state.slot
|
||||||
yield 'pre', state
|
yield 'pre', state
|
||||||
|
|
||||||
block = build_empty_block_for_next_slot(state)
|
block = build_empty_block_for_next_slot(state, signed=False)
|
||||||
block.slot += spec.SLOTS_PER_EPOCH
|
block.slot += spec.SLOTS_PER_EPOCH
|
||||||
|
sign_block(state, block)
|
||||||
yield 'blocks', [block], [spec.BeaconBlock]
|
yield 'blocks', [block], [spec.BeaconBlock]
|
||||||
|
|
||||||
state_transition(state, block)
|
state_transition(state, block)
|
||||||
@ -289,7 +291,7 @@ def test_voluntary_exit(state):
|
|||||||
epoch=get_current_epoch(state),
|
epoch=get_current_epoch(state),
|
||||||
validator_index=validator_index,
|
validator_index=validator_index,
|
||||||
)
|
)
|
||||||
voluntary_exit.signature = bls.sign(
|
voluntary_exit.signature = bls_sign(
|
||||||
message_hash=signing_root(voluntary_exit),
|
message_hash=signing_root(voluntary_exit),
|
||||||
privkey=privkeys[validator_index],
|
privkey=privkeys[validator_index],
|
||||||
domain=get_domain(
|
domain=get_domain(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user