commit 6b4c5fccf44038daf3a66b13697fc6b716a480fa
parent 3f19ec22a29b78ac904151005afd7708b72e1beb
Author: Florian Dold <dold@taler.net>
Date: Wed, 22 Jul 2026 15:43:51 +0200
wallet: test which wire account a deposit restriction rejects
Covers an account that accepts the deposit target and one that denies it,
including the restrictions reported back for the rejected account.
Diffstat:
1 file changed, 59 insertions(+), 0 deletions(-)
diff --git a/packages/taler-wallet-core/src/coinSelection.test.ts b/packages/taler-wallet-core/src/coinSelection.test.ts
@@ -16,6 +16,7 @@
import {
AbsoluteTime,
AmountJson,
+ AccountRestriction,
AmountString,
Amounts,
DenomKeyType,
@@ -24,12 +25,14 @@ import {
TalerProtocolTimestamp,
j2s,
} from "@gnu-taler/taler-util";
+import { WireInfo } from "@gnu-taler/taler-util";
import { test } from "node:test";
import assert from "node:assert";
import {
AvailableCoinsOfDenom,
CoinSelectionTally,
emptyTallyForPeerPayment,
+ findMatchingWire,
testing_getMaxDepositAmountForAvailableCoins,
testing_getMaxPeerPushDebitAmountForAvailableCoins,
testing_selectGreedy,
@@ -646,3 +649,59 @@ test("peer push debit max ignores coins that cost more to deposit than they are
Amounts.stringifyValue(withoutDust.rawAmount),
);
});
+
+function wireInfoWithRestrictions(
+ restrictions: AccountRestriction[],
+): { wireInfo: WireInfo } {
+ return {
+ wireInfo: {
+ accounts: [
+ {
+ payto_uri: "payto://iban/DE76500202009817493529",
+ master_sig: "DUMMY",
+ credit_restrictions: [],
+ debit_restrictions: restrictions,
+ },
+ ],
+ feesForType: {
+ iban: [
+ {
+ wireFee: "KUDOS:0.01" as AmountString,
+ closingFee: "KUDOS:0.01" as AmountString,
+ startStamp: inThePast,
+ endStamp: inTheDistantFuture,
+ sig: "DUMMY",
+ },
+ ],
+ },
+ },
+ };
+}
+
+test("a wire account without restrictions matches", (t) => {
+ const res = findMatchingWire(
+ "iban",
+ "payto://iban/CH62414246VCSW2LM4FG0",
+ wireInfoWithRestrictions([]),
+ );
+ assert.ok(res);
+ assert.strictEqual(res.ok, true);
+});
+
+test("a rejected wire account reports the restrictions that rejected it", (t) => {
+ const restrictions: AccountRestriction[] = [
+ { type: "deny" },
+ ];
+ const res = findMatchingWire(
+ "iban",
+ "payto://iban/CH62414246VCSW2LM4FG0",
+ wireInfoWithRestrictions(restrictions),
+ );
+ assert.ok(res);
+ assert.strictEqual(res.ok, false);
+ if (res.ok === false) {
+ assert.deepStrictEqual(res.accountRestrictions, {
+ "payto://iban/DE76500202009817493529": restrictions,
+ });
+ }
+});