Update testing builders as per state 0.5.0 update

This commit is contained in:
Paul Hauner 2019-03-16 14:31:43 +11:00
parent 01bfd38637
commit 6ae5d34d0f
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
4 changed files with 12 additions and 7 deletions

View File

@ -20,7 +20,7 @@ impl TestingAttestationDataBuilder {
let source_epoch = if is_previous_epoch {
state.previous_justified_epoch
} else {
state.justified_epoch
state.current_justified_epoch
};
let target_root = if is_previous_epoch {

View File

@ -19,7 +19,7 @@ impl TestingBeaconBlockBuilder {
/// Create a new builder from genesis.
pub fn new(spec: &ChainSpec) -> Self {
Self {
block: BeaconBlock::genesis(spec.zero_hash, spec),
block: BeaconBlock::empty(spec),
}
}
@ -34,7 +34,7 @@ impl TestingBeaconBlockBuilder {
pub fn sign(&mut self, sk: &SecretKey, fork: &Fork, spec: &ChainSpec) {
let message = self.block.signed_root();
let epoch = self.block.slot.epoch(spec.slots_per_epoch);
let domain = spec.get_domain(epoch, Domain::Proposal, fork);
let domain = spec.get_domain(epoch, Domain::BeaconBlock, fork);
self.block.signature = Signature::new(&message, domain, sk);
}

View File

@ -190,7 +190,7 @@ impl TestingBeaconStateBuilder {
state.current_shuffling_seed = Hash256::from_low_u64_le(1);
state.previous_justified_epoch = epoch - 3;
state.justified_epoch = epoch - 2;
state.current_justified_epoch = epoch - 2;
state.justification_bitfield = u64::max_value();
state.finalized_epoch = epoch - 3;
@ -232,8 +232,13 @@ impl TestingBeaconStateBuilder {
// The entire committee should have signed the pending attestation.
let signers = vec![true; committee.len()];
builder.add_committee_participation(signers);
let attestation = builder.build();
state.latest_attestations.push(builder.build())
if attestation.data.slot.epoch(spec.slots_per_epoch) < state.current_epoch(spec) {
state.previous_epoch_attestations.push(attestation)
} else {
state.current_epoch_attestations.push(attestation)
}
}
}
}

View File

@ -41,13 +41,13 @@ impl TestingProposerSlashingBuilder {
proposal_1.signature = {
let message = proposal_1.signed_root();
let epoch = slot.epoch(spec.slots_per_epoch);
signer(proposer_index, &message[..], epoch, Domain::Proposal)
signer(proposer_index, &message[..], epoch, Domain::BeaconBlock)
};
proposal_2.signature = {
let message = proposal_2.signed_root();
let epoch = slot.epoch(spec.slots_per_epoch);
signer(proposer_index, &message[..], epoch, Domain::Proposal)
signer(proposer_index, &message[..], epoch, Domain::BeaconBlock)
};
ProposerSlashing {