commit 5c468e88ce8226d77377dc2eb38276bbd6491d65
parent 38e380c5c0ae4db1ab5124dc975138ba89f2dc2a
Author: Florian Dold <florian@dold.me>
Date: Fri, 13 Mar 2026 17:34:02 +0100
harness: remove legacy assertion
Diffstat:
8 files changed, 177 insertions(+), 168 deletions(-)
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts
@@ -330,25 +330,6 @@ export class GlobalTestState {
logger.info(`STEP: ${stepEnd}`);
}
- /**
- * @deprecated use {@link assertThrowsTalerErrorAsync} instead
- */
- async assertThrowsTalerErrorAsyncLegacy(
- block: Promise<unknown>,
- ): Promise<TalerError> {
- try {
- await block;
- } catch (e) {
- if (e instanceof TalerError) {
- return e;
- }
- throw Error(`expected TalerError to be thrown, but got ${e}`);
- }
- throw Error(
- `expected TalerError to be thrown, but block finished without throwing`,
- );
- }
-
async assertThrowsTalerErrorAsync(
block: () => Promise<unknown>,
): Promise<TalerError> {
diff --git a/packages/taler-harness/src/integrationtests/test-account-restrictions.ts b/packages/taler-harness/src/integrationtests/test-account-restrictions.ts
@@ -28,14 +28,14 @@ import {
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import {
+ createSimpleTestkudosEnvironmentV3,
+ WithdrawViaBankResult,
+} from "../harness/environments.js";
+import {
ExchangeServiceInterface,
GlobalTestState,
WalletClient,
} from "../harness/harness.js";
-import {
- createSimpleTestkudosEnvironmentV3,
- WithdrawViaBankResult,
-} from "../harness/environments.js";
const logger = new Logger("test-account-restrictions.ts");
@@ -90,11 +90,11 @@ export async function runAccountRestrictionsTest(t: GlobalTestState) {
});
// Invalid account, does not start with "foo-"
- const err = await t.assertThrowsTalerErrorAsyncLegacy(
+ const err = await t.assertThrowsTalerErrorAsync(() =>
walletClient.call(WalletApiOperation.CheckDeposit, {
amount: "TESTKUDOS:5",
depositPaytoUri: "payto://x-taler-bank/localhost/bar-42",
- })
+ }),
);
logger.info(`checkResp ${j2s(err)}`);
diff --git a/packages/taler-harness/src/integrationtests/test-bank-api.ts b/packages/taler-harness/src/integrationtests/test-bank-api.ts
@@ -19,7 +19,6 @@
*/
import {
CreditDebitIndicator,
- MerchantAuthMethod,
TalerCorebankApiClient,
TalerWireGatewayHttpClient,
createEddsaKeyPair,
@@ -31,7 +30,6 @@ import {
BankService,
ExchangeService,
GlobalTestState,
- MERCHANT_DEFAULT_AUTH,
MerchantService,
getTestHarnessPaytoForLabel,
setupDb,
@@ -100,19 +98,23 @@ export async function runBankApiTest(t: GlobalTestState) {
await merchant.start();
await merchant.pingUntilAvailable();
- setPrintHttpRequestAsCurl(true)
+ setPrintHttpRequestAsCurl(true);
- const { accessToken: adminAccessToken } = await merchant.addInstanceWithWireAccount({
- id: "admin",
- name: "Default Instance",
- paytoUris: [getTestHarnessPaytoForLabel("merchant-default")],
- });
+ const { accessToken: adminAccessToken } =
+ await merchant.addInstanceWithWireAccount({
+ id: "admin",
+ name: "Default Instance",
+ paytoUris: [getTestHarnessPaytoForLabel("merchant-default")],
+ });
- await merchant.addInstanceWithWireAccount({
- id: "minst1",
- name: "minst1",
- paytoUris: [getTestHarnessPaytoForLabel("minst1")],
- }, { adminAccessToken });
+ await merchant.addInstanceWithWireAccount(
+ {
+ id: "minst1",
+ name: "minst1",
+ paytoUris: [getTestHarnessPaytoForLabel("minst1")],
+ },
+ { adminAccessToken },
+ );
console.log("setup done!");
@@ -135,7 +137,7 @@ export async function runBankApiTest(t: GlobalTestState) {
// Make sure that registering twice results in a 409 Conflict
{
- const e = await t.assertThrowsTalerErrorAsyncLegacy(
+ const e = await t.assertThrowsTalerErrorAsync(() =>
bankClient.registerAccount("user1", "password2"),
);
t.assertTrue(e.errorDetail.httpStatusCode === 409);
diff --git a/packages/taler-harness/src/integrationtests/test-exchange-management-fault.ts b/packages/taler-harness/src/integrationtests/test-exchange-management-fault.ts
@@ -109,17 +109,21 @@ export async function runExchangeManagementFaultTest(
await merchant.start();
await merchant.pingUntilAvailable();
- const { accessToken: adminAccessToken } = await merchant.addInstanceWithWireAccount({
- id: "admin",
- name: "Default Instance",
- paytoUris: [getTestHarnessPaytoForLabel("merchant-default")],
- });
-
- await merchant.addInstanceWithWireAccount({
- id: "minst1",
- name: "minst1",
- paytoUris: [getTestHarnessPaytoForLabel("minst1")],
- }, {adminAccessToken});
+ const { accessToken: adminAccessToken } =
+ await merchant.addInstanceWithWireAccount({
+ id: "admin",
+ name: "Default Instance",
+ paytoUris: [getTestHarnessPaytoForLabel("merchant-default")],
+ });
+
+ await merchant.addInstanceWithWireAccount(
+ {
+ id: "minst1",
+ name: "minst1",
+ paytoUris: [getTestHarnessPaytoForLabel("minst1")],
+ },
+ { adminAccessToken },
+ );
console.log("setup done!");
@@ -191,7 +195,7 @@ export async function runExchangeManagementFaultTest(
},
});
- const err1 = await t.assertThrowsTalerErrorAsyncLegacy(
+ const err1 = await t.assertThrowsTalerErrorAsync(() =>
wallet.client.call(WalletApiOperation.AddExchange, {
exchangeBaseUrl: faultyExchange.baseUrl,
}),
@@ -239,7 +243,7 @@ export async function runExchangeManagementFaultTest(
},
});
- const err2 = await t.assertThrowsTalerErrorAsyncLegacy(
+ const err2 = await t.assertThrowsTalerErrorAsync(() =>
wallet.client.call(WalletApiOperation.AddExchange, {
exchangeBaseUrl: faultyExchange.baseUrl,
}),
diff --git a/packages/taler-harness/src/integrationtests/test-exchange-master-pub-change.ts b/packages/taler-harness/src/integrationtests/test-exchange-master-pub-change.ts
@@ -85,7 +85,7 @@ export async function runExchangeMasterPubChangeTest(
t.logStep("exchange-restarted");
- const err = await t.assertThrowsTalerErrorAsyncLegacy(
+ const err = await t.assertThrowsTalerErrorAsync(async () =>
walletClient.call(WalletApiOperation.UpdateExchangeEntry, {
exchangeBaseUrl: exchange.baseUrl,
force: true,
diff --git a/packages/taler-harness/src/integrationtests/test-peer-pull.ts b/packages/taler-harness/src/integrationtests/test-peer-pull.ts
@@ -30,16 +30,10 @@ import {
createWalletDaemonWithClient,
withdrawViaBankV3,
} from "../harness/environments.js";
-import {
- GlobalTestState,
- WalletClient,
-} from "../harness/harness.js";
+import { GlobalTestState, WalletClient } from "../harness/harness.js";
const purse_expiration = AbsoluteTime.toProtocolTimestamp(
- AbsoluteTime.addDuration(
- AbsoluteTime.now(),
- Duration.fromSpec({ days: 2 }),
- ),
+ AbsoluteTime.addDuration(AbsoluteTime.now(), Duration.fromSpec({ days: 2 })),
);
/**
@@ -54,28 +48,33 @@ export async function runPeerPullTest(t: GlobalTestState) {
] = await Promise.all([
createSimpleTestkudosEnvironmentV3(t),
createWalletDaemonWithClient(t, {
- name: "w2"
+ name: "w2",
}),
createWalletDaemonWithClient(t, {
- name: "w3"
+ name: "w3",
}),
createWalletDaemonWithClient(t, {
- name: "w4"
- })
+ name: "w4",
+ }),
]);
// Withdraw digital cash into the wallet.
- await Promise.all([wallet1, wallet2, wallet3, wallet4].map(async w => {
- const withdrawRes = await withdrawViaBankV3(t, {
- walletClient: w,
- bankClient,
- exchange,
- amount: "TESTKUDOS:20",
- });
- await withdrawRes.withdrawalFinishedCond;
- }));
+ await Promise.all(
+ [wallet1, wallet2, wallet3, wallet4].map(async (w) => {
+ const withdrawRes = await withdrawViaBankV3(t, {
+ walletClient: w,
+ bankClient,
+ exchange,
+ amount: "TESTKUDOS:20",
+ });
+ await withdrawRes.withdrawalFinishedCond;
+ }),
+ );
- async function initPeerPullCredit(summary: string, amount: AmountString = "TESTKUDOS:2"): Promise<TransactionPeerPullCredit> {
+ async function initPeerPullCredit(
+ summary: string,
+ amount: AmountString = "TESTKUDOS:2",
+ ): Promise<TransactionPeerPullCredit> {
const initiate = await wallet1.call(
WalletApiOperation.InitiatePeerPullCredit,
{
@@ -92,7 +91,7 @@ export async function runPeerPullTest(t: GlobalTestState) {
transactionId: initiate.transactionId,
txState: {
major: TransactionMajorState.Pending,
- minor: TransactionMinorState.Ready
+ minor: TransactionMinorState.Ready,
},
});
@@ -100,32 +99,23 @@ export async function runPeerPullTest(t: GlobalTestState) {
transactionId: initiate.transactionId,
});
t.assertDeepEqual(tx.type, TransactionType.PeerPullCredit);
- return tx
+ return tx;
}
t.logStep("P2P pull amount logic");
{
await wallet1.call(WalletApiOperation.AddExchange, {
- exchangeBaseUrl: exchange.baseUrl
+ exchangeBaseUrl: exchange.baseUrl,
});
- const [
- checkfive,
- checkzero
- ] = await Promise.all([
- wallet1.call(
- WalletApiOperation.CheckPeerPullCredit,
- {
- amount: "TESTKUDOS:5",
- exchangeBaseUrl: exchange.baseUrl,
- },
- ),
- wallet1.call(
- WalletApiOperation.CheckPeerPullCredit,
- {
- amount: "TESTKUDOS:0",
- exchangeBaseUrl: exchange.baseUrl,
- },
- ),
+ const [checkfive, checkzero] = await Promise.all([
+ wallet1.call(WalletApiOperation.CheckPeerPullCredit, {
+ amount: "TESTKUDOS:5",
+ exchangeBaseUrl: exchange.baseUrl,
+ }),
+ wallet1.call(WalletApiOperation.CheckPeerPullCredit, {
+ amount: "TESTKUDOS:0",
+ exchangeBaseUrl: exchange.baseUrl,
+ }),
]);
t.assertDeepEqual(checkfive.amountRaw, "TESTKUDOS:5");
@@ -138,34 +128,45 @@ export async function runPeerPullTest(t: GlobalTestState) {
t.logStep("P2P pull errors");
{
const tx = await initPeerPullCredit("confirm", "TESTKUDOS:1000");
- const insufficient_balance = await t.assertThrowsTalerErrorAsyncLegacy(wallet1.call(
- WalletApiOperation.PreparePeerPullDebit,
- { talerUri: tx.talerUri! }
- ));
- t.assertTrue(insufficient_balance.errorDetail.code === TalerErrorCode.WALLET_PEER_PUSH_PAYMENT_INSUFFICIENT_BALANCE);
+ const insufficient_balance = await t.assertThrowsTalerErrorAsync(async () =>
+ wallet1.call(WalletApiOperation.PreparePeerPullDebit, {
+ talerUri: tx.talerUri!,
+ }),
+ );
+ t.assertTrue(
+ insufficient_balance.errorDetail.code ===
+ TalerErrorCode.WALLET_PEER_PUSH_PAYMENT_INSUFFICIENT_BALANCE,
+ );
- const unknown_purse = await t.assertThrowsTalerErrorAsyncLegacy(wallet1.call(
- WalletApiOperation.PreparePeerPullDebit,
- { talerUri: "taler+http://pay-pull/localhost:8081/MQP1DP1J94ZZWNQS7TRDF1KJZ7V8H74CZF41V90FKXBPN5GNRN6G" }
- ));
+ const unknown_purse = await t.assertThrowsTalerErrorAsync(async () =>
+ wallet1.call(WalletApiOperation.PreparePeerPullDebit, {
+ talerUri:
+ "taler+http://pay-pull/localhost:8081/MQP1DP1J94ZZWNQS7TRDF1KJZ7V8H74CZF41V90FKXBPN5GNRN6G",
+ }),
+ );
// FIXME this should fail with a proper error code
- t.assertTrue(unknown_purse.errorDetail.code === TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION);
+ t.assertTrue(
+ unknown_purse.errorDetail.code ===
+ TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
+ );
}
t.logStep("P2P pull confirm");
{
const tx = await initPeerPullCredit("confirm");
- const [prepare2, prepare3, prepare4] = await Promise.all([wallet2, wallet3, wallet4].map(w =>
- w.call(
- WalletApiOperation.PreparePeerPullDebit,
- { talerUri: tx.talerUri! }
- ))
+ const [prepare2, prepare3, prepare4] = await Promise.all(
+ [wallet2, wallet3, wallet4].map((w) =>
+ w.call(WalletApiOperation.PreparePeerPullDebit, {
+ talerUri: tx.talerUri!,
+ }),
+ ),
);
{
- const idempotent = await wallet2.call(WalletApiOperation.PreparePeerPullDebit,
- { talerUri: tx.talerUri! }
+ const idempotent = await wallet2.call(
+ WalletApiOperation.PreparePeerPullDebit,
+ { talerUri: tx.talerUri! },
);
t.assertTrue(prepare2.transactionId === idempotent.transactionId);
}
@@ -214,12 +215,16 @@ export async function runPeerPullTest(t: GlobalTestState) {
}),
]);
- const completed_purse = await t.assertThrowsTalerErrorAsyncLegacy(wallet1.call(
- WalletApiOperation.PreparePeerPullDebit,
- { talerUri: tx.talerUri! }
- ));
+ const completed_purse = await t.assertThrowsTalerErrorAsync(async () =>
+ wallet1.call(WalletApiOperation.PreparePeerPullDebit, {
+ talerUri: tx.talerUri!,
+ }),
+ );
// FIXME this should fail with a proper error code
- t.assertTrue(completed_purse.errorDetail.code === TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION);
+ t.assertTrue(
+ completed_purse.errorDetail.code ===
+ TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
+ );
}
t.logStep("P2P pull self");
@@ -227,11 +232,11 @@ export async function runPeerPullTest(t: GlobalTestState) {
const tx = await initPeerPullCredit("self");
const prepare = await wallet1.call(
WalletApiOperation.PreparePeerPullDebit,
- { talerUri: tx.talerUri! }
+ { talerUri: tx.talerUri! },
);
await wallet1.call(WalletApiOperation.ConfirmPeerPullDebit, {
transactionId: prepare.transactionId,
- })
+ });
await Promise.all([
wallet1.call(WalletApiOperation.TestingWaitTransactionState, {
transactionId: tx.transactionId,
@@ -248,8 +253,9 @@ export async function runPeerPullTest(t: GlobalTestState) {
]);
// Check scan after completion
- const idempotent = await wallet1.call(WalletApiOperation.PreparePeerPullDebit,
- { talerUri: tx.talerUri! }
+ const idempotent = await wallet1.call(
+ WalletApiOperation.PreparePeerPullDebit,
+ { talerUri: tx.talerUri! },
);
t.assertTrue(prepare.transactionId === idempotent.transactionId);
}
@@ -258,11 +264,12 @@ export async function runPeerPullTest(t: GlobalTestState) {
{
const tx = await initPeerPullCredit("conflict");
- const [prepare2, prepare3] = await Promise.all([wallet2, wallet3].map(w =>
- w.call(
- WalletApiOperation.PreparePeerPullDebit,
- { talerUri: tx.talerUri! }
- ))
+ const [prepare2, prepare3] = await Promise.all(
+ [wallet2, wallet3].map((w) =>
+ w.call(WalletApiOperation.PreparePeerPullDebit, {
+ talerUri: tx.talerUri!,
+ }),
+ ),
);
await exchange.stop();
@@ -276,7 +283,7 @@ export async function runPeerPullTest(t: GlobalTestState) {
}),
]);
- await exchange.start()
+ await exchange.start();
await Promise.all([
wallet1.call(WalletApiOperation.TestingWaitTransactionState, {
transactionId: tx.transactionId,
@@ -312,8 +319,8 @@ export async function runPeerPullTest(t: GlobalTestState) {
major: TransactionMajorState.Done,
},
}),
- ])
- ])
+ ]),
+ ]),
]);
}
@@ -321,12 +328,13 @@ export async function runPeerPullTest(t: GlobalTestState) {
{
const tx = await initPeerPullCredit("abort");
- const [prepare2, prepare3] = await Promise.all([wallet2, wallet3].map(w =>
- w.call(
- WalletApiOperation.PreparePeerPullDebit,
- { talerUri: tx.talerUri! }
- )
- ));
+ const [prepare2, prepare3] = await Promise.all(
+ [wallet2, wallet3].map((w) =>
+ w.call(WalletApiOperation.PreparePeerPullDebit, {
+ talerUri: tx.talerUri!,
+ }),
+ ),
+ );
await wallet1.call(WalletApiOperation.AbortTransaction, {
transactionId: tx.transactionId,
@@ -352,17 +360,21 @@ export async function runPeerPullTest(t: GlobalTestState) {
wallet3.call(WalletApiOperation.TestingWaitTransactionState, {
transactionId: prepare3.transactionId,
txState: {
- major: TransactionMajorState.Aborted
+ major: TransactionMajorState.Aborted,
},
}),
]);
- const aborted_contract = await t.assertThrowsTalerErrorAsyncLegacy(wallet1.call(
- WalletApiOperation.PreparePeerPullDebit,
- { talerUri: tx.talerUri! }
- ));
+ const aborted_contract = await t.assertThrowsTalerErrorAsync(() =>
+ wallet1.call(WalletApiOperation.PreparePeerPullDebit, {
+ talerUri: tx.talerUri!,
+ }),
+ );
// FIXME this should fail with a proper error code
- t.assertTrue(aborted_contract.errorDetail.code === TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION);
+ t.assertTrue(
+ aborted_contract.errorDetail.code ===
+ TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
+ );
}
t.logStep("P2P pull abort before create purse");
@@ -406,12 +418,13 @@ export async function runPeerPullTest(t: GlobalTestState) {
{
const tx = await initPeerPullCredit("expire");
- const [prepare2, prepare3] = await Promise.all([wallet2, wallet3].map(w =>
- w.call(
- WalletApiOperation.PreparePeerPullDebit,
- { talerUri: tx.talerUri! }
- )
- ));
+ const [prepare2, prepare3] = await Promise.all(
+ [wallet2, wallet3].map((w) =>
+ w.call(WalletApiOperation.PreparePeerPullDebit, {
+ talerUri: tx.talerUri!,
+ }),
+ ),
+ );
const timetravelOffsetMs = Duration.toMilliseconds(
Duration.fromSpec({ days: 5 }),
@@ -421,11 +434,13 @@ export async function runPeerPullTest(t: GlobalTestState) {
exchange.setTimetravel(timetravelOffsetMs);
await Promise.all([exchange.start(), exchange.runExpireOnce()]);
- await Promise.all([wallet1, wallet2, wallet3].map(w =>
- w.call(WalletApiOperation.TestingSetTimetravel, {
- offsetMs: timetravelOffsetMs,
- })
- ));
+ await Promise.all(
+ [wallet1, wallet2, wallet3].map((w) =>
+ w.call(WalletApiOperation.TestingSetTimetravel, {
+ offsetMs: timetravelOffsetMs,
+ }),
+ ),
+ );
await wallet2.call(WalletApiOperation.ConfirmPeerPullDebit, {
transactionId: prepare2.transactionId,
@@ -452,11 +467,15 @@ export async function runPeerPullTest(t: GlobalTestState) {
}),
]);
- const expired_purse = await t.assertThrowsTalerErrorAsyncLegacy(wallet1.call(
- WalletApiOperation.PreparePeerPullDebit,
- { talerUri: tx.talerUri! }
- ));
- t.assertTrue(expired_purse.errorDetail.code === TalerErrorCode.WALLET_PEER_PULL_DEBIT_PURSE_GONE);
+ const expired_purse = await t.assertThrowsTalerErrorAsync(() =>
+ wallet1.call(WalletApiOperation.PreparePeerPullDebit, {
+ talerUri: tx.talerUri!,
+ }),
+ );
+ t.assertTrue(
+ expired_purse.errorDetail.code ===
+ TalerErrorCode.WALLET_PEER_PULL_DEBIT_PURSE_GONE,
+ );
}
await t.runSpanAsync("P2P pull delete", async () => {
@@ -474,7 +493,7 @@ export async function runPeerPullTest(t: GlobalTestState) {
});
t.assertDeepEqual(txn2.transactions.length, 0);
};
- await Promise.all([wallet1, wallet2, wallet3, wallet4].map(delAll))
+ await Promise.all([wallet1, wallet2, wallet3, wallet4].map(delAll));
});
}
diff --git a/packages/taler-harness/src/integrationtests/test-wallet-devexp-fakeprotover.ts b/packages/taler-harness/src/integrationtests/test-wallet-devexp-fakeprotover.ts
@@ -18,7 +18,6 @@
* Imports.
*/
import {
- j2s,
LibtoolVersion,
Logger,
succeedOrThrow,
@@ -77,7 +76,7 @@ export async function runWalletDevexpFakeprotoverTest(t: GlobalTestState) {
logger.info("updating exchange entry after dev experiment");
- const err1 = await t.assertThrowsTalerErrorAsyncLegacy(
+ const err1 = await t.assertThrowsTalerErrorAsync(async () =>
walletClient.call(WalletApiOperation.UpdateExchangeEntry, {
exchangeBaseUrl: exchange.baseUrl,
force: true,
@@ -95,7 +94,7 @@ export async function runWalletDevexpFakeprotoverTest(t: GlobalTestState) {
logger.info("done updating exchange entry after dev experiment");
- const err2 = await t.assertThrowsTalerErrorAsyncLegacy(
+ const err2 = await t.assertThrowsTalerErrorAsync(async () =>
walletClient.call(WalletApiOperation.GetWithdrawalDetailsForAmount, {
amount: "TESTKUDOS:10",
exchangeBaseUrl: exchange.baseUrl,
diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-abort-bank.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-abort-bank.ts
@@ -19,8 +19,8 @@
*/
import { TalerErrorCode } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import { GlobalTestState } from "../harness/harness.js";
import { createSimpleTestkudosEnvironmentV3 } from "../harness/environments.js";
+import { GlobalTestState } from "../harness/harness.js";
/**
* Run test for basic, bank-integrated withdrawal.
@@ -60,11 +60,15 @@ export async function runWithdrawalAbortBankTest(t: GlobalTestState) {
//
// WHY ?!
//
- const e = await t.assertThrowsTalerErrorAsyncLegacy(
- walletClient.call(WalletApiOperation.AcceptBankIntegratedWithdrawal, {
- exchangeBaseUrl: exchange.baseUrl,
- talerWithdrawUri: wop.taler_withdraw_uri,
- })
+ const e = await t.assertThrowsTalerErrorAsync(
+ async () =>
+ await walletClient.call(
+ WalletApiOperation.AcceptBankIntegratedWithdrawal,
+ {
+ exchangeBaseUrl: exchange.baseUrl,
+ talerWithdrawUri: wop.taler_withdraw_uri,
+ },
+ ),
);
t.assertDeepEqual(
e.errorDetail.code,