From 9d78a2ce4ff908689d5d9acab964d1063082d5ca Mon Sep 17 00:00:00 2001 From: josibake Date: Sun, 5 May 2024 12:53:19 +0200 Subject: [PATCH] tests: add BIP352 test vectors as unit tests Use the test vectors to test sending and receiving. A few cases are not covered here, namely anything that requires testing specific to the wallet. For example: * Taproot script path spending is not tested, as that is better tested in a wallets coin selection / signing logic * Re-computing outputs during RBF is not tested, as that is better tested in a wallets RBF logic The unit tests are written in such a way that adding new test cases is as easy as updating the JSON file --- src/test/CMakeLists.txt | 2 + src/test/bip352_tests.cpp | 188 ++ .../data/bip352_send_and_receive_vectors.json | 2760 +++++++++++++++++ 3 files changed, 2950 insertions(+) create mode 100644 src/test/bip352_tests.cpp create mode 100644 src/test/data/bip352_send_and_receive_vectors.json diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 336377331d9..30d8f642d21 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -18,6 +18,7 @@ add_executable(test_bitcoin bech32_tests.cpp bip32_tests.cpp bip324_tests.cpp + bip352_tests.cpp blockchain_tests.cpp blockencodings_tests.cpp blockfilter_index_tests.cpp @@ -129,6 +130,7 @@ include(TargetDataSources) target_json_data_sources(test_bitcoin data/base58_encode_decode.json data/bip341_wallet_vectors.json + data/bip352_send_and_receive_vectors.json data/blockfilters.json data/key_io_invalid.json data/key_io_valid.json diff --git a/src/test/bip352_tests.cpp b/src/test/bip352_tests.cpp new file mode 100644 index 00000000000..376687722d3 --- /dev/null +++ b/src/test/bip352_tests.cpp @@ -0,0 +1,188 @@ +#include +#include +#include +#include +#include