diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 40cbd496b..b918c960d 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -1016,4 +1016,22 @@ impl ChainSync { #[cfg(test)] mod tests { + use tests::helpers::*; + use super::*; + use util::*; + + #[test] + fn return_receipts() { + let mut client = TestBlockChainClient::new(); + let mut queue:VecDeque = VecDeque::new(); + let mut io = TestIo::new(& mut client, & mut queue, None); + + let sync = ChainSync::new(); + let data = vec![0xc0]; + let rlp = UntrustedRlp::new(&data); + + let result = sync.return_receipts(& mut io, &rlp); + + assert!(result.is_ok()); + } } \ No newline at end of file diff --git a/sync/src/tests/chain.rs b/sync/src/tests/chain.rs index 083a9bd33..fcd9b6a7b 100644 --- a/sync/src/tests/chain.rs +++ b/sync/src/tests/chain.rs @@ -5,7 +5,7 @@ use chain::{SyncState}; use super::helpers::*; #[test] -fn chain_two_peers() { +fn two_peers() { ::env_logger::init().ok(); let mut net = TestNet::new(3); net.peer_mut(1).chain.add_blocks(1000, false); @@ -16,7 +16,7 @@ fn chain_two_peers() { } #[test] -fn chain_status_after_sync() { +fn status_after_sync() { ::env_logger::init().ok(); let mut net = TestNet::new(3); net.peer_mut(1).chain.add_blocks(1000, false); @@ -27,7 +27,7 @@ fn chain_status_after_sync() { } #[test] -fn chain_takes_few_steps() { +fn takes_few_steps() { let mut net = TestNet::new(3); net.peer_mut(1).chain.add_blocks(100, false); net.peer_mut(2).chain.add_blocks(100, false); @@ -36,7 +36,7 @@ fn chain_takes_few_steps() { } #[test] -fn chain_empty_blocks() { +fn empty_blocks() { ::env_logger::init().ok(); let mut net = TestNet::new(3); for n in 0..200 { @@ -49,7 +49,7 @@ fn chain_empty_blocks() { } #[test] -fn chain_forked() { +fn forked() { ::env_logger::init().ok(); let mut net = TestNet::new(3); net.peer_mut(0).chain.add_blocks(300, false); @@ -69,7 +69,7 @@ fn chain_forked() { } #[test] -fn chain_restart() { +fn restart() { let mut net = TestNet::new(3); net.peer_mut(1).chain.add_blocks(1000, false); net.peer_mut(2).chain.add_blocks(1000, false); @@ -85,7 +85,7 @@ fn chain_restart() { } #[test] -fn chain_status_empty() { +fn status_empty() { let net = TestNet::new(2); assert_eq!(net.peer(0).sync.status().state, SyncState::NotSynced); } \ No newline at end of file diff --git a/sync/src/tests/helpers.rs b/sync/src/tests/helpers.rs index 7fdd695fb..405d1e5c1 100644 --- a/sync/src/tests/helpers.rs +++ b/sync/src/tests/helpers.rs @@ -15,7 +15,7 @@ pub struct TestBlockChainClient { } impl TestBlockChainClient { - fn new() -> TestBlockChainClient { + pub fn new() -> TestBlockChainClient { let mut client = TestBlockChainClient { blocks: RwLock::new(HashMap::new()), @@ -196,7 +196,7 @@ pub struct TestIo<'p> { } impl<'p> TestIo<'p> { - fn new(chain: &'p mut TestBlockChainClient, queue: &'p mut VecDeque, sender: Option) -> TestIo<'p> { + pub fn new(chain: &'p mut TestBlockChainClient, queue: &'p mut VecDeque, sender: Option) -> TestIo<'p> { TestIo { chain: chain, queue: queue,