This commit is contained in:
Nikolay Volf 2016-01-27 20:32:53 +04:00
parent ec42dd6b28
commit 533fdd632a
2 changed files with 13 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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> {
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
}