mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 13:32:33 +02:00
Merge bitcoin/bitcoin#24854: Remove not needed ArithToUint256 roundtrips in tests
fad6d4f952
Remove not needed ArithToUint256 roundtrips in tests (MarcoFalke)fa456ccb22
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 ACKfad6d4f952
Tree-SHA512: bea901ea5904bf61a0dadf7168c6b126f7e62ff1180d4aa72063c28930a01a8baa57ab0d324226bd4de72fb59559455c29c049d90061f888044198aae1426dcb
This commit is contained in:
commit
173c796268
@ -24,22 +24,19 @@ template<unsigned int BITS>
|
|||||||
class base_uint
|
class base_uint
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
static_assert(BITS / 32 > 0 && BITS % 32 == 0, "Template parameter BITS must be a positive multiple of 32.");
|
||||||
static constexpr int WIDTH = BITS / 32;
|
static constexpr int WIDTH = BITS / 32;
|
||||||
uint32_t pn[WIDTH];
|
uint32_t pn[WIDTH];
|
||||||
public:
|
public:
|
||||||
|
|
||||||
base_uint()
|
base_uint()
|
||||||
{
|
{
|
||||||
static_assert(BITS/32 > 0 && BITS%32 == 0, "Template parameter BITS must be a positive multiple of 32.");
|
|
||||||
|
|
||||||
for (int i = 0; i < WIDTH; i++)
|
for (int i = 0; i < WIDTH; i++)
|
||||||
pn[i] = 0;
|
pn[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
base_uint(const base_uint& b)
|
base_uint(const base_uint& b)
|
||||||
{
|
{
|
||||||
static_assert(BITS/32 > 0 && BITS%32 == 0, "Template parameter BITS must be a positive multiple of 32.");
|
|
||||||
|
|
||||||
for (int i = 0; i < WIDTH; i++)
|
for (int i = 0; i < WIDTH; i++)
|
||||||
pn[i] = b.pn[i];
|
pn[i] = b.pn[i];
|
||||||
}
|
}
|
||||||
@ -53,8 +50,6 @@ public:
|
|||||||
|
|
||||||
base_uint(uint64_t b)
|
base_uint(uint64_t b)
|
||||||
{
|
{
|
||||||
static_assert(BITS/32 > 0 && BITS%32 == 0, "Template parameter BITS must be a positive multiple of 32.");
|
|
||||||
|
|
||||||
pn[0] = (unsigned int)b;
|
pn[0] = (unsigned int)b;
|
||||||
pn[1] = (unsigned int)(b >> 32);
|
pn[1] = (unsigned int)(b >> 32);
|
||||||
for (int i = 2; i < WIDTH; i++)
|
for (int i = 2; i < WIDTH; i++)
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
// Unit tests for denial-of-service detection/prevention code
|
// Unit tests for denial-of-service detection/prevention code
|
||||||
|
|
||||||
#include <arith_uint256.h>
|
|
||||||
#include <banman.h>
|
#include <banman.h>
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
@ -464,7 +463,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
|
|||||||
// ecdsa_signature_parse_der_lax are executed during this test.
|
// ecdsa_signature_parse_der_lax are executed during this test.
|
||||||
// Specifically branches that run only when an ECDSA
|
// Specifically branches that run only when an ECDSA
|
||||||
// signature's R and S values have leading zeros.
|
// signature's R and S values have leading zeros.
|
||||||
g_insecure_rand_ctx = FastRandomContext(ArithToUint256(arith_uint256(33)));
|
g_insecure_rand_ctx = FastRandomContext{uint256{33}};
|
||||||
|
|
||||||
TxOrphanageTest orphanage;
|
TxOrphanageTest orphanage;
|
||||||
CKey key;
|
CKey key;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <arith_uint256.h>
|
|
||||||
#include <consensus/merkle.h>
|
#include <consensus/merkle.h>
|
||||||
#include <merkleblock.h>
|
#include <merkleblock.h>
|
||||||
#include <serialize.h>
|
#include <serialize.h>
|
||||||
@ -107,13 +106,13 @@ BOOST_AUTO_TEST_CASE(pmt_test1)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(pmt_malleability)
|
BOOST_AUTO_TEST_CASE(pmt_malleability)
|
||||||
{
|
{
|
||||||
std::vector<uint256> vTxid = {
|
std::vector<uint256> vTxid{
|
||||||
ArithToUint256(1), ArithToUint256(2),
|
uint256{1}, uint256{2},
|
||||||
ArithToUint256(3), ArithToUint256(4),
|
uint256{3}, uint256{4},
|
||||||
ArithToUint256(5), ArithToUint256(6),
|
uint256{5}, uint256{6},
|
||||||
ArithToUint256(7), ArithToUint256(8),
|
uint256{7}, uint256{8},
|
||||||
ArithToUint256(9), ArithToUint256(10),
|
uint256{9}, uint256{10},
|
||||||
ArithToUint256(9), ArithToUint256(10),
|
uint256{9}, uint256{10},
|
||||||
};
|
};
|
||||||
std::vector<bool> vMatch = {false, false, false, false, false, false, false, false, false, true, true, false};
|
std::vector<bool> vMatch = {false, false, false, false, false, false, false, false, false, true, true, false};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user