Changeset View
Changeset View
Standalone View
Standalone View
src/test/dbwrapper_tests.cpp
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | |||||
// Test that we do not obfuscation if there is existing data. | // Test that we do not obfuscation if there is existing data. | ||||
BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate) { | BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate) { | ||||
// We're going to share this fs::path between two wrappers | // We're going to share this fs::path between two wrappers | ||||
fs::path ph = fs::temp_directory_path() / fs::unique_path(); | fs::path ph = fs::temp_directory_path() / fs::unique_path(); | ||||
create_directories(ph); | create_directories(ph); | ||||
// Set up a non-obfuscated wrapper to write some initial data. | // Set up a non-obfuscated wrapper to write some initial data. | ||||
std::unique_ptr<CDBWrapper> dbw = | std::unique_ptr<CDBWrapper> dbw = | ||||
MakeUnique<CDBWrapper>(ph, (1 << 10), false, false, false); | std::make_unique<CDBWrapper>(ph, (1 << 10), false, false, false); | ||||
char key = 'k'; | char key = 'k'; | ||||
uint256 in = InsecureRand256(); | uint256 in = InsecureRand256(); | ||||
uint256 res; | uint256 res; | ||||
BOOST_CHECK(dbw->Write(key, in)); | BOOST_CHECK(dbw->Write(key, in)); | ||||
BOOST_CHECK(dbw->Read(key, res)); | BOOST_CHECK(dbw->Read(key, res)); | ||||
BOOST_CHECK_EQUAL(res.ToString(), in.ToString()); | BOOST_CHECK_EQUAL(res.ToString(), in.ToString()); | ||||
Show All 26 Lines | |||||
// Ensure that we start obfuscating during a reindex. | // Ensure that we start obfuscating during a reindex. | ||||
BOOST_AUTO_TEST_CASE(existing_data_reindex) { | BOOST_AUTO_TEST_CASE(existing_data_reindex) { | ||||
// We're going to share this fs::path between two wrappers | // We're going to share this fs::path between two wrappers | ||||
fs::path ph = fs::temp_directory_path() / fs::unique_path(); | fs::path ph = fs::temp_directory_path() / fs::unique_path(); | ||||
create_directories(ph); | create_directories(ph); | ||||
// Set up a non-obfuscated wrapper to write some initial data. | // Set up a non-obfuscated wrapper to write some initial data. | ||||
std::unique_ptr<CDBWrapper> dbw = | std::unique_ptr<CDBWrapper> dbw = | ||||
MakeUnique<CDBWrapper>(ph, (1 << 10), false, false, false); | std::make_unique<CDBWrapper>(ph, (1 << 10), false, false, false); | ||||
char key = 'k'; | char key = 'k'; | ||||
uint256 in = InsecureRand256(); | uint256 in = InsecureRand256(); | ||||
uint256 res; | uint256 res; | ||||
BOOST_CHECK(dbw->Write(key, in)); | BOOST_CHECK(dbw->Write(key, in)); | ||||
BOOST_CHECK(dbw->Read(key, res)); | BOOST_CHECK(dbw->Read(key, res)); | ||||
BOOST_CHECK_EQUAL(res.ToString(), in.ToString()); | BOOST_CHECK_EQUAL(res.ToString(), in.ToString()); | ||||
▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines |