commit 60aa552c12207f7ef379d685a27fce336e6c26bb
parent 9c7f95e72913c686d29d286b6cf69873e9edbb52
Author: Florian Dold <dold@taler.net>
Date: Sun, 9 Aug 2026 21:19:17 +0200
test: cover native edge cases and lifecycle
Diffstat:
3 files changed, 90 insertions(+), 0 deletions(-)
diff --git a/meson.build b/meson.build
@@ -295,4 +295,17 @@ if not meson.is_cross_build()
wallet_client_example_exe = executable('wallet-client-example',
'wallet-client-example.c',
link_with : [talerwalletcore_lib])
+
+ wallet_lifecycle_test = executable('test-wallet-lifecycle',
+ 'tests/test_wallet_lifecycle.c',
+ link_with : [talerwalletcore_lib])
+
+ test('prelude', qtart_exe,
+ args : [files('tests/test_prelude.js')])
+ test('sqlite3', qtart_exe,
+ args : [files('tests/test_sqlite3_error.js')])
+ test('tart-inputs', qtart_exe,
+ args : [files('tests/test_tart_inputs.js')])
+ test('wallet-lifecycle', wallet_lifecycle_test,
+ timeout : 60)
endif
diff --git a/tests/test_tart_inputs.js b/tests/test_tart_inputs.js
@@ -0,0 +1,31 @@
+import * as tart from "tart";
+
+function assert(condition, message) {
+ if (!condition) {
+ throw new Error(message);
+ }
+}
+
+function expectThrow(fn, message) {
+ let threw = false;
+ try {
+ fn();
+ } catch (_) {
+ threw = true;
+ }
+ assert(threw, message);
+}
+
+assert(tart.decodeCrock("").byteLength === 0,
+ "empty Crockford input must decode to an empty byte array");
+assert(tart.randomBytes(1024 * 1024).byteLength === 1024 * 1024,
+ "randomBytes must support heap-sized outputs");
+
+const hashState = tart.hashStateInit();
+expectThrow(() => tart.hashStateUpdate(hashState, "not a buffer"),
+ "hashStateUpdate must reject non-buffer input");
+expectThrow(() => tart.kdf(8161, new Uint8Array(1)),
+ "HKDF output beyond the RFC limit must be rejected");
+expectThrow(() => tart.rsaBlind(new Uint8Array(64), new Uint8Array(32),
+ new Uint8Array(4)),
+ "malformed RSA public keys must be rejected");
diff --git a/tests/test_wallet_lifecycle.c b/tests/test_wallet_lifecycle.c
@@ -0,0 +1,46 @@
+#include "taler_wallet_core_lib.h"
+
+#include <stddef.h>
+
+static void ignore_log(void *cls,
+ enum TALER_WALLET_LogLevel level,
+ const char *tag,
+ const char *msg)
+{
+ (void) cls;
+ (void) level;
+ (void) tag;
+ (void) msg;
+}
+
+int main(void)
+{
+ struct TALER_WALLET_Instance *first = TALER_WALLET_create();
+ struct TALER_WALLET_Instance *second = TALER_WALLET_create();
+
+ if (!first || !second) {
+ return 1;
+ }
+ if (TALER_WALLET_send_request(first, "{}") == 0) {
+ return 2;
+ }
+
+ TALER_WALLET_set_log_handler(first, ignore_log, NULL);
+ TALER_WALLET_set_log_handler(second, ignore_log, NULL);
+ TALER_set_curl_http_client(first);
+ TALER_set_curl_http_client(second);
+
+ if (TALER_WALLET_run(first) != 0 || TALER_WALLET_run(second) != 0) {
+ return 3;
+ }
+ if (TALER_WALLET_send_request(first,
+ "{\"id\":1,\"operation\":\"getVersion\",\"args\":{}}") != 0 ||
+ TALER_WALLET_send_request(second,
+ "{\"id\":2,\"operation\":\"getVersion\",\"args\":{}}") != 0) {
+ return 4;
+ }
+
+ TALER_WALLET_destroy(first);
+ TALER_WALLET_destroy(second);
+ return 0;
+}