Skip to content

Commit b1c36a8

Browse files
committed
Merge #719: Add unit test for dynafed CalculateRoot methods
6650067 Add unit test for dynafed CalculateRoot methods (Steven Roose) Pull request description: I created these for having test vectors for rust-elements, but it makes sense to have them around so that we don't accidentally change them. Tree-SHA512: 1e6fef4a09e1ab15cf462858c83e65c1224b15e14aa73b7ae1788b74aca3c2c46147affb44a1a1a64bf8c4ff7f57f3859e220652f4ea2ab5ff14738a33ab756a
2 parents 690fed6 + 6650067 commit b1c36a8

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/Makefile.test.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ BITCOIN_TESTS =\
131131
test/validation_block_tests.cpp \
132132
test/versionbits_tests.cpp \
133133
test/pegin_spent_tests.cpp \
134+
test/dynafed_tests.cpp \
134135
test/blind_tests.cpp
135136
# ELEMENTS IN THE END
136137

src/test/dynafed_tests.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) 2017-2017 Blockstream
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#include <test/test_bitcoin.h>
6+
#include <string>
7+
#include <boost/test/unit_test.hpp>
8+
#include <primitives/block.h>
9+
#include <script/script.h>
10+
#include <serialize.h>
11+
12+
13+
BOOST_FIXTURE_TEST_SUITE(dynafed_tests, BasicTestingSetup)
14+
15+
// Ensure the paam roots doesn't change unexpectedly.
16+
BOOST_AUTO_TEST_CASE(dynafed_params_root)
17+
{
18+
CScript signblockscript(opcodetype(1));
19+
uint32_t signblock_wl(2);
20+
CScript fp_program(opcodetype(3));
21+
CScript fp_script(opcodetype(4));
22+
std::vector<std::vector<unsigned char>> ext{ {5, 6}, {7} };
23+
24+
DynaFedParamEntry compact_entry = DynaFedParamEntry(signblockscript, signblock_wl);
25+
BOOST_CHECK_EQUAL(
26+
compact_entry.CalculateRoot().GetHex(),
27+
"dff5f3793abc06a6d75e80fe3cfd47406f732fa4ec9305960ae2a229222a1ad5"
28+
);
29+
30+
DynaFedParamEntry full_entry =
31+
DynaFedParamEntry(signblockscript, signblock_wl, fp_program, fp_script, ext);
32+
BOOST_CHECK_EQUAL(
33+
full_entry.CalculateRoot().GetHex(),
34+
"175be2087ba7cc0e33348bef493bd3e34f31f64bf9226e5881ab310dafa432ff"
35+
);
36+
37+
DynaFedParams params = DynaFedParams(compact_entry, full_entry);
38+
BOOST_CHECK_EQUAL(
39+
params.CalculateRoot().GetHex(),
40+
"e56cf79487952dfa85fe6a85829600adc19714ba6ab1157fdff02b25ae60cee2"
41+
);
42+
}
43+
44+
BOOST_AUTO_TEST_SUITE_END()
45+
46+

0 commit comments

Comments
 (0)