aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-11-22 15:44:43 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2014-12-11 17:22:15 +0100
commit012598880cf69a6a4d4d495c78e40ab4abb4eb39 (patch)
treef2d433bad71f00fadfdeac6063700b43735863b6 /src/test
parent3bb29a3e13f78f534d96b71048a128843f3bab85 (diff)
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.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/pmt_tests.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/test/pmt_tests.cpp b/src/test/pmt_tests.cpp
index 3b535a84fd..eea5b0af49 100644
--- a/src/test/pmt_tests.cpp
+++ b/src/test/pmt_tests.cpp
@@ -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()