From a5531e83fd8a6ba1d2c52f71ae3d49474097ce63 Mon Sep 17 00:00:00 2001 From: Guanqun Lu Date: Sat, 10 Jun 2017 00:23:25 +0800 Subject: [PATCH] ArchiveDB: add a new test case --- util/src/journaldb/archivedb.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/util/src/journaldb/archivedb.rs b/util/src/journaldb/archivedb.rs index b86064d8f..9099ff03b 100644 --- a/util/src/journaldb/archivedb.rs +++ b/util/src/journaldb/archivedb.rs @@ -242,6 +242,20 @@ mod tests { assert!(jdb.contains(&h)); } + #[test] + #[should_panic] + fn multiple_owed_removal_not_allowed() { + let mut jdb = ArchiveDB::new_temp(); + let h = jdb.insert(b"foo"); + jdb.commit_batch(0, &b"0".sha3(), None).unwrap(); + assert!(jdb.contains(&h)); + jdb.remove(&h); + jdb.remove(&h); + // commit_batch would call journal_under(), + // and we don't allow multiple owned removals. + jdb.commit_batch(1, &b"1".sha3(), None).unwrap(); + } + #[test] fn complex() { // history is 1