Changeset View
Changeset View
Standalone View
Standalone View
src/test/pmt_tests.cpp
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | for (int i = 0; i < 12; i++) { | ||||
BOOST_CHECK(ss.size() <= 10 + (258 * n + 7) / 8); | BOOST_CHECK(ss.size() <= 10 + (258 * n + 7) / 8); | ||||
// deserialize into a tester copy | // deserialize into a tester copy | ||||
CPartialMerkleTreeTester pmt2; | CPartialMerkleTreeTester pmt2; | ||||
ss >> pmt2; | ss >> pmt2; | ||||
// extract merkle root and matched txids from copy | // extract merkle root and matched txids from copy | ||||
std::vector<uint256> vMatchTxid2; | std::vector<uint256> vMatchTxid2; | ||||
std::vector<unsigned int> vIndex; | std::vector<size_t> vIndex; | ||||
uint256 merkleRoot2 = pmt2.ExtractMatches(vMatchTxid2, vIndex); | uint256 merkleRoot2 = pmt2.ExtractMatches(vMatchTxid2, vIndex); | ||||
// check that it has the same merkle root as the original, and a | // check that it has the same merkle root as the original, and a | ||||
// valid one | // valid one | ||||
BOOST_CHECK(merkleRoot1 == merkleRoot2); | BOOST_CHECK(merkleRoot1 == merkleRoot2); | ||||
BOOST_CHECK(!merkleRoot2.IsNull()); | BOOST_CHECK(!merkleRoot2.IsNull()); | ||||
// check that it contains the matched transactions (in the same | // check that it contains the matched transactions (in the same | ||||
Show All 17 Lines | std::vector<uint256> vTxid = { | ||||
ArithToUint256(1), ArithToUint256(2), ArithToUint256(3), | ArithToUint256(1), ArithToUint256(2), ArithToUint256(3), | ||||
ArithToUint256(4), ArithToUint256(5), ArithToUint256(6), | ArithToUint256(4), ArithToUint256(5), ArithToUint256(6), | ||||
ArithToUint256(7), ArithToUint256(8), ArithToUint256(9), | ArithToUint256(7), ArithToUint256(8), ArithToUint256(9), | ||||
ArithToUint256(10), ArithToUint256(9), ArithToUint256(10)}; | ArithToUint256(10), ArithToUint256(9), ArithToUint256(10)}; | ||||
std::vector<bool> vMatch = {false, false, false, false, false, false, | std::vector<bool> vMatch = {false, false, false, false, false, false, | ||||
false, false, false, true, true, false}; | false, false, false, true, true, false}; | ||||
CPartialMerkleTree tree(vTxid, vMatch); | CPartialMerkleTree tree(vTxid, vMatch); | ||||
std::vector<unsigned int> vIndex; | std::vector<size_t> vIndex; | ||||
BOOST_CHECK(tree.ExtractMatches(vTxid, vIndex).IsNull()); | BOOST_CHECK(tree.ExtractMatches(vTxid, vIndex).IsNull()); | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |