From 012598880cf69a6a4d4d495c78e40ab4abb4eb39 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 22 Nov 2014 15:44:43 +0100 Subject: 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. --- src/test/pmt_tests.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/test/pmt_tests.cpp') diff --git a/src/test/pmt_tests.cpp b/src/test/pmt_tests.cpp index 3b535a84f..eea5b0af4 100644 --- a/src/test/pmt_tests.cpp +++ b/src/test/pmt_tests.cpp @@ -10,6 +10,7 @@ #include +#include #include using namespace std; @@ -104,4 +105,14 @@ BOOST_AUTO_TEST_CASE(pmt_test1) } } +BOOST_AUTO_TEST_CASE(pmt_malleability) +{ + std::vector vTxid = boost::assign::list_of(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)(9)(10); + std::vector vMatch = boost::assign::list_of(false)(false)(false)(false)(false)(false)(false)(false)(false)(true)(true)(false); + + CPartialMerkleTree tree(vTxid, vMatch); + std::vector vTxid2; + BOOST_CHECK(tree.ExtractMatches(vTxid) == 0); +} + BOOST_AUTO_TEST_SUITE_END() -- cgit v1.2.3