15#include <boost/test/unit_test.hpp>
26 *(
vHash[n].begin() + (bit>>3)) ^= 1<<(bit&7);
36 static const unsigned int tx_counts[] = {1, 4, 7, 17, 56, 100, 127, 256, 312, 513, 1000, 4095};
38 for (
int i = 0; i < 12; i++) {
39 unsigned int nTx = tx_counts[i];
43 for (
unsigned int j=0; j<nTx; j++) {
51 std::vector<uint256> vTxid(nTx,
uint256());
52 for (
unsigned int j=0; j<nTx; j++)
53 vTxid[j] = block.
vtx[j]->GetHash();
61 for (
int att = 1; att < 15; att++) {
63 std::vector<bool> vMatch(nTx,
false);
64 std::vector<uint256> vMatchTxid1;
65 for (
unsigned int j=0; j<nTx; j++) {
66 bool fInclude = m_rng.randbits(att / 2) == 0;
69 vMatchTxid1.push_back(vTxid[j]);
80 unsigned int n = std::min<unsigned int>(nTx, 1 + vMatchTxid1.size()*
nHeight);
88 std::vector<uint256> vMatchTxid2;
89 std::vector<unsigned int> vIndex;
90 uint256 merkleRoot2 = pmt2.ExtractMatches(vMatchTxid2, vIndex);
100 for (
int j=0; j<4; j++) {
103 std::vector<uint256> vMatchTxid3;
113 std::vector<uint256> vTxid{
121 std::vector<bool> vMatch = {
false,
false,
false,
false,
false,
false,
false,
false,
false,
true,
true,
false};
124 std::vector<unsigned int> vIndex;
std::vector< CTransactionRef > vtx
Data structure that represents a partial merkle tree.
uint256 ExtractMatches(std::vector< uint256 > &vMatch, std::vector< unsigned int > &vnIndex)
extract the matching txid's represented by this partial merkle tree and their respective indices with...
std::vector< uint256 > vHash
txids and internal hashes
CPartialMerkleTreeTester(FastRandomContext &rng)
FastRandomContext & m_rng
Double ended buffer combining vector and stream-like interfaces.
I randrange(I range) noexcept
Generate a random integer in the range [0..range), with range > 0.
uint64_t randbits(int bits) noexcept
Generate a random (bits)-bit integer.
constexpr bool IsNull() const
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
#define BOOST_CHECK(expr)
BOOST_AUTO_TEST_CASE(pmt_test1)
static CTransactionRef MakeTransactionRef(Tx &&txIn)
A mutable version of CTransaction.