Fix failing tests

This commit is contained in:
Paul Hauner
2019-01-26 22:22:52 +11:00
parent 7ee836d118
commit 22a08e5160
4 changed files with 23 additions and 14 deletions

View File

@@ -240,11 +240,7 @@ where
ensure!(
attestation.data.justified_block_root
== *state
.get_block_root(
&state,
attestation.data.justified_slot,
self.spec.latest_block_roots_length
)
.get_block_root(attestation.data.justified_slot, &self.spec)
.ok_or(Error::NoBlockRoot)?,
Error::BadAttestation
);
@@ -364,6 +360,10 @@ where
Error::BadCustodyResponses
);
if state.slot % self.spec.epoch_length == 0 {
state.per_epoch_processing(&self.spec);
}
Ok(state)
}
}

View File

@@ -4,17 +4,19 @@ use types::ChainSpec;
mod utils;
#[test]
#[ignore]
fn it_can_produce_blocks() {
let validator_count = 2;
let blocks = 3;
let mut rig = TestRig::new(ChainSpec::foundation(), validator_count);
let blocks = rig.spec.epoch_length + 1;
for _ in 0..blocks {
rig.produce_next_slot();
}
let dump = rig.chain_dump().expect("Chain dump failed.");
assert_eq!(dump.len(), blocks + 1); // + 1 for genesis block.
assert_eq!(dump.len() as u64, blocks + 1); // + 1 for genesis block.
rig.dump_to_file("/tmp/chaindump.json".to_string(), &dump);
}

View File

@@ -19,6 +19,7 @@ pub struct TestRig {
block_store: Arc<BeaconBlockStore<MemoryDB>>,
state_store: Arc<BeaconStateStore<MemoryDB>>,
validators: Vec<TestValidator>,
pub spec: ChainSpec,
}
impl TestRig {
@@ -50,8 +51,13 @@ impl TestRig {
// Create the Beacon Chain
let beacon_chain = Arc::new(
BeaconChain::genesis(state_store.clone(), block_store.clone(), slot_clock, spec)
.unwrap(),
BeaconChain::genesis(
state_store.clone(),
block_store.clone(),
slot_clock,
spec.clone(),
)
.unwrap(),
);
// Spawn the test validator instances.
@@ -66,6 +72,7 @@ impl TestRig {
block_store,
state_store,
validators,
spec,
}
}