From 7f21b94b973e68e7304315f3252f7239a0b632d5 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Thu, 28 Jan 2016 22:43:57 +0400 Subject: [PATCH] extra queue tests --- src/block_queue.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/block_queue.rs b/src/block_queue.rs index 08e22f799..206388042 100644 --- a/src/block_queue.rs +++ b/src/block_queue.rs @@ -310,7 +310,7 @@ mod tests { } #[test] - fn can_verify_blocks() { + fn can_import_blocks() { let mut queue = get_test_queue(); if let Err(e) = queue.import_block(get_good_dummy_block()) { panic!("error importing block that is valid by definition({:?})", e); @@ -323,8 +323,29 @@ mod tests { if let Err(e) = queue.import_block(get_good_dummy_block()) { panic!("error importing block that is valid by definition({:?})", e); } - let duplicate_import = queue.import_block(get_good_dummy_block()); + let duplicate_import = queue.import_block(get_good_dummy_block()); + match duplicate_import { + Err(e) => { + match e { + ImportError::AlreadyQueued => {}, + _ => { panic!("must return AlreadyQueued error"); } + } + } + Ok(_) => { panic!("must produce error"); } + } + } + + #[test] + fn returns_error_for_verified_duplicates() { + let mut queue = get_test_queue(); + if let Err(e) = queue.import_block(get_good_dummy_block()) { + panic!("error importing block that is valid by definition({:?})", e); + } + queue.drain(10); + queue.flush(); + + let duplicate_import = queue.import_block(get_good_dummy_block()); match duplicate_import { Err(e) => { match e {