lighthouse/beacon_node/beacon_chain/test_harness/tests/chain.rs

47 lines
1.2 KiB
Rust
Raw Normal View History

use env_logger::{Builder, Env};
use log::debug;
use test_harness::BeaconChainHarness;
2019-01-25 05:47:24 +00:00
use types::ChainSpec;
2019-01-27 03:22:51 +00:00
#[test]
fn it_can_build_on_genesis_block() {
let mut spec = ChainSpec::foundation();
spec.genesis_slot = spec.epoch_length * 8;
/*
spec.shard_count = spec.shard_count / 8;
spec.target_committee_size = spec.target_committee_size / 8;
*/
let validator_count = 1000;
let mut harness = BeaconChainHarness::new(spec, validator_count as usize);
2019-01-27 03:22:51 +00:00
2019-01-28 05:21:33 +00:00
harness.advance_chain_with_block();
2019-01-27 03:22:51 +00:00
}
2018-12-30 01:59:24 +00:00
#[test]
2019-01-26 11:22:52 +00:00
#[ignore]
2019-01-27 03:22:51 +00:00
fn it_can_produce_past_first_epoch_boundary() {
Builder::from_env(Env::default().default_filter_or("debug")).init();
2019-02-01 04:39:30 +00:00
let validator_count = 100;
debug!("Starting harness build...");
2019-01-28 05:21:33 +00:00
let mut harness = BeaconChainHarness::new(ChainSpec::foundation(), validator_count);
2019-01-26 11:22:52 +00:00
debug!("Harness built, tests starting..");
let blocks = harness.spec.epoch_length * 3 + 1;
2019-01-26 11:22:52 +00:00
for i in 0..blocks {
2019-01-28 05:21:33 +00:00
harness.advance_chain_with_block();
debug!("Produced block {}/{}.", i, blocks);
2019-01-25 05:47:24 +00:00
}
2019-01-28 05:21:33 +00:00
let dump = harness.chain_dump().expect("Chain dump failed.");
2019-01-25 20:20:58 +00:00
2019-01-26 11:22:52 +00:00
assert_eq!(dump.len() as u64, blocks + 1); // + 1 for genesis block.
2019-01-25 21:25:56 +00:00
2019-01-28 05:21:33 +00:00
harness.dump_to_file("/tmp/chaindump.json".to_string(), &dump);
2018-12-30 01:59:24 +00:00
}