mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
refactor: Switch serialize to uint8_t (1/n)
This commit is contained in:
@@ -28,7 +28,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper)
|
||||
for (const bool obfuscate : {false, true}) {
|
||||
fs::path ph = m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_obfuscate_true" : "dbwrapper_obfuscate_false");
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||
char key = 'k';
|
||||
uint8_t key{'k'};
|
||||
uint256 in = InsecureRand256();
|
||||
uint256 res;
|
||||
|
||||
@@ -88,21 +88,21 @@ BOOST_AUTO_TEST_CASE(dbwrapper_basic_data)
|
||||
BOOST_CHECK_EQUAL(res.ToString(), in_utxo.ToString());
|
||||
|
||||
//Simulate last block file number - "l"
|
||||
char key_last_blockfile_number = 'l';
|
||||
uint8_t key_last_blockfile_number{'l'};
|
||||
uint32_t lastblockfilenumber = InsecureRand32();
|
||||
BOOST_CHECK(dbw.Write(key_last_blockfile_number, lastblockfilenumber));
|
||||
BOOST_CHECK(dbw.Read(key_last_blockfile_number, res_uint_32));
|
||||
BOOST_CHECK_EQUAL(lastblockfilenumber, res_uint_32);
|
||||
|
||||
//Simulate Is Reindexing - "R"
|
||||
char key_IsReindexing = 'R';
|
||||
uint8_t key_IsReindexing{'R'};
|
||||
bool isInReindexing = InsecureRandBool();
|
||||
BOOST_CHECK(dbw.Write(key_IsReindexing, isInReindexing));
|
||||
BOOST_CHECK(dbw.Read(key_IsReindexing, res_bool));
|
||||
BOOST_CHECK_EQUAL(isInReindexing, res_bool);
|
||||
|
||||
//Simulate last block hash up to which UXTO covers - 'B'
|
||||
char key_lastblockhash_uxto = 'B';
|
||||
uint8_t key_lastblockhash_uxto{'B'};
|
||||
uint256 lastblock_hash = InsecureRand256();
|
||||
BOOST_CHECK(dbw.Write(key_lastblockhash_uxto, lastblock_hash));
|
||||
BOOST_CHECK(dbw.Read(key_lastblockhash_uxto, res));
|
||||
@@ -129,11 +129,11 @@ BOOST_AUTO_TEST_CASE(dbwrapper_batch)
|
||||
fs::path ph = m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_batch_obfuscate_true" : "dbwrapper_batch_obfuscate_false");
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||
|
||||
char key = 'i';
|
||||
uint8_t key{'i'};
|
||||
uint256 in = InsecureRand256();
|
||||
char key2 = 'j';
|
||||
uint8_t key2{'j'};
|
||||
uint256 in2 = InsecureRand256();
|
||||
char key3 = 'k';
|
||||
uint8_t key3{'k'};
|
||||
uint256 in3 = InsecureRand256();
|
||||
|
||||
uint256 res;
|
||||
@@ -166,10 +166,10 @@ BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||
|
||||
// The two keys are intentionally chosen for ordering
|
||||
char key = 'j';
|
||||
uint8_t key{'j'};
|
||||
uint256 in = InsecureRand256();
|
||||
BOOST_CHECK(dbw.Write(key, in));
|
||||
char key2 = 'k';
|
||||
uint8_t key2{'k'};
|
||||
uint256 in2 = InsecureRand256();
|
||||
BOOST_CHECK(dbw.Write(key2, in2));
|
||||
|
||||
@@ -178,7 +178,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
|
||||
// Be sure to seek past the obfuscation key (if it exists)
|
||||
it->Seek(key);
|
||||
|
||||
char key_res;
|
||||
uint8_t key_res;
|
||||
uint256 val_res;
|
||||
|
||||
BOOST_REQUIRE(it->GetKey(key_res));
|
||||
@@ -207,7 +207,7 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate)
|
||||
|
||||
// Set up a non-obfuscated wrapper to write some initial data.
|
||||
std::unique_ptr<CDBWrapper> dbw = std::make_unique<CDBWrapper>(ph, (1 << 10), false, false, false);
|
||||
char key = 'k';
|
||||
uint8_t key{'k'};
|
||||
uint256 in = InsecureRand256();
|
||||
uint256 res;
|
||||
|
||||
@@ -248,7 +248,7 @@ BOOST_AUTO_TEST_CASE(existing_data_reindex)
|
||||
|
||||
// Set up a non-obfuscated wrapper to write some initial data.
|
||||
std::unique_ptr<CDBWrapper> dbw = std::make_unique<CDBWrapper>(ph, (1 << 10), false, false, false);
|
||||
char key = 'k';
|
||||
uint8_t key{'k'};
|
||||
uint256 in = InsecureRand256();
|
||||
uint256 res;
|
||||
|
||||
@@ -334,7 +334,7 @@ struct StringContentsSerializer {
|
||||
void Serialize(Stream& s) const
|
||||
{
|
||||
for (size_t i = 0; i < str.size(); i++) {
|
||||
s << str[i];
|
||||
s << uint8_t(str[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ struct StringContentsSerializer {
|
||||
void Unserialize(Stream& s)
|
||||
{
|
||||
str.clear();
|
||||
char c = 0;
|
||||
uint8_t c{0};
|
||||
while (true) {
|
||||
try {
|
||||
s >> c;
|
||||
|
||||
Reference in New Issue
Block a user