From e18df12b5ee592cef8862aef5c8c756d7147950c Mon Sep 17 00:00:00 2001 From: clemahieu Date: Tue, 25 Nov 2014 17:21:06 -0600 Subject: [PATCH] Adding test to make sure iterators can be incremented after deleting current key. --- rai/core_test/block_store.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/rai/core_test/block_store.cpp b/rai/core_test/block_store.cpp index c00b4912..0bd05968 100644 --- a/rai/core_test/block_store.cpp +++ b/rai/core_test/block_store.cpp @@ -195,4 +195,24 @@ TEST (checksum, simple) store.checksum_del (0x100, 0x10); rai::block_hash hash3; ASSERT_TRUE (store.checksum_get (0x100, 0x10, hash3)); +} + +TEST (block_store, delete_iterator_entry) +{ + leveldb::Status init; + rai::block_store store (init, rai::block_store_temp); + ASSERT_TRUE (init.ok ()); + rai::send_block block1; + block1.hashables.previous = 1; + store.block_put (block1.hash (), block1); + rai::send_block block2; + block2.hashables.previous = 2; + store.block_put (block2.hash (), block2); + auto current (store.blocks_begin ()); + ASSERT_NE (store.blocks_end (), current); + store.block_del (current->first); + ++current; + ASSERT_NE (store.blocks_end (), current); + store.block_del (current->first); + ASSERT_EQ (store.blocks_end (), current); } \ No newline at end of file