aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-04-05 09:28:30 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-04-14 08:35:38 +0000
commit5e673c03fec66024027b94229fa2e317d7767a20 (patch)
treecb754f13947b96bf9cbbd74e579d4b7c709a0212 /tests/unit_tests
parentMerge pull request #5423 (diff)
downloadmonero-5e673c03fec66024027b94229fa2e317d7767a20.tar.xz
blockchain_db: fix db txn ending too early
The db txn in add_block ending caused the entire overarching batch txn to stop. Also add a new guard class so a db txn can be stopped in the face of exceptions. Also use a read only db txn in init when the db itself is read only, and do not save the max tx size in that case.
Diffstat (limited to 'tests/unit_tests')
-rw-r--r--tests/unit_tests/blockchain_db.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/unit_tests/blockchain_db.cpp b/tests/unit_tests/blockchain_db.cpp
index 4fbc21ddc..f302d7946 100644
--- a/tests/unit_tests/blockchain_db.cpp
+++ b/tests/unit_tests/blockchain_db.cpp
@@ -271,6 +271,8 @@ TYPED_TEST(BlockchainDBTest, AddBlock)
this->get_filenames();
this->init_hard_fork();
+ db_wtxn_guard guard(this->m_db);
+
// adding a block with no parent in the blockchain should throw.
// note: this shouldn't be possible, but is a good (and cheap) failsafe.
//
@@ -317,6 +319,8 @@ TYPED_TEST(BlockchainDBTest, RetrieveBlockData)
this->get_filenames();
this->init_hard_fork();
+ db_wtxn_guard guard(this->m_db);
+
ASSERT_NO_THROW(this->m_db->add_block(this->m_blocks[0], t_sizes[0], t_sizes[0], t_diffs[0], t_coins[0], this->m_txs[0]));
ASSERT_EQ(t_sizes[0], this->m_db->get_block_weight(0));