Skip to content

Commit 173c796

Browse files
committed
Merge bitcoin/bitcoin#24854: Remove not needed ArithToUint256 roundtrips in tests
fad6d4f Remove not needed ArithToUint256 roundtrips in tests (MarcoFalke) fa456cc Remove duplicate static_asserts (MarcoFalke) Pull request description: No need to go from `arith_uint256`->`uint256` when a `uint256` can be constructed right away. ACKs for top commit: laanwj: Code review ACK fad6d4f Tree-SHA512: bea901ea5904bf61a0dadf7168c6b126f7e62ff1180d4aa72063c28930a01a8baa57ab0d324226bd4de72fb59559455c29c049d90061f888044198aae1426dcb
2 parents 2513499 + fad6d4f commit 173c796

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

src/arith_uint256.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,19 @@ template<unsigned int BITS>
2424
class base_uint
2525
{
2626
protected:
27+
static_assert(BITS / 32 > 0 && BITS % 32 == 0, "Template parameter BITS must be a positive multiple of 32.");
2728
static constexpr int WIDTH = BITS / 32;
2829
uint32_t pn[WIDTH];
2930
public:
3031

3132
base_uint()
3233
{
33-
static_assert(BITS/32 > 0 && BITS%32 == 0, "Template parameter BITS must be a positive multiple of 32.");
34-
3534
for (int i = 0; i < WIDTH; i++)
3635
pn[i] = 0;
3736
}
3837

3938
base_uint(const base_uint& b)
4039
{
41-
static_assert(BITS/32 > 0 && BITS%32 == 0, "Template parameter BITS must be a positive multiple of 32.");
42-
4340
for (int i = 0; i < WIDTH; i++)
4441
pn[i] = b.pn[i];
4542
}
@@ -53,8 +50,6 @@ class base_uint
5350

5451
base_uint(uint64_t b)
5552
{
56-
static_assert(BITS/32 > 0 && BITS%32 == 0, "Template parameter BITS must be a positive multiple of 32.");
57-
5853
pn[0] = (unsigned int)b;
5954
pn[1] = (unsigned int)(b >> 32);
6055
for (int i = 2; i < WIDTH; i++)

src/test/denialofservice_tests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
// Unit tests for denial-of-service detection/prevention code
66

7-
#include <arith_uint256.h>
87
#include <banman.h>
98
#include <chainparams.h>
109
#include <net.h>
@@ -464,7 +463,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
464463
// ecdsa_signature_parse_der_lax are executed during this test.
465464
// Specifically branches that run only when an ECDSA
466465
// signature's R and S values have leading zeros.
467-
g_insecure_rand_ctx = FastRandomContext(ArithToUint256(arith_uint256(33)));
466+
g_insecure_rand_ctx = FastRandomContext{uint256{33}};
468467

469468
TxOrphanageTest orphanage;
470469
CKey key;

src/test/pmt_tests.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#include <arith_uint256.h>
65
#include <consensus/merkle.h>
76
#include <merkleblock.h>
87
#include <serialize.h>
@@ -107,13 +106,13 @@ BOOST_AUTO_TEST_CASE(pmt_test1)
107106

108107
BOOST_AUTO_TEST_CASE(pmt_malleability)
109108
{
110-
std::vector<uint256> vTxid = {
111-
ArithToUint256(1), ArithToUint256(2),
112-
ArithToUint256(3), ArithToUint256(4),
113-
ArithToUint256(5), ArithToUint256(6),
114-
ArithToUint256(7), ArithToUint256(8),
115-
ArithToUint256(9), ArithToUint256(10),
116-
ArithToUint256(9), ArithToUint256(10),
109+
std::vector<uint256> vTxid{
110+
uint256{1}, uint256{2},
111+
uint256{3}, uint256{4},
112+
uint256{5}, uint256{6},
113+
uint256{7}, uint256{8},
114+
uint256{9}, uint256{10},
115+
uint256{9}, uint256{10},
117116
};
118117
std::vector<bool> vMatch = {false, false, false, false, false, false, false, false, false, true, true, false};
119118

0 commit comments

Comments
 (0)