1 #include <boost/test/unit_test.hpp>
13 unsigned int n =
rand() % vHash.size();
14 int bit =
rand() % 256;
20 BOOST_AUTO_TEST_SUITE(pmt_tests)
24 static const unsigned int nTxCounts[] = {1, 4, 7, 17, 56, 100, 127, 256, 312, 513, 1000, 4095};
26 for (
int n = 0; n < 12; n++) {
27 unsigned int nTx = nTxCounts[n];
31 for (
unsigned int j=0; j<nTx; j++) {
34 block.
vtx.push_back(tx);
39 std::vector<uint256> vTxid(nTx, 0);
40 for (
unsigned int j=0; j<nTx; j++)
41 vTxid[j] = block.
vtx[j].GetHash();
42 int nHeight = 1, nTx_ = nTx;
49 for (
int att = 1; att < 15; att++) {
51 std::vector<bool> vMatch(nTx,
false);
52 std::vector<uint256> vMatchTxid1;
53 for (
unsigned int j=0; j<nTx; j++) {
54 bool fInclude = (
rand() & ((1 << (att/2)) - 1)) == 0;
57 vMatchTxid1.push_back(vTxid[j]);
68 unsigned int n = std::min<unsigned int>(nTx, 1 + vMatchTxid1.size()*nHeight);
69 BOOST_CHECK(ss.
size() <= 10 + (258*n+7)/8);
76 std::vector<uint256> vMatchTxid2;
77 uint256 merkleRoot2 = pmt2.ExtractMatches(vMatchTxid2);
80 BOOST_CHECK(merkleRoot1 == merkleRoot2);
81 BOOST_CHECK(merkleRoot2 != 0);
84 BOOST_CHECK(vMatchTxid1 == vMatchTxid2);
87 for (
int j=0; j<4; j++) {
90 std::vector<uint256> vMatchTxid3;
92 BOOST_CHECK(merkleRoot3 != merkleRoot1);
98 BOOST_AUTO_TEST_SUITE_END()
Double ended buffer combining vector and stream-like interfaces.
Data structure that represents a partial merkle tree.
uint256 BuildMerkleTree() const
uint256 ExtractMatches(std::vector< uint256 > &vMatch)
BOOST_AUTO_TEST_CASE(pmt_test1)
std::vector< CTransaction > vtx
The basic transaction that is broadcasted on the network and contained in blocks. ...