Browse Source

Use unique_ptr for dbw (CDBWrapper)

0.16
practicalswift 7 years ago
parent
commit
0024531625
  1. 10
      src/test/dbwrapper_tests.cpp

10
src/test/dbwrapper_tests.cpp

@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate) @@ -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;
@ -135,8 +135,7 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate) @@ -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);
@ -167,7 +166,7 @@ BOOST_AUTO_TEST_CASE(existing_data_reindex) @@ -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;
@ -177,8 +176,7 @@ BOOST_AUTO_TEST_CASE(existing_data_reindex) @@ -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);

Loading…
Cancel
Save