eth2.0-specs/test_libs/pyspec/eth2spec/test/helpers/attester_slashings.py

20 lines
648 B
Python
Raw Normal View History

2019-05-15 16:36:32 +00:00
from copy import deepcopy
from eth2spec.phase0.spec import AttesterSlashing, convert_to_indexed
2019-05-15 17:31:02 +00:00
from eth2spec.test.helpers.attestations import get_valid_attestation, sign_attestation
2019-05-15 16:36:32 +00:00
2019-05-15 17:53:35 +00:00
def get_valid_attester_slashing(state, signed_1=False, signed_2=False):
attestation_1 = get_valid_attestation(state, signed=signed_1)
2019-05-15 16:36:32 +00:00
attestation_2 = deepcopy(attestation_1)
attestation_2.data.target_root = b'\x01' * 32
2019-05-15 17:53:35 +00:00
if signed_2:
sign_attestation(state, attestation_2)
2019-05-15 16:36:32 +00:00
return AttesterSlashing(
attestation_1=convert_to_indexed(state, attestation_1),
attestation_2=convert_to_indexed(state, attestation_2),
)