From 533fdd632a6291e4eaa19e298e2d836ad3b1a565 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Wed, 27 Jan 2016 20:32:53 +0400 Subject: [PATCH] initial --- src/blockchain.rs | 6 ++++++ src/tests/helpers.rs | 7 +++++++ 2 files changed, 13 insertions(+) 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