diff options
Diffstat (limited to 'packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts')
-rw-r--r-- | packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts index e6c84b75d..046bd5aed 100644 --- a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts +++ b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts @@ -24,11 +24,12 @@ import { NotificationType, PreparePayResultType, TalerCorebankApiClient, + j2s, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { makeNoFeeCoinConfig } from "../harness/denomStructures.js"; import { - BankService, + BankService, ExchangeService, GlobalTestState, MerchantService, @@ -78,7 +79,10 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { await exchange.addBankAccount("1", { accountName: exchangeBankUsername, accountPassword: exchangeBankPassword, - wireGatewayApiBaseUrl: new URL("accounts/exchange/taler-wire-gateway/", bank.baseUrl).href, + wireGatewayApiBaseUrl: new URL( + "accounts/exchange/taler-wire-gateway/", + bank.baseUrl, + ).href, accountPaytoUri: exchangePaytoUri, }); @@ -129,29 +133,42 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { const { walletClient } = await createWalletDaemonWithClient(t, { name: "w1", + persistent: true, }); const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl()); - // Withdraw digital cash into the wallet. + t.logStep("exchangeUpdated1Cond"); + // Withdraw digital cash into the wallet. + t.logStep("Withdraw digital cash into the wallet."); const wres = await withdrawViaBankV3(t, { walletClient, bankClient, exchange, amount: "TESTKUDOS:15", }); + t.logStep("wait"); await wres.withdrawalFinishedCond; - const exchangeUpdated1Cond = walletClient.waitForNotificationCond( (x) => - x.type === NotificationType.ExchangeStateTransition && - x.exchangeBaseUrl === exchange.baseUrl, + { + t.logStep(`EXCHANGE UPDATE, ${j2s(x)}`) + return x.type === NotificationType.ExchangeStateTransition && + x.exchangeBaseUrl === exchange.baseUrl + } ); + t.logStep("waiting tx"); + await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); + { + const balance = await walletClient.call(WalletApiOperation.GetBalances, {}); + t.assertAmountEquals(balance.balances[0].available, "TESTKUDOS:15"); + } + // Travel into the future, the deposit expiration is two years // into the future. - console.log("applying first time travel"); + t.logStep("applying first time travel"); await applyTimeTravelV2( Duration.toMilliseconds(Duration.fromSpec({ days: 400 })), { @@ -162,9 +179,16 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { ); // The time travel should cause exchanges to update. + t.logStep("The time travel should cause exchanges to update"); await exchangeUpdated1Cond; + t.logStep("exchange updated, waiting for tx"); await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); + { + const balance = await walletClient.call(WalletApiOperation.GetBalances, {}); + t.assertAmountEquals(balance.balances[0].available, "TESTKUDOS:15"); + } + t.logStep("withdrawing second time"); const wres2 = await withdrawViaBankV3(t, { walletClient, bankClient, @@ -173,8 +197,14 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { }); await wres2.withdrawalFinishedCond; + t.logStep("witdrawn, waiting tx"); await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); + { + const balance = await walletClient.call(WalletApiOperation.GetBalances, {}); + t.assertAmountEquals(balance.balances[0].available, "TESTKUDOS:35"); + } + const exchangeUpdated2Cond = walletClient.waitForNotificationCond( (x) => x.type === NotificationType.ExchangeStateTransition && @@ -183,7 +213,7 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { // Travel into the future, the deposit expiration is two years // into the future. - console.log("applying second time travel"); + t.logStep("applying second time travel"); await applyTimeTravelV2( Duration.toMilliseconds(Duration.fromSpec({ years: 2, months: 6 })), { @@ -194,8 +224,13 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { ); // The time travel should cause exchanges to update. + t.logStep("The time travel should cause exchanges to update."); await exchangeUpdated2Cond; await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); + { + const balance = await walletClient.call(WalletApiOperation.GetBalances, {}); + t.assertAmountEquals(balance.balances[0].available, "TESTKUDOS:35"); + } // At this point, the original coins should've been refreshed. // It would be too late to refresh them now, as we're past |