mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
Merge bitcoin/bitcoin#23829: refactor: use braced init for integer literals instead of c style casts
f2fc03ec85
refactor: use braced init for integer constants instead of c style casts (Pasta) Pull request description: See https://github.com/bitcoin/bitcoin/pull/23810 for more context. This is broken out from that PR, as it is less breaking, and should be trivial to review and merge. EDIT: Long term, the intention is to remove all C-style casts, as they can dangerously introduce reinterpret_casts. This is one step which removes a number of trivially removable C-style casts ACKs for top commit: aureleoules: ACKf2fc03ec85
Tree-SHA512: 2fd11b92c9147e3f970ec3e130e3b3dce70e707ff02950a8c697d4b111ddcbbfa16915393db20cfc8f384bc76f13241c9b994a187987fcecd16a61f8cc0af14c
This commit is contained in:
commit
3212d104f4
23 changed files with 47 additions and 47 deletions
|
@ -99,9 +99,9 @@ static CAmount make_hard_case(int utxos, std::vector<OutputGroup>& utxo_pool)
|
||||||
utxo_pool.clear();
|
utxo_pool.clear();
|
||||||
CAmount target = 0;
|
CAmount target = 0;
|
||||||
for (int i = 0; i < utxos; ++i) {
|
for (int i = 0; i < utxos; ++i) {
|
||||||
target += (CAmount)1 << (utxos+i);
|
target += CAmount{1} << (utxos+i);
|
||||||
add_coin((CAmount)1 << (utxos+i), 2*i, utxo_pool);
|
add_coin(CAmount{1} << (utxos+i), 2*i, utxo_pool);
|
||||||
add_coin(((CAmount)1 << (utxos+i)) + ((CAmount)1 << (utxos-1-i)), 2*i + 1, utxo_pool);
|
add_coin((CAmount{1} << (utxos+i)) + (CAmount{1} << (utxos-1-i)), 2*i + 1, utxo_pool);
|
||||||
}
|
}
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,10 +119,10 @@ uint64_t SipHashUint256(uint64_t k0, uint64_t k1, const uint256& val)
|
||||||
SIPROUND;
|
SIPROUND;
|
||||||
SIPROUND;
|
SIPROUND;
|
||||||
v0 ^= d;
|
v0 ^= d;
|
||||||
v3 ^= ((uint64_t)4) << 59;
|
v3 ^= (uint64_t{4}) << 59;
|
||||||
SIPROUND;
|
SIPROUND;
|
||||||
SIPROUND;
|
SIPROUND;
|
||||||
v0 ^= ((uint64_t)4) << 59;
|
v0 ^= (uint64_t{4}) << 59;
|
||||||
v2 ^= 0xFF;
|
v2 ^= 0xFF;
|
||||||
SIPROUND;
|
SIPROUND;
|
||||||
SIPROUND;
|
SIPROUND;
|
||||||
|
@ -159,7 +159,7 @@ uint64_t SipHashUint256Extra(uint64_t k0, uint64_t k1, const uint256& val, uint3
|
||||||
SIPROUND;
|
SIPROUND;
|
||||||
SIPROUND;
|
SIPROUND;
|
||||||
v0 ^= d;
|
v0 ^= d;
|
||||||
d = (((uint64_t)36) << 56) | extra;
|
d = ((uint64_t{36}) << 56) | extra;
|
||||||
v3 ^= d;
|
v3 ^= d;
|
||||||
SIPROUND;
|
SIPROUND;
|
||||||
SIPROUND;
|
SIPROUND;
|
||||||
|
|
|
@ -344,7 +344,7 @@ public:
|
||||||
collection_flags.setup(size);
|
collection_flags.setup(size);
|
||||||
epoch_flags.resize(size);
|
epoch_flags.resize(size);
|
||||||
// Set to 45% as described above
|
// Set to 45% as described above
|
||||||
epoch_size = std::max((uint32_t)1, (45 * size) / 100);
|
epoch_size = std::max(uint32_t{1}, (45 * size) / 100);
|
||||||
// Initially set to wait for a whole epoch
|
// Initially set to wait for a whole epoch
|
||||||
epoch_heuristic_counter = epoch_size;
|
epoch_heuristic_counter = epoch_size;
|
||||||
return size;
|
return size;
|
||||||
|
|
|
@ -200,7 +200,7 @@ public:
|
||||||
return rand64() >> (64 - bits);
|
return rand64() >> (64 - bits);
|
||||||
} else {
|
} else {
|
||||||
if (bitbuf_size < bits) FillBitBuffer();
|
if (bitbuf_size < bits) FillBitBuffer();
|
||||||
uint64_t ret = bitbuf & (~(uint64_t)0 >> (64 - bits));
|
uint64_t ret = bitbuf & (~uint64_t{0} >> (64 - bits));
|
||||||
bitbuf >>= bits;
|
bitbuf >>= bits;
|
||||||
bitbuf_size -= bits;
|
bitbuf_size -= bits;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -1303,7 +1303,7 @@ public:
|
||||||
// Serialize the nSequence
|
// Serialize the nSequence
|
||||||
if (nInput != nIn && (fHashSingle || fHashNone))
|
if (nInput != nIn && (fHashSingle || fHashNone))
|
||||||
// let the others update at will
|
// let the others update at will
|
||||||
::Serialize(s, (int)0);
|
::Serialize(s, int{0});
|
||||||
else
|
else
|
||||||
::Serialize(s, txTo.vin[nInput].nSequence);
|
::Serialize(s, txTo.vin[nInput].nSequence);
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ static void Correct_Queue_range(std::vector<size_t> range)
|
||||||
BOOST_AUTO_TEST_CASE(test_CheckQueue_Correct_Zero)
|
BOOST_AUTO_TEST_CASE(test_CheckQueue_Correct_Zero)
|
||||||
{
|
{
|
||||||
std::vector<size_t> range;
|
std::vector<size_t> range;
|
||||||
range.push_back((size_t)0);
|
range.push_back(size_t{0});
|
||||||
Correct_Queue_range(range);
|
Correct_Queue_range(range);
|
||||||
}
|
}
|
||||||
/** Test that 1 check is correct
|
/** Test that 1 check is correct
|
||||||
|
@ -202,7 +202,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Correct_Zero)
|
||||||
BOOST_AUTO_TEST_CASE(test_CheckQueue_Correct_One)
|
BOOST_AUTO_TEST_CASE(test_CheckQueue_Correct_One)
|
||||||
{
|
{
|
||||||
std::vector<size_t> range;
|
std::vector<size_t> range;
|
||||||
range.push_back((size_t)1);
|
range.push_back(size_t{1});
|
||||||
Correct_Queue_range(range);
|
Correct_Queue_range(range);
|
||||||
}
|
}
|
||||||
/** Test that MAX check is correct
|
/** Test that MAX check is correct
|
||||||
|
|
|
@ -723,14 +723,14 @@ BOOST_AUTO_TEST_CASE(countbits_tests)
|
||||||
// Check handling of zero.
|
// Check handling of zero.
|
||||||
BOOST_CHECK_EQUAL(CountBits(0), 0U);
|
BOOST_CHECK_EQUAL(CountBits(0), 0U);
|
||||||
} else if (i < 10) {
|
} else if (i < 10) {
|
||||||
for (uint64_t j = (uint64_t)1 << (i - 1); (j >> i) == 0; ++j) {
|
for (uint64_t j = uint64_t{1} << (i - 1); (j >> i) == 0; ++j) {
|
||||||
// Exhaustively test up to 10 bits
|
// Exhaustively test up to 10 bits
|
||||||
BOOST_CHECK_EQUAL(CountBits(j), i);
|
BOOST_CHECK_EQUAL(CountBits(j), i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int k = 0; k < 1000; k++) {
|
for (int k = 0; k < 1000; k++) {
|
||||||
// Randomly test 1000 samples of each length above 10 bits.
|
// Randomly test 1000 samples of each length above 10 bits.
|
||||||
uint64_t j = ((uint64_t)1) << (i - 1) | ctx.randbits(i - 1);
|
uint64_t j = (uint64_t{1}) << (i - 1) | ctx.randbits(i - 1);
|
||||||
BOOST_CHECK_EQUAL(CountBits(j), i);
|
BOOST_CHECK_EQUAL(CountBits(j), i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ void initialize_p2p_transport_serialization()
|
||||||
FUZZ_TARGET_INIT(p2p_transport_serialization, initialize_p2p_transport_serialization)
|
FUZZ_TARGET_INIT(p2p_transport_serialization, initialize_p2p_transport_serialization)
|
||||||
{
|
{
|
||||||
// Construct deserializer, with a dummy NodeId
|
// Construct deserializer, with a dummy NodeId
|
||||||
V1TransportDeserializer deserializer{Params(), (NodeId)0, SER_NETWORK, INIT_PROTO_VERSION};
|
V1TransportDeserializer deserializer{Params(), NodeId{0}, SER_NETWORK, INIT_PROTO_VERSION};
|
||||||
V1TransportSerializer serializer{};
|
V1TransportSerializer serializer{};
|
||||||
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
|
|
||||||
bool Condition(int32_t version) const
|
bool Condition(int32_t version) const
|
||||||
{
|
{
|
||||||
uint32_t mask = ((uint32_t)1) << m_bit;
|
uint32_t mask = (uint32_t{1}) << m_bit;
|
||||||
return (((version & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (version & mask) != 0);
|
return (((version & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (version & mask) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
|
||||||
// For each of the lower bits in count that are 0, do 1 step. Each
|
// For each of the lower bits in count that are 0, do 1 step. Each
|
||||||
// corresponds to an inner value that existed before processing the
|
// corresponds to an inner value that existed before processing the
|
||||||
// current leaf, and each needs a hash to combine it.
|
// current leaf, and each needs a hash to combine it.
|
||||||
for (level = 0; !(count & (((uint32_t)1) << level)); level++) {
|
for (level = 0; !(count & ((uint32_t{1}) << level)); level++) {
|
||||||
if (pbranch) {
|
if (pbranch) {
|
||||||
if (matchh) {
|
if (matchh) {
|
||||||
pbranch->push_back(inner[level]);
|
pbranch->push_back(inner[level]);
|
||||||
|
@ -74,12 +74,12 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
|
||||||
int level = 0;
|
int level = 0;
|
||||||
// As long as bit number level in count is zero, skip it. It means there
|
// As long as bit number level in count is zero, skip it. It means there
|
||||||
// is nothing left at this level.
|
// is nothing left at this level.
|
||||||
while (!(count & (((uint32_t)1) << level))) {
|
while (!(count & ((uint32_t{1}) << level))) {
|
||||||
level++;
|
level++;
|
||||||
}
|
}
|
||||||
uint256 h = inner[level];
|
uint256 h = inner[level];
|
||||||
bool matchh = matchlevel == level;
|
bool matchh = matchlevel == level;
|
||||||
while (count != (((uint32_t)1) << level)) {
|
while (count != ((uint32_t{1}) << level)) {
|
||||||
// If we reach this point, h is an inner value that is not the top.
|
// If we reach this point, h is an inner value that is not the top.
|
||||||
// We combine it with itself (Bitcoin's special rule for odd levels in
|
// We combine it with itself (Bitcoin's special rule for odd levels in
|
||||||
// the tree) to produce a higher level one.
|
// the tree) to produce a higher level one.
|
||||||
|
@ -89,10 +89,10 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
|
||||||
CHash256().Write(h).Write(h).Finalize(h);
|
CHash256().Write(h).Write(h).Finalize(h);
|
||||||
// Increment count to the value it would have if two entries at this
|
// Increment count to the value it would have if two entries at this
|
||||||
// level had existed.
|
// level had existed.
|
||||||
count += (((uint32_t)1) << level);
|
count += ((uint32_t{1}) << level);
|
||||||
level++;
|
level++;
|
||||||
// And propagate the result upwards accordingly.
|
// And propagate the result upwards accordingly.
|
||||||
while (!(count & (((uint32_t)1) << level))) {
|
while (!(count & ((uint32_t{1}) << level))) {
|
||||||
if (pbranch) {
|
if (pbranch) {
|
||||||
if (matchh) {
|
if (matchh) {
|
||||||
pbranch->push_back(inner[level]);
|
pbranch->push_back(inner[level]);
|
||||||
|
|
|
@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(fastrandom_randbits)
|
||||||
for (int j = 0; j < 1000; ++j) {
|
for (int j = 0; j < 1000; ++j) {
|
||||||
uint64_t rangebits = ctx1.randbits(bits);
|
uint64_t rangebits = ctx1.randbits(bits);
|
||||||
BOOST_CHECK_EQUAL(rangebits >> bits, 0U);
|
BOOST_CHECK_EQUAL(rangebits >> bits, 0U);
|
||||||
uint64_t range = ((uint64_t)1) << bits | rangebits;
|
uint64_t range = (uint64_t{1}) << bits | rangebits;
|
||||||
uint64_t rand = ctx2.randrange(range);
|
uint64_t rand = ctx2.randrange(range);
|
||||||
BOOST_CHECK(rand < range);
|
BOOST_CHECK(rand < range);
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,17 +123,17 @@ BOOST_AUTO_TEST_CASE(varints_bitpatterns)
|
||||||
CDataStream ss(SER_DISK, 0);
|
CDataStream ss(SER_DISK, 0);
|
||||||
ss << VARINT_MODE(0, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "00"); ss.clear();
|
ss << VARINT_MODE(0, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "00"); ss.clear();
|
||||||
ss << VARINT_MODE(0x7f, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "7f"); ss.clear();
|
ss << VARINT_MODE(0x7f, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "7f"); ss.clear();
|
||||||
ss << VARINT_MODE((int8_t)0x7f, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "7f"); ss.clear();
|
ss << VARINT_MODE(int8_t{0x7f}, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "7f"); ss.clear();
|
||||||
ss << VARINT_MODE(0x80, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "8000"); ss.clear();
|
ss << VARINT_MODE(0x80, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "8000"); ss.clear();
|
||||||
ss << VARINT((uint8_t)0x80); BOOST_CHECK_EQUAL(HexStr(ss), "8000"); ss.clear();
|
ss << VARINT(uint8_t{0x80}); BOOST_CHECK_EQUAL(HexStr(ss), "8000"); ss.clear();
|
||||||
ss << VARINT_MODE(0x1234, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "a334"); ss.clear();
|
ss << VARINT_MODE(0x1234, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "a334"); ss.clear();
|
||||||
ss << VARINT_MODE((int16_t)0x1234, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "a334"); ss.clear();
|
ss << VARINT_MODE(int16_t{0x1234}, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "a334"); ss.clear();
|
||||||
ss << VARINT_MODE(0xffff, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "82fe7f"); ss.clear();
|
ss << VARINT_MODE(0xffff, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "82fe7f"); ss.clear();
|
||||||
ss << VARINT((uint16_t)0xffff); BOOST_CHECK_EQUAL(HexStr(ss), "82fe7f"); ss.clear();
|
ss << VARINT(uint16_t{0xffff}); BOOST_CHECK_EQUAL(HexStr(ss), "82fe7f"); ss.clear();
|
||||||
ss << VARINT_MODE(0x123456, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "c7e756"); ss.clear();
|
ss << VARINT_MODE(0x123456, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "c7e756"); ss.clear();
|
||||||
ss << VARINT_MODE((int32_t)0x123456, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "c7e756"); ss.clear();
|
ss << VARINT_MODE(int32_t{0x123456}, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "c7e756"); ss.clear();
|
||||||
ss << VARINT(0x80123456U); BOOST_CHECK_EQUAL(HexStr(ss), "86ffc7e756"); ss.clear();
|
ss << VARINT(0x80123456U); BOOST_CHECK_EQUAL(HexStr(ss), "86ffc7e756"); ss.clear();
|
||||||
ss << VARINT((uint32_t)0x80123456U); BOOST_CHECK_EQUAL(HexStr(ss), "86ffc7e756"); ss.clear();
|
ss << VARINT(uint32_t{0x80123456U}); BOOST_CHECK_EQUAL(HexStr(ss), "86ffc7e756"); ss.clear();
|
||||||
ss << VARINT(0xffffffff); BOOST_CHECK_EQUAL(HexStr(ss), "8efefefe7f"); ss.clear();
|
ss << VARINT(0xffffffff); BOOST_CHECK_EQUAL(HexStr(ss), "8efefefe7f"); ss.clear();
|
||||||
ss << VARINT_MODE(0x7fffffffffffffffLL, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "fefefefefefefefe7f"); ss.clear();
|
ss << VARINT_MODE(0x7fffffffffffffffLL, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "fefefefefefefefe7f"); ss.clear();
|
||||||
ss << VARINT(0xffffffffffffffffULL); BOOST_CHECK_EQUAL(HexStr(ss), "80fefefefefefefefe7f"); ss.clear();
|
ss << VARINT(0xffffffffffffffffULL); BOOST_CHECK_EQUAL(HexStr(ss), "80fefefefefefefefe7f"); ss.clear();
|
||||||
|
|
|
@ -144,10 +144,10 @@ BOOST_AUTO_TEST_CASE(bitstream_reader_writer)
|
||||||
CDataStream data_copy(data);
|
CDataStream data_copy(data);
|
||||||
uint32_t serialized_int1;
|
uint32_t serialized_int1;
|
||||||
data >> serialized_int1;
|
data >> serialized_int1;
|
||||||
BOOST_CHECK_EQUAL(serialized_int1, (uint32_t)0x7700C35A); // NOTE: Serialized as LE
|
BOOST_CHECK_EQUAL(serialized_int1, uint32_t{0x7700C35A}); // NOTE: Serialized as LE
|
||||||
uint16_t serialized_int2;
|
uint16_t serialized_int2;
|
||||||
data >> serialized_int2;
|
data >> serialized_int2;
|
||||||
BOOST_CHECK_EQUAL(serialized_int2, (uint16_t)0x1072); // NOTE: Serialized as LE
|
BOOST_CHECK_EQUAL(serialized_int2, uint16_t{0x1072}); // NOTE: Serialized as LE
|
||||||
|
|
||||||
BitStreamReader<CDataStream> bit_reader(data_copy);
|
BitStreamReader<CDataStream> bit_reader(data_copy);
|
||||||
BOOST_CHECK_EQUAL(bit_reader.Read(1), 0U);
|
BOOST_CHECK_EQUAL(bit_reader.Read(1), 0U);
|
||||||
|
|
|
@ -810,8 +810,8 @@ BOOST_AUTO_TEST_CASE(test_ParseInt64)
|
||||||
BOOST_CHECK(ParseInt64("01234", &n) && n == 1234LL); // no octal
|
BOOST_CHECK(ParseInt64("01234", &n) && n == 1234LL); // no octal
|
||||||
BOOST_CHECK(ParseInt64("2147483647", &n) && n == 2147483647LL);
|
BOOST_CHECK(ParseInt64("2147483647", &n) && n == 2147483647LL);
|
||||||
BOOST_CHECK(ParseInt64("-2147483648", &n) && n == -2147483648LL);
|
BOOST_CHECK(ParseInt64("-2147483648", &n) && n == -2147483648LL);
|
||||||
BOOST_CHECK(ParseInt64("9223372036854775807", &n) && n == (int64_t)9223372036854775807);
|
BOOST_CHECK(ParseInt64("9223372036854775807", &n) && n == int64_t{9223372036854775807});
|
||||||
BOOST_CHECK(ParseInt64("-9223372036854775808", &n) && n == (int64_t)-9223372036854775807-1);
|
BOOST_CHECK(ParseInt64("-9223372036854775808", &n) && n == int64_t{-9223372036854775807-1});
|
||||||
BOOST_CHECK(ParseInt64("-1234", &n) && n == -1234LL);
|
BOOST_CHECK(ParseInt64("-1234", &n) && n == -1234LL);
|
||||||
// Invalid values
|
// Invalid values
|
||||||
BOOST_CHECK(!ParseInt64("", &n));
|
BOOST_CHECK(!ParseInt64("", &n));
|
||||||
|
@ -907,8 +907,8 @@ BOOST_AUTO_TEST_CASE(test_ParseUInt32)
|
||||||
BOOST_CHECK(ParseUInt32("1234", &n) && n == 1234);
|
BOOST_CHECK(ParseUInt32("1234", &n) && n == 1234);
|
||||||
BOOST_CHECK(ParseUInt32("01234", &n) && n == 1234); // no octal
|
BOOST_CHECK(ParseUInt32("01234", &n) && n == 1234); // no octal
|
||||||
BOOST_CHECK(ParseUInt32("2147483647", &n) && n == 2147483647);
|
BOOST_CHECK(ParseUInt32("2147483647", &n) && n == 2147483647);
|
||||||
BOOST_CHECK(ParseUInt32("2147483648", &n) && n == (uint32_t)2147483648);
|
BOOST_CHECK(ParseUInt32("2147483648", &n) && n == uint32_t{2147483648});
|
||||||
BOOST_CHECK(ParseUInt32("4294967295", &n) && n == (uint32_t)4294967295);
|
BOOST_CHECK(ParseUInt32("4294967295", &n) && n == uint32_t{4294967295});
|
||||||
BOOST_CHECK(ParseUInt32("+1234", &n) && n == 1234);
|
BOOST_CHECK(ParseUInt32("+1234", &n) && n == 1234);
|
||||||
BOOST_CHECK(ParseUInt32("00000000000000001234", &n) && n == 1234);
|
BOOST_CHECK(ParseUInt32("00000000000000001234", &n) && n == 1234);
|
||||||
BOOST_CHECK(ParseUInt32("00000000000000000000", &n) && n == 0);
|
BOOST_CHECK(ParseUInt32("00000000000000000000", &n) && n == 0);
|
||||||
|
|
|
@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
|
||||||
COutPoint outp{txid, 0};
|
COutPoint outp{txid, 0};
|
||||||
newcoin.nHeight = 1;
|
newcoin.nHeight = 1;
|
||||||
newcoin.out.nValue = InsecureRand32();
|
newcoin.out.nValue = InsecureRand32();
|
||||||
newcoin.out.scriptPubKey.assign((uint32_t)56, 1);
|
newcoin.out.scriptPubKey.assign(uint32_t{56}, 1);
|
||||||
coins_view.AddCoin(outp, std::move(newcoin), false);
|
coins_view.AddCoin(outp, std::move(newcoin), false);
|
||||||
|
|
||||||
return outp;
|
return outp;
|
||||||
|
|
|
@ -31,7 +31,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
|
||||||
COutPoint outp{txid, 0};
|
COutPoint outp{txid, 0};
|
||||||
newcoin.nHeight = 1;
|
newcoin.nHeight = 1;
|
||||||
newcoin.out.nValue = InsecureRand32();
|
newcoin.out.nValue = InsecureRand32();
|
||||||
newcoin.out.scriptPubKey.assign((uint32_t)56, 1);
|
newcoin.out.scriptPubKey.assign(uint32_t{56}, 1);
|
||||||
coins_view.AddCoin(outp, std::move(newcoin), false);
|
coins_view.AddCoin(outp, std::move(newcoin), false);
|
||||||
|
|
||||||
return outp;
|
return outp;
|
||||||
|
|
|
@ -34,7 +34,7 @@ std::string FormatMoney(const CAmount n)
|
||||||
str.erase(str.size()-nTrim, nTrim);
|
str.erase(str.size()-nTrim, nTrim);
|
||||||
|
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
str.insert((unsigned int)0, 1, '-');
|
str.insert(uint32_t{0}, 1, '-');
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VersionBitsConditionChecker(Consensus::DeploymentPos id_) : id(id_) {}
|
explicit VersionBitsConditionChecker(Consensus::DeploymentPos id_) : id(id_) {}
|
||||||
uint32_t Mask(const Consensus::Params& params) const { return ((uint32_t)1) << params.vDeployments[id].bit; }
|
uint32_t Mask(const Consensus::Params& params) const { return (uint32_t{1}) << params.vDeployments[id].bit; }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -100,7 +100,7 @@ void BerkeleyEnvironment::Close()
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
LogPrintf("BerkeleyEnvironment::Close: Error %d closing database environment: %s\n", ret, DbEnv::strerror(ret));
|
LogPrintf("BerkeleyEnvironment::Close: Error %d closing database environment: %s\n", ret, DbEnv::strerror(ret));
|
||||||
if (!fMockDb)
|
if (!fMockDb)
|
||||||
DbEnv((uint32_t)0).remove(strPath.c_str(), 0);
|
DbEnv(uint32_t{0}).remove(strPath.c_str(), 0);
|
||||||
|
|
||||||
if (error_file) fclose(error_file);
|
if (error_file) fclose(error_file);
|
||||||
|
|
||||||
|
|
|
@ -2123,7 +2123,7 @@ bool DescriptorScriptPubKeyMan::TopUp(unsigned int size)
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
target_size = size;
|
target_size = size;
|
||||||
} else {
|
} else {
|
||||||
target_size = std::max(gArgs.GetIntArg("-keypool", DEFAULT_KEYPOOL_SIZE), (int64_t) 1);
|
target_size = std::max(gArgs.GetIntArg("-keypool", DEFAULT_KEYPOOL_SIZE), int64_t{1});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the new range_end
|
// Calculate the new range_end
|
||||||
|
|
|
@ -667,7 +667,7 @@ util::Result<SelectionResult> AutomaticCoinSelection(const CWallet& wallet, Coin
|
||||||
// possible) if we cannot fund the transaction otherwise.
|
// possible) if we cannot fund the transaction otherwise.
|
||||||
if (wallet.m_spend_zero_conf_change) {
|
if (wallet.m_spend_zero_conf_change) {
|
||||||
ordered_filters.push_back({CoinEligibilityFilter(0, 1, 2)});
|
ordered_filters.push_back({CoinEligibilityFilter(0, 1, 2)});
|
||||||
ordered_filters.push_back({CoinEligibilityFilter(0, 1, std::min((size_t)4, max_ancestors/3), std::min((size_t)4, max_descendants/3))});
|
ordered_filters.push_back({CoinEligibilityFilter(0, 1, std::min(size_t{4}, max_ancestors/3), std::min(size_t{4}, max_descendants/3))});
|
||||||
ordered_filters.push_back({CoinEligibilityFilter(0, 1, max_ancestors/2, max_descendants/2)});
|
ordered_filters.push_back({CoinEligibilityFilter(0, 1, max_ancestors/2, max_descendants/2)});
|
||||||
// If partial groups are allowed, relax the requirement of spending OutputGroups (groups
|
// If partial groups are allowed, relax the requirement of spending OutputGroups (groups
|
||||||
// of UTXOs sent to the same address, which are obviously controlled by a single wallet)
|
// of UTXOs sent to the same address, which are obviously controlled by a single wallet)
|
||||||
|
|
|
@ -121,9 +121,9 @@ static CAmount make_hard_case(int utxos, std::vector<COutput>& utxo_pool)
|
||||||
utxo_pool.clear();
|
utxo_pool.clear();
|
||||||
CAmount target = 0;
|
CAmount target = 0;
|
||||||
for (int i = 0; i < utxos; ++i) {
|
for (int i = 0; i < utxos; ++i) {
|
||||||
target += (CAmount)1 << (utxos+i);
|
target += CAmount{1} << (utxos+i);
|
||||||
add_coin((CAmount)1 << (utxos+i), 2*i, utxo_pool);
|
add_coin(CAmount{1} << (utxos+i), 2*i, utxo_pool);
|
||||||
add_coin(((CAmount)1 << (utxos+i)) + ((CAmount)1 << (utxos-1-i)), 2*i + 1, utxo_pool);
|
add_coin((CAmount{1} << (utxos+i)) + (CAmount{1} << (utxos-1-i)), 2*i + 1, utxo_pool);
|
||||||
}
|
}
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
|
@ -736,10 +736,10 @@ BOOST_FIXTURE_TEST_CASE(wallet_descriptor_test, BasicTestingSetup)
|
||||||
std::vector<unsigned char> malformed_record;
|
std::vector<unsigned char> malformed_record;
|
||||||
CVectorWriter vw(0, 0, malformed_record, 0);
|
CVectorWriter vw(0, 0, malformed_record, 0);
|
||||||
vw << std::string("notadescriptor");
|
vw << std::string("notadescriptor");
|
||||||
vw << (uint64_t)0;
|
vw << uint64_t{0};
|
||||||
vw << (int32_t)0;
|
vw << int32_t{0};
|
||||||
vw << (int32_t)0;
|
vw << int32_t{0};
|
||||||
vw << (int32_t)1;
|
vw << int32_t{1};
|
||||||
|
|
||||||
SpanReader vr{0, 0, malformed_record};
|
SpanReader vr{0, 0, malformed_record};
|
||||||
WalletDescriptor w_desc;
|
WalletDescriptor w_desc;
|
||||||
|
|
Loading…
Add table
Reference in a new issue