10#include <boost/test/unit_test.hpp>
18 hash =
Hash(*it, hash);
20 hash =
Hash(hash, *it);
32 for (std::vector<CTransactionRef>::const_iterator it(block.
vtx.begin()); it != block.
vtx.end(); ++it)
33 vMerkleTree.push_back((*it)->GetHash().ToUint256());
36 for (
int nSize = block.
vtx.size(); nSize > 1; nSize = (nSize + 1) / 2)
38 for (
int i = 0; i < nSize; i += 2)
40 int i2 = std::min(i+1, nSize-1);
60 for (
int nSize = block.
vtx.size(); nSize > 1; nSize = (nSize + 1) / 2)
62 int i = std::min(nIndex^1, nSize-1);
82 for (
int i = 0; i < 32; i++) {
84 int ntx = (i <= 16) ? i : 17 + (m_rng.randrange(4000));
99 for (
int j = 0;
j <
ntx;
j++) {
133 for (
int loop = 0; loop < std::min(
ntx, 16); loop++) {
137 mtx = m_rng.randrange(
ntx);
186 for (std::size_t pos = 0; pos < block.
vtx.size(); pos++) {
209 for (pos = 0; pos < block.
vtx.size(); pos++) {
215 for (pos = 0; pos < block.
vtx.size() / 2; pos++)
218 for (pos = block.
vtx.size() / 2; pos < block.
vtx.size(); pos++)
238 for (std::size_t pos = 0; pos <
vtx_count; pos++) {
246 std::vector<uint256>
hashes;
249 for (
size_t pos{1}; pos <
vtx_count; ++pos) {
250 hashes[pos] = block.
vtx[pos]->GetWitnessHash().ToUint256();
std::vector< CTransactionRef > vtx
constexpr bool IsNull() const
static const uint256 ZERO
uint256 ComputeMerkleRoot(std::vector< uint256 > hashes, bool *mutated)
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
std::vector< uint256 > TransactionMerklePath(const CBlock &block, uint32_t position)
Compute merkle path to the specified transaction.
uint256 BlockWitnessMerkleRoot(const CBlock &block)
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
uint256 Hash(const T &in1)
Compute the 256-bit hash of an object.
static uint256 BlockBuildMerkleTree(const CBlock &block, bool *fMutated, std::vector< uint256 > &vMerkleTree)
static int ctz(uint32_t i)
static uint256 ComputeMerkleRootFromBranch(const uint256 &leaf, const std::vector< uint256 > &vMerkleBranch, uint32_t nIndex)
static std::vector< uint256 > BlockGetMerkleBranch(const CBlock &block, const std::vector< uint256 > &vMerkleTree, int nIndex)
BOOST_AUTO_TEST_CASE(merkle_test)
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
static CTransactionRef MakeTransactionRef(Tx &&txIn)
A mutable version of CTransaction.
Testing setup that configures a complete environment.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.