What changed, and why it matters
This commit is a routine maintenance change to the project's unit tests. It updates the test build system to use shared utility code from the Ledger SDK instead of local copies, deletes tests for functions that now live in the SDK, and adds a couple of new test cases for wallet policy parsing. There is no change to the actual Bitcoin app code that runs on the device, and nothing in the commit suggests a security fix or vulnerability.
No security action required. Treat as ordinary test-suite maintenance. If reviewing for supply-chain assurance, verify that the referenced BOLOS_SDK versions of base58/bip32/buffer/read/varint/write are themselves trustworthy, but that is outside the scope of this commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors the unit-tests/ directory. CMakeLists.txt is updated to require BOLOS_SDK and link against lib_standard_app implementations of base58, bip32, buffer, read, varint, and write rather than ../src/common/ copies. Several standalone test files (test_apdu_parser.c, test_base58.c, test_bip32.c, test_format.c, test_write.c) are removed because the tested functions are now provided by the SDK. Remaining tests are adjusted to include both the new SDK headers (lib_standard_app/buffer.h, parser.h) and the app’s extension headers (common/buffer_ext.h, parser_ext.h). Two new test cases for Taproot MuSig policy parsing are registered in test_wallet.c. No application source code is modified.
Changed components
unit-tests/CMakeLists.txtunit-tests/mock_includes/lcx_hash.hunit-tests/test_buffer.cunit-tests/test_parser.cunit-tests/test_wallet.cInspect captured patch +41 / −469
diff --git a/unit-tests/CMakeLists.txt b/unit-tests/CMakeLists.txt
index a7791ef..cd5882a 100644
--- a/unit-tests/CMakeLists.txt
+++ b/unit-tests/CMakeLists.txt
@@ -32,23 +32,26 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. ")
endif()
+if(NOT DEFINED ENV{BOLOS_SDK})
+ message(FATAL_ERROR "BOLOS_SDK is not defined.")
+endif()
+
add_compile_definitions(TEST DEBUG=0 SKIP_FOR_CMOCKA PRINTF=printf COIN_NATIVE_SEGWIT_PREFIX=\"tb\")
include_directories(../src)
+include_directories(../src/debug-helpers)
+include_directories(../src/boilerplate)
include_directories(mock_includes)
include_directories(libs)
+include_directories($ENV{BOLOS_SDK})
+include_directories($ENV{BOLOS_SDK}/lib_standard_app)
-add_executable(test_apdu_parser test_apdu_parser.c)
-add_executable(test_base58 test_base58.c)
-add_executable(test_bip32 test_bip32.c)
add_executable(test_bitvector test_bitvector.c)
add_executable(test_buffer test_buffer.c)
-add_executable(test_format test_format.c)
add_executable(test_display_utils test_display_utils.c)
add_executable(test_parser test_parser.c)
add_executable(test_script test_script.c)
add_executable(test_wallet test_wallet.c)
-add_executable(test_write test_write.c)
# add_executable(test_crypto test_crypto.c)
@@ -57,18 +60,17 @@ add_library(crypto_mocks SHARED libs/crypto_mocks.c)
add_library(sha256 SHARED libs/sha-256.c)
# App's libraries
-add_library(apdu_parser SHARED ../src/boilerplate/apdu_parser.c)
-add_library(base58 SHARED ../src/common/base58.c)
-add_library(bip32 SHARED ../src/common/bip32.c)
-add_library(buffer SHARED ../src/common/buffer.c)
+add_library(base58 SHARED $ENV{BOLOS_SDK}/lib_standard_app/base58.c)
+add_library(bip32 SHARED $ENV{BOLOS_SDK}/lib_standard_app/bip32.c)
+add_library(buffer SHARED $ENV{BOLOS_SDK}/lib_standard_app/buffer.c)
+add_library(buffer_ext SHARED ../src/common/buffer_ext.c)
add_library(display_utils SHARED ../src/ui/display_utils.c)
-add_library(format SHARED ../src/common/format.c)
-add_library(parser SHARED ../src/common/parser.c)
-add_library(read SHARED ../src/common/read.c)
+add_library(parser SHARED ../src/common/parser_ext.c)
+add_library(read SHARED $ENV{BOLOS_SDK}/lib_standard_app/read.c)
add_library(script SHARED ../src/common/script.c)
-add_library(varint SHARED ../src/common/varint.c)
+add_library(varint SHARED $ENV{BOLOS_SDK}/lib_standard_app/varint.c)
add_library(wallet SHARED ../src/common/wallet.c)
-add_library(write SHARED ../src/common/write.c)
+add_library(write SHARED $ENV{BOLOS_SDK}/lib_standard_app/write.c)
# add_library(crypto SHARED ../src/crypto.c)
@@ -76,29 +78,19 @@ add_library(write SHARED ../src/common/write.c)
target_link_libraries(crypto_mocks PUBLIC sha256)
# App's libraries
-target_link_libraries(test_apdu_parser PUBLIC cmocka gcov apdu_parser)
-target_link_libraries(test_base58 PUBLIC cmocka gcov base58)
-target_link_libraries(test_bip32 PUBLIC cmocka gcov bip32 read)
target_link_libraries(test_bitvector PUBLIC cmocka gcov)
-target_link_libraries(test_buffer PUBLIC cmocka gcov buffer varint read write bip32)
+target_link_libraries(test_buffer PUBLIC cmocka gcov buffer buffer_ext varint read write bip32)
target_link_libraries(test_display_utils PUBLIC cmocka gcov display_utils)
-target_link_libraries(test_format PUBLIC cmocka gcov format)
-target_link_libraries(test_parser PUBLIC cmocka gcov parser buffer varint read write bip32)
+target_link_libraries(test_parser PUBLIC cmocka gcov parser buffer buffer_ext varint read write bip32)
target_link_libraries(test_script PUBLIC cmocka gcov script buffer varint read write bip32)
-target_link_libraries(test_wallet PUBLIC cmocka gcov wallet script buffer varint read write bip32 base58 crypto_mocks)
-target_link_libraries(test_write PUBLIC cmocka gcov write)
+target_link_libraries(test_wallet PUBLIC cmocka gcov wallet script buffer buffer_ext varint read write bip32 base58 crypto_mocks)
# target_link_libraries(test_crypto PUBLIC cmocka gcov crypto)
-add_test(test_apdu_parser test_apdu_parser)
-add_test(test_base58 test_base58)
-add_test(test_bip32 test_bip32)
add_test(test_bitvector test_bitvector)
add_test(test_buffer test_buffer)
add_test(test_display_utils test_display_utils)
-add_test(test_format test_format)
add_test(test_parser test_parser)
add_test(test_script test_script)
add_test(test_wallet test_wallet)
-add_test(test_write test_write)
# add_test(test_crypto test_crypto)
diff --git a/unit-tests/mock_includes/lcx_hash.h b/unit-tests/mock_includes/lcx_hash.h
index 5a87f21..2ffc1c9 100644
--- a/unit-tests/mock_includes/lcx_hash.h
+++ b/unit-tests/mock_includes/lcx_hash.h
@@ -19,9 +19,19 @@
#ifndef LCX_HASH_H
#define LCX_HASH_H
-#include "os.h"
#include <stdint.h>
+/* Defines from os.h */
+#ifndef SYSCALL
+#define SYSCALL
+#endif
+
+#ifndef PLENGTH
+#define PLENGTH(...)
+#endif
+
+#define WIDE // const // don't !!
+
/** Message Digest algorithm identifiers. */
enum cx_md_e {
/** NONE Digest */
diff --git a/unit-tests/test_apdu_parser.c b/unit-tests/test_apdu_parser.c
deleted file mode 100644
index b1f864a..0000000
--- a/unit-tests/test_apdu_parser.c
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <string.h>
-
-#include <cmocka.h>
-
-#include "boilerplate/apdu_parser.h"
-
-static void test_apdu_parser(void **state) {
- (void) state;
- uint8_t apdu_bad_min_len[] = {0xE0, 0x03, 0x00, 0x00}; // less than 5 bytes
- uint8_t apdu_bad_lc[] = {0xE0, 0x03, 0x00, 0x00, 0x01}; // Lc = 1 but no data
- uint8_t apdu[] = {0xE0, 0x03, 0x01, 0x02, 0x05, 0x00, 0x01, 0x02, 0x03, 0x04};
-
- command_t cmd;
-
- memset(&cmd, 0, sizeof(cmd));
- assert_false(apdu_parser(&cmd, apdu_bad_min_len, sizeof(apdu_bad_min_len)));
-
- memset(&cmd, 0, sizeof(cmd));
- assert_false(apdu_parser(&cmd, apdu_bad_lc, sizeof(apdu_bad_min_len)));
-
- memset(&cmd, 0, sizeof(cmd));
- assert_true(apdu_parser(&cmd, apdu, sizeof(apdu)));
- assert_int_equal(cmd.cla, 0xE0);
- assert_int_equal(cmd.ins, 0x03);
- assert_int_equal(cmd.p1, 0x01);
- assert_int_equal(cmd.p2, 0x02);
- assert_int_equal(cmd.lc, 5);
- assert_memory_equal(cmd.data, ((uint8_t[]){0x00, 0x01, 0x02, 0x03, 0x04}), cmd.lc);
-}
-
-int main() {
- const struct CMUnitTest tests[] = {cmocka_unit_test(test_apdu_parser)};
-
- return cmocka_run_group_tests(tests, NULL, NULL);
-}
diff --git a/unit-tests/test_base58.c b/unit-tests/test_base58.c
deleted file mode 100644
index f7f5e45..0000000
--- a/unit-tests/test_base58.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <string.h>
-
-#include <cmocka.h>
-
-#include "common/base58.h"
-
-static void test_base58(void **state) {
- (void) state;
-
- const char in[] = "USm3fpXnKG5EUBx2ndxBDMPVciP5hGey2Jh4NDv6gmeo1LkMeiKrLJUUBk6Z";
- const char expected_out[] = "The quick brown fox jumps over the lazy dog.";
- uint8_t out[100] = {0};
- int out_len = base58_decode(in, sizeof(in) - 1, out, sizeof(out));
- assert_int_equal(out_len, strlen(expected_out));
- assert_string_equal((char *) out, expected_out);
-
- const char in2[] = "The quick brown fox jumps over the lazy dog.";
- const char expected_out2[] = "USm3fpXnKG5EUBx2ndxBDMPVciP5hGey2Jh4NDv6gmeo1LkMeiKrLJUUBk6Z";
- char out2[100] = {0};
- int out_len2 = base58_encode((uint8_t *) in2, sizeof(in2) - 1, out2, sizeof(out2));
- assert_int_equal(out_len2, strlen(expected_out2));
- assert_string_equal((char *) out2, expected_out2);
-}
-
-int main() {
- const struct CMUnitTest tests[] = {cmocka_unit_test(test_base58)};
-
- return cmocka_run_group_tests(tests, NULL, NULL);
-}
diff --git a/unit-tests/test_bip32.c b/unit-tests/test_bip32.c
deleted file mode 100644
index 1e406a4..0000000
--- a/unit-tests/test_bip32.c
+++ /dev/null
@@ -1,160 +0,0 @@
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <stdint.h>
-#include <stdbool.h>
-
-#include <cmocka.h>
-
-#include "common/bip32.h"
-
-#define H 0x80000000u
-
-static void test_bip32_format(void **state) {
- (void) state;
-
- char output[30];
- bool b = false;
-
- b = bip32_path_format((const uint32_t[5]){0x8000002C, 0x80000000, 0x80000000, 0, 0},
- 5,
- output,
- sizeof(output));
- assert_true(b);
- assert_string_equal(output, "44'/0'/0'/0/0");
-
- b = bip32_path_format((const uint32_t[5]){0x8000002C, 0x80000001, 0x80000000, 0, 0},
- 5,
- output,
- sizeof(output));
- assert_true(b);
- assert_string_equal(output, "44'/1'/0'/0/0");
-
- // No BIP32 path (=0)
- b = bip32_path_format(NULL, 0, output, sizeof(output));
- assert_true(b);
- assert_string_equal(output, "");
-}
-
-static void test_bad_bip32_format(void **state) {
- (void) state;
-
- char output[30];
- bool b = true;
-
- // More than MAX_BIP32_PATH_STEPS (=10)
- b = bip32_path_format(
- (const uint32_t[11]){0x8000002C, 0x80000000, 0x80000000, 0, 0, 0, 0, 0, 0, 0, 0},
- 11,
- output,
- sizeof(output));
- assert_false(b);
-}
-
-static void test_bip32_read(void **state) {
- (void) state;
-
- // clang-format off
- uint8_t input[20] = {
- 0x80, 0x00, 0x00, 0x2C,
- 0x80, 0x00, 0x00, 0x01,
- 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00
- };
- uint32_t expected[5] = {0x8000002C, 0x80000001, 0x80000000, 0, 0};
- uint32_t output[5] = {0};
- bool b = false;
-
- b = bip32_path_read(input, sizeof(input), output, 5);
- assert_true(b);
- assert_memory_equal(output, expected, 5);
-
- // No BIP32 path
- assert_true(bip32_path_read(input, sizeof(input), output, 0));
-}
-
-static void test_bad_bip32_read(void **state) {
- (void) state;
-
- // clang-format off
- uint8_t input[20] = {
- 0x80, 0x00, 0x00, 0x2C,
- 0x80, 0x00, 0x00, 0x01,
- 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00
- };
- uint32_t output[10] = {0};
-
- // buffer too small (5 BIP32 paths instead of 10)
- assert_false(bip32_path_read(input, sizeof(input), output, 10));
-
- // More than MAX_BIP32_PATH_STEPS (=10)
- assert_false(bip32_path_read(input, sizeof(input), output, 20));
-}
-
-
-static void test_is_pubkey_path_standard_true(void **state) {
- (void) state;
-
- const uint32_t valid_purposes[] = {44, 49, 84};
- const uint32_t coin_types[] = {0, 8};
-
- for (int i_p = 0; i_p < sizeof(valid_purposes)/sizeof(valid_purposes[0]); i_p++) {
- uint32_t purpose = valid_purposes[i_p];
-
- // any coin type will do, if coin_types is not given
- assert_true(is_pubkey_path_standard((const uint32_t[]){purpose^H, 12345^H}, 2, purpose, NULL, 0));
- assert_true(is_pubkey_path_standard((const uint32_t[]){purpose^H, 12345^H, 0^H}, 3, purpose, NULL, 0));
-
- for (int i_c = 0; i_c < sizeof(coin_types)/sizeof(coin_types[0]); i_c++) {
- uint32_t coin_type = coin_types[i_c];
-
- assert_true(is_pubkey_path_standard((const uint32_t[]){purpose^H, coin_type^H, 0^H}, 3, purpose, coin_types, 2));
- }
- }
-}
-
-static void test_is_pubkey_path_standard_false(void **state) {
- (void) state;
-
- const uint32_t coin_types[] = {0, 8};
-
- // path too short
- assert_false(is_pubkey_path_standard(NULL, 0, 44, coin_types, 2));
- assert_false(is_pubkey_path_standard(NULL, 0, 44, NULL, 0));
- assert_false(is_pubkey_path_standard((const uint32_t[]){44^H}, 1, 44, coin_types, 2));
- assert_false(is_pubkey_path_standard((const uint32_t[]){44^H}, 1, 44, NULL, 0));
-
- // wrong purpose
- assert_false(is_pubkey_path_standard((const uint32_t[]){45^H, 0^H}, 2, 44, coin_types, 2));
- // non-hardened purpose
- assert_false(is_pubkey_path_standard((const uint32_t[]){44, 0^H}, 2, 44, coin_types, 2));
-
- // invalid coin type
- assert_false(is_pubkey_path_standard((const uint32_t[]){44^H, 100^H, 0^H}, 3, 44, coin_types, 2));
- // non-hardened coin type (but otherwise in coin_types)
- assert_false(is_pubkey_path_standard((const uint32_t[]){44^H, 8, 0^H}, 3, 44, coin_types, 2));
- // should still check that coin type is hardened, even if coin_types is not given
- assert_false(is_pubkey_path_standard((const uint32_t[]){44^H, 0, 0^H}, 3, 44, NULL, 0));
-
- // account too big
- assert_false(is_pubkey_path_standard((const uint32_t[]){44^H, 0^H, (1 + MAX_BIP44_ACCOUNT_RECOMMENDED)^H}, 3, 44, coin_types, 2));
- // account not hardened
- assert_false(is_pubkey_path_standard((const uint32_t[]){44^H, 0^H, 0}, 3, 44, coin_types, 2));
-}
-
-
-int main() {
- const struct CMUnitTest tests[] = {
- cmocka_unit_test(test_bip32_format),
- cmocka_unit_test(test_bad_bip32_format),
- cmocka_unit_test(test_bip32_read),
- cmocka_unit_test(test_bad_bip32_read),
- cmocka_unit_test(test_is_pubkey_path_standard_true),
- cmocka_unit_test(test_is_pubkey_path_standard_false)
- };
-
- return cmocka_run_group_tests(tests, NULL, NULL);
-}
diff --git a/unit-tests/test_buffer.c b/unit-tests/test_buffer.c
index d6b2bc0..554969e 100644
--- a/unit-tests/test_buffer.c
+++ b/unit-tests/test_buffer.c
@@ -7,40 +7,8 @@
#include <cmocka.h>
-#include "common/buffer.h"
-
-static void test_buffer_can_read(void **state) {
- (void) state;
-
- uint8_t temp[20] = {0};
- buffer_t buf = {.ptr = temp, .size = sizeof(temp), .offset = 0};
-
- assert_true(buffer_can_read(&buf, 20));
-
- assert_true(buffer_seek_cur(&buf, 20));
- assert_false(buffer_can_read(&buf, 1));
-}
-
-static void test_buffer_seek(void **state) {
- (void) state;
-
- uint8_t temp[20] = {0};
- buffer_t buf = {.ptr = temp, .size = sizeof(temp), .offset = 0};
-
- assert_true(buffer_can_read(&buf, 20));
-
- assert_true(buffer_seek_cur(&buf, 20)); // seek at offset 20
- assert_false(buffer_can_read(&buf, 1)); // can't read 1 byte
- assert_false(buffer_seek_cur(&buf, 1)); // can't move at offset 21
-
- assert_true(buffer_seek_end(&buf, 19));
- assert_int_equal(buf.offset, 1);
- assert_false(buffer_seek_end(&buf, 21)); // can't seek at offset -1
-
- assert_true(buffer_seek_set(&buf, 10));
- assert_int_equal(buf.offset, 10);
- assert_false(buffer_seek_set(&buf, 21)); // can't seek at offset 21
-}
+#include "common/buffer_ext.h"
+#include "lib_standard_app/buffer.h"
static void test_buffer_get_cur(void **state) {
(void) state;
@@ -483,9 +451,7 @@ static void test_buffer_snapshot_restore(void **state) {
int main() {
- const struct CMUnitTest tests[] = {cmocka_unit_test(test_buffer_can_read),
- cmocka_unit_test(test_buffer_seek),
- cmocka_unit_test(test_buffer_get_cur),
+ const struct CMUnitTest tests[] = {cmocka_unit_test(test_buffer_get_cur),
cmocka_unit_test(test_buffer_read),
cmocka_unit_test(test_buffer_peek),
cmocka_unit_test(test_buffer_peek_n),
diff --git a/unit-tests/test_format.c b/unit-tests/test_format.c
deleted file mode 100644
index 11e2fa6..0000000
--- a/unit-tests/test_format.c
+++ /dev/null
@@ -1,105 +0,0 @@
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <string.h>
-
-#include <cmocka.h>
-
-#include "common/format.h"
-
-static void test_format_i64(void **state) {
- (void) state;
-
- char temp[22] = {0};
-
- int64_t value = 0;
- assert_true(format_i64(temp, sizeof(temp), value));
- assert_string_equal(temp, "0");
-
- value = (int64_t) 9223372036854775807ull; // MAX_INT64
- memset(temp, 0, sizeof(temp));
- assert_true(format_i64(temp, sizeof(temp), value));
- assert_string_equal(temp, "9223372036854775807");
-
- // buffer too small
- assert_false(format_i64(temp, sizeof(temp) - 5, value));
-
- value = (int64_t) -9223372036854775808ull; // MIN_INT64
- memset(temp, 0, sizeof(temp));
- assert_true(format_i64(temp, sizeof(temp), value));
- assert_string_equal(temp, "-9223372036854775808");
-}
-
-static void test_format_u64(void **state) {
- (void) state;
-
- char temp[21] = {0};
-
- uint64_t value = 0;
- assert_true(format_u64(temp, sizeof(temp), value));
- assert_string_equal(temp, "0");
-
- value = (uint64_t) 18446744073709551615ull; // MAX_UNT64
- memset(temp, 0, sizeof(temp));
- assert_true(format_u64(temp, sizeof(temp), value));
- assert_string_equal(temp, "18446744073709551615");
-
- // buffer too small
- assert_false(format_u64(temp, sizeof(temp) - 5, value));
-}
-
-static void test_format_fpu64(void **state) {
- (void) state;
-
- char temp[22] = {0};
-
- uint64_t amount = 100000000ull; // satoshi
- memset(temp, 0, sizeof(temp));
- assert_true(format_fpu64(temp, sizeof(temp), amount, 8));
- assert_string_equal(temp, "1.00000000"); // BTC
-
- amount = 24964823ull; // satoshi
- memset(temp, 0, sizeof(temp));
- assert_true(format_fpu64(temp, sizeof(temp), amount, 8));
- assert_string_equal(temp, "0.24964823"); // BTC
-
- amount = 100ull; // satoshi
- memset(temp, 0, sizeof(temp));
- assert_true(format_fpu64(temp, sizeof(temp), amount, 8));
- assert_string_equal(temp, "0.00000100"); // BTC
- // buffer too small
- assert_false(format_fpu64(temp, sizeof(temp) - 16, amount, 8));
-
- char temp2[50] = {0};
-
- amount = 1000000000000000000ull; // wei
- assert_true(format_fpu64(temp2, sizeof(temp2), amount, 18));
- assert_string_equal(temp2, "1.000000000000000000"); // ETH
-
- // buffer too small
- assert_false(format_fpu64(temp2, sizeof(temp2) - 20, amount, 18));
-}
-
-static void test_format_hex(void **state) {
- (void) state;
-
- uint8_t address[] = {0xde, 0xb, 0x29, 0x56, 0x69, 0xa9, 0xfd, 0x93, 0xd5, 0xf2,
- 0x8d, 0x9e, 0xc8, 0x5e, 0x40, 0xf4, 0xcb, 0x69, 0x7b, 0xae};
- char output[2 * sizeof(address) + 1] = {0};
-
- assert_int_equal(2 * sizeof(address) + 1,
- format_hex(address, sizeof(address), output, sizeof(output)));
- assert_string_equal(output, "de0b295669a9fd93d5f28d9ec85e40f4cb697bae");
- assert_int_equal(-1, format_hex(address, sizeof(address), output, sizeof(address)));
-}
-
-int main() {
- const struct CMUnitTest tests[] = {cmocka_unit_test(test_format_i64),
- cmocka_unit_test(test_format_u64),
- cmocka_unit_test(test_format_fpu64),
- cmocka_unit_test(test_format_hex)};
-
- return cmocka_run_group_tests(tests, NULL, NULL);
-}
diff --git a/unit-tests/test_parser.c b/unit-tests/test_parser.c
index 05070ad..b199be2 100644
--- a/unit-tests/test_parser.c
+++ b/unit-tests/test_parser.c
@@ -7,7 +7,10 @@
#include <cmocka.h>
-#include "common/parser.h"
+#include "common/buffer_ext.h"
+#include "common/parser_ext.h"
+#include "lib_standard_app/buffer.h"
+#include "lib_standard_app/parser.h"
// An example parser that reads an uint32_t, an array of 8 bytes, and an uint8_t.
typedef struct {
diff --git a/unit-tests/test_wallet.c b/unit-tests/test_wallet.c
index cd66a92..39c30c9 100644
--- a/unit-tests/test_wallet.c
+++ b/unit-tests/test_wallet.c
@@ -8,6 +8,8 @@
#include <cmocka.h>
+#include "common/buffer_ext.h"
+
// missing definitions to make it compile without the SDK
unsigned int pic(unsigned int linked_address) {
return linked_address;
@@ -680,6 +682,8 @@ int main() {
cmocka_unit_test(test_parse_policy_map_multisig_3),
cmocka_unit_test(test_parse_policy_tr),
cmocka_unit_test(test_parse_policy_tr_multisig),
+ cmocka_unit_test(test_parse_policy_tr_musig_scriptpath),
+ cmocka_unit_test(test_parse_policy_tr_musig_keypath),
cmocka_unit_test(test_get_policy_segwit_version),
cmocka_unit_test(test_failures),
cmocka_unit_test(test_miniscript_types),
diff --git a/unit-tests/test_write.c b/unit-tests/test_write.c
deleted file mode 100644
index 08f37f7..0000000
--- a/unit-tests/test_write.c
+++ /dev/null
@@ -1,64 +0,0 @@
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <string.h>
-
-#include <cmocka.h>
-
-#include "common/write.h"
-
-static void test_write(void **state) {
- (void) state;
-
- uint8_t tmp2[2] = {0};
-
- uint8_t expected2[2] = {0x01, 0x07};
- write_u16_be(tmp2, 0, (uint16_t) 263U);
- assert_memory_equal(tmp2, expected2, sizeof(expected2));
-
- memset(tmp2, 0, sizeof(tmp2));
- expected2[0] = 0x07;
- expected2[1] = 0x01;
- write_u16_le(tmp2, 0, (uint16_t) 263U);
- assert_memory_equal(tmp2, expected2, sizeof(expected2));
-
- uint8_t tmp4[4] = {0};
-
- uint8_t expected4[4] = {0x01, 0x3B, 0xAC, 0xC7};
- write_u32_be(tmp4, 0, (uint32_t) 20688071UL);
- assert_memory_equal(tmp4, expected4, sizeof(expected4));
-
- memset(tmp4, 0, sizeof(tmp4));
- expected4[0] = 0xC7;
- expected4[1] = 0xAC;
- expected4[2] = 0x3B;
- expected4[3] = 0x01;
- write_u32_le(tmp4, 0, (uint32_t) 20688071UL);
- assert_memory_equal(tmp4, expected4, sizeof(expected4));
-
- uint8_t tmp8[8] = {0};
-
- uint8_t expected8[8] = {0xEB, 0x68, 0x44, 0xC0, 0x2C, 0x61, 0xB0, 0x99};
- write_u64_be(tmp8, 0, (uint64_t) 16962883588659982489ULL);
- assert_memory_equal(tmp8, expected8, sizeof(expected8));
-
- memset(tmp8, 0, sizeof(tmp8));
- expected8[0] = 0x99;
- expected8[1] = 0xB0;
- expected8[2] = 0x61;
- expected8[3] = 0x2C;
- expected8[4] = 0xC0;
- expected8[5] = 0x44;
- expected8[6] = 0x68;
- expected8[7] = 0xEB;
- write_u64_le(tmp8, 0, (uint64_t) 16962883588659982489ULL);
- assert_memory_equal(tmp8, expected8, sizeof(expected8));
-}
-
-int main() {
- const struct CMUnitTest tests[] = {cmocka_unit_test(test_write)};
-
- return cmocka_run_group_tests(tests, NULL, NULL);
-}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.