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

29 lines
790 B
Rust
Raw Normal View History

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 validator_count = 2;
2019-01-28 05:21:33 +00:00
let mut harness = BeaconChainHarness::new(ChainSpec::foundation(), validator_count);
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() {
let validator_count = 100;
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
2019-01-28 05:21:33 +00:00
let blocks = harness.spec.epoch_length + 1;
2019-01-26 11:22:52 +00:00
2019-01-25 05:47:24 +00:00
for _ in 0..blocks {
2019-01-28 05:21:33 +00:00
harness.advance_chain_with_block();
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
}