From 246e2a24c5460504c799fbc6312ef075f0ca4e72 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/Makefile.test.include | 2 + src/test/bip352_tests.cpp | 187 ++ .../data/bip352_send_and_receive_vectors.json | 2673 +++++++++++++++++ 3 files changed, 2862 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/Makefile.test.include b/src/Makefile.test.include index cf88a02b95f06..4114d02a0c44e 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -17,6 +17,7 @@ FUZZ_BINARY=test/fuzz/fuzz$(EXEEXT) JSON_TEST_FILES = \ test/data/script_tests.json \ test/data/bip341_wallet_vectors.json \ + test/data/bip352_send_and_receive_vectors.json \ test/data/base58_encode_decode.json \ test/data/blockfilters.json \ test/data/key_io_valid.json \ @@ -75,6 +76,7 @@ BITCOIN_TESTS =\ test/bech32_tests.cpp \ test/bip32_tests.cpp \ test/bip324_tests.cpp \ + test/bip352_tests.cpp \ test/blockchain_tests.cpp \ test/blockencodings_tests.cpp \ test/blockfilter_index_tests.cpp \ diff --git a/src/test/bip352_tests.cpp b/src/test/bip352_tests.cpp new file mode 100644 index 0000000000000..e7b7c63bcb003 --- /dev/null +++ b/src/test/bip352_tests.cpp @@ -0,0 +1,187 @@ +#include +#include +#include +#include +#include