commit 247a16abaee56a518bb41be83462ea0bd4eb3447
parent ee2b6de9ec08a00a123da039c4576597ed9a271c
Author: Florian Dold <dold@taler.net>
Date: Tue, 21 Jul 2026 02:24:26 +0200
util: test that object codecs decode coin_sig and filterByState
Diffstat:
1 file changed, 42 insertions(+), 0 deletions(-)
diff --git a/packages/taler-util/src/codec-object-fields.test.ts b/packages/taler-util/src/codec-object-fields.test.ts
@@ -0,0 +1,42 @@
+/*
+ This file is part of GNU Taler
+ (C) 2024 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+import { test } from "node:test";
+import assert from "node:assert";
+// Imported through the package barrel: types-taler-wallet-transactions.js pulls
+// in a circular dependency that only resolves when index.js is the entry point.
+import {
+ codecForPurseDepositConflict,
+ codecForTransactionsRequest,
+} from "./index.js";
+
+test("codecForPurseDepositConflict decodes coin_sig", (t) => {
+ const decoded = codecForPurseDepositConflict().decode({
+ code: 1234,
+ coin_pub: "COINPUB",
+ coin_sig: "COINSIG",
+ amount: "KUDOS:10",
+ });
+ // coin_sig is the proof the wallet needs to verify; it must not be dropped.
+ assert.strictEqual((decoded as any).coin_sig, "COINSIG");
+});
+
+test("codecForTransactionsRequest decodes filterByState", (t) => {
+ const decoded = codecForTransactionsRequest().decode({
+ filterByState: "nonfinal",
+ });
+ assert.strictEqual(decoded.filterByState, "nonfinal");
+});