diff --git a/src/blockchain.rs b/src/blockchain.rs index fb3755ff2..7323de827 100644 --- a/src/blockchain.rs +++ b/src/blockchain.rs @@ -769,4 +769,10 @@ mod tests { assert_eq!(bc.best_block_hash(), b1_hash); } } + + #[test] + fn can_consist_of_random_blocks() { + let bc = generate_dummy_blockchain(100); + assert_eq!(bc.best_block_hash(), 0); + } } diff --git a/src/tests/helpers.rs b/src/tests/helpers.rs index a566392cc..38aaafe5f 100644 --- a/src/tests/helpers.rs +++ b/src/tests/helpers.rs @@ -4,6 +4,7 @@ use super::test_common::*; use std::path::PathBuf; use spec::*; use std::fs::{remove_dir_all}; +use blockchain:{BlockChain}; pub struct RandomTempPath { @@ -77,4 +78,10 @@ pub fn generate_dummy_client(block_number: usize) -> Arc { client.flush_queue(); client.import_verified_blocks(&IoChannel::disconnected()); client +} + +pub fn generate_dummy_blockchain(block_number: usize) -> BlockChain { + let temp = RandomTempPath::new(); + let bc = BlockChain::new(&("fffffff".from_hex().unwrap()), temp.as_path()); + bc } \ No newline at end of file