diff options
Diffstat (limited to 'packages/taler-harness/src')
-rw-r--r-- | packages/taler-harness/src/integrationtests/test-wallet-refresh.ts | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/packages/taler-harness/src/integrationtests/test-wallet-refresh.ts b/packages/taler-harness/src/integrationtests/test-wallet-refresh.ts index b86dfadcf..f1c544a4e 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-refresh.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-refresh.ts @@ -20,12 +20,15 @@ import { AmountString, NotificationType, + TransactionIdStr, TransactionMajorState, TransactionType, j2s, } from "@gnu-taler/taler-util"; -import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { parseTransactionIdentifier } from "../../../taler-wallet-core/src/transactions.js"; +import { + WalletApiOperation, + parseTransactionIdentifier, +} from "@gnu-taler/taler-wallet-core"; import { GlobalTestState, generateRandomPayto } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, @@ -139,6 +142,59 @@ export async function runWalletRefreshTest(t: GlobalTestState) { bal2.balances[0].available, ); } + + const wres = await withdrawViaBankV2(t, { + walletClient, + bank, + exchange, + amount: "TESTKUDOS:20", + }); + + await wres.withdrawalFinishedCond; + + // Test failing a refresh transaction + { + await exchange.stop(); + + let refreshTransactionId: TransactionIdStr | undefined = undefined; + + const refreshCreatedCond = walletClient.waitForNotificationCond((x) => { + if ( + x.type === NotificationType.TransactionStateTransition && + parseTransactionIdentifier(x.transactionId)?.tag === + TransactionType.Refresh + ) { + refreshTransactionId = x.transactionId as TransactionIdStr; + return true; + } + return false; + }); + + const depositGroupResult = await walletClient.client.call( + WalletApiOperation.CreateDepositGroup, + { + amount: "TESTKUDOS:10.5" as AmountString, + depositPaytoUri: generateRandomPayto("foo"), + }, + ); + + await refreshCreatedCond; + + t.assertTrue(!!refreshTransactionId); + + await walletClient.call(WalletApiOperation.FailTransaction, { + transactionId: refreshTransactionId, + }); + + const txn = await walletClient.call(WalletApiOperation.GetTransactionById, { + transactionId: refreshTransactionId, + }); + + t.assertDeepEqual(txn.type, TransactionType.Refresh); + t.assertDeepEqual(txn.txState.major, TransactionMajorState.Failed); + + t.assertTrue(!!refreshTransactionId); + } } runWalletRefreshTest.suites = ["wallet"]; |