Skip to content

Commit

Permalink
Use unique_ptr for dbw (CDBWrapper)
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalswift committed Nov 9, 2017
1 parent fa6d122 commit 0024531
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/test/dbwrapper_tests.cpp
Expand Up @@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate)
create_directories(ph);

// Set up a non-obfuscated wrapper to write some initial data.
CDBWrapper* dbw = new CDBWrapper(ph, (1 << 10), false, false, false);
std::unique_ptr<CDBWrapper> dbw = std::unique_ptr<CDBWrapper>(new CDBWrapper(ph, (1 << 10), false, false, false));
char key = 'k';
uint256 in = InsecureRand256();
uint256 res;
Expand All @@ -135,8 +135,7 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate)
BOOST_CHECK_EQUAL(res.ToString(), in.ToString());

// Call the destructor to free leveldb LOCK
delete dbw;
dbw = nullptr;
dbw.reset();

// Now, set up another wrapper that wants to obfuscate the same directory
CDBWrapper odbw(ph, (1 << 10), false, false, true);
Expand Down Expand Up @@ -167,7 +166,7 @@ BOOST_AUTO_TEST_CASE(existing_data_reindex)
create_directories(ph);

// Set up a non-obfuscated wrapper to write some initial data.
CDBWrapper* dbw = new CDBWrapper(ph, (1 << 10), false, false, false);
std::unique_ptr<CDBWrapper> dbw = std::unique_ptr<CDBWrapper>(new CDBWrapper(ph, (1 << 10), false, false, false));
char key = 'k';
uint256 in = InsecureRand256();
uint256 res;
Expand All @@ -177,8 +176,7 @@ BOOST_AUTO_TEST_CASE(existing_data_reindex)
BOOST_CHECK_EQUAL(res.ToString(), in.ToString());

// Call the destructor to free leveldb LOCK
delete dbw;
dbw = nullptr;
dbw.reset();

// Simulate a -reindex by wiping the existing data store
CDBWrapper odbw(ph, (1 << 10), false, true, true);
Expand Down

0 comments on commit 0024531

Please sign in to comment.