mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Implement test for merkle tree malleability in CPartialMerkleTree
This is a check that is mentioned in BIP 37, but never implemented in the reference code. As Bitcoin Core so far never decodes partial merkle trees, this is not a problem. But perhaps others use the code as a reference.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
@@ -104,4 +105,14 @@ BOOST_AUTO_TEST_CASE(pmt_test1)
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(pmt_malleability)
|
||||
{
|
||||
std::vector<uint256> vTxid = boost::assign::list_of(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)(9)(10);
|
||||
std::vector<bool> vMatch = boost::assign::list_of(false)(false)(false)(false)(false)(false)(false)(false)(false)(true)(true)(false);
|
||||
|
||||
CPartialMerkleTree tree(vTxid, vMatch);
|
||||
std::vector<uint256> vTxid2;
|
||||
BOOST_CHECK(tree.ExtractMatches(vTxid) == 0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user