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 | 66 |
1 files changed, 21 insertions, 45 deletions
diff --git a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts index 50f9cbcd3..602b6629a 100644 --- a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts +++ b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts @@ -38,35 +38,8 @@ import { WalletCli, getPayto, } from "../harness/harness.js"; -import { startWithdrawViaBank, withdrawViaBank } from "../harness/helpers.js"; - -async function applyTimeTravel( - timetravelDuration: Duration, - s: { - exchange?: ExchangeService; - merchant?: MerchantService; - wallet?: WalletCli; - }, -): Promise<void> { - if (s.exchange) { - await s.exchange.stop(); - s.exchange.setTimetravel(timetravelDuration); - await s.exchange.start(); - await s.exchange.pingUntilAvailable(); - } - - if (s.merchant) { - await s.merchant.stop(); - s.merchant.setTimetravel(timetravelDuration); - await s.merchant.start(); - await s.merchant.pingUntilAvailable(); - } - - if (s.wallet) { - console.log("setting wallet time travel to", timetravelDuration); - s.wallet.setTimetravel(timetravelDuration); - } -} +import { applyTimeTravelV2, createWalletDaemonWithClient, withdrawViaBankV2 } from "../harness/helpers.js"; + /** * Basic time travel test. @@ -119,13 +92,13 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { await merchant.start(); await merchant.pingUntilAvailable(); - await merchant.addInstance({ + await merchant.addInstanceWithWireAccount({ id: "default", name: "Default Instance", paytoUris: [getPayto("merchant-default")], }); - await merchant.addInstance({ + await merchant.addInstanceWithWireAccount({ id: "minst1", name: "minst1", paytoUris: [getPayto("minst1")], @@ -133,43 +106,46 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { console.log("setup done!"); - const wallet = new WalletCli(t); + const { walletClient } = await createWalletDaemonWithClient(t, { + name: "w1", + }); // Withdraw digital cash into the wallet. - await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:15" }); + const wres = await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: "TESTKUDOS:15" }); + await wres.withdrawalFinishedCond; // Travel into the future, the deposit expiration is two years // into the future. console.log("applying first time travel"); - await applyTimeTravel(durationFromSpec({ days: 400 }), { - wallet, + await applyTimeTravelV2(Duration.toMilliseconds(durationFromSpec({ days: 400 })), { + walletClient, exchange, merchant, }); - await wallet.runUntilDone(); + await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); let p: PendingOperationsResponse; - p = await wallet.client.call(WalletApiOperation.GetPendingOperations, {}); + p = await walletClient.call(WalletApiOperation.GetPendingOperations, {}); console.log("pending operations after first time travel"); console.log(JSON.stringify(p, undefined, 2)); - await startWithdrawViaBank(t, { - wallet, + await withdrawViaBankV2(t, { + walletClient, bank, exchange, amount: "TESTKUDOS:20", }); - await wallet.runUntilDone(); + await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); // Travel into the future, the deposit expiration is two years // into the future. console.log("applying second time travel"); - await applyTimeTravel(durationFromSpec({ years: 2, months: 6 }), { - wallet, + await applyTimeTravelV2(Duration.toMilliseconds(durationFromSpec({ years: 2, months: 6 })), { + walletClient, exchange, merchant, }); @@ -178,7 +154,7 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { // It would be too late to refresh them now, as we're past // the two year deposit expiration. - await wallet.runUntilDone(); + await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { order: { @@ -198,7 +174,7 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { t.assertTrue(orderStatus.order_status === "unpaid"); - const r = await wallet.client.call(WalletApiOperation.PreparePayForUri, { + const r = await walletClient.call(WalletApiOperation.PreparePayForUri, { talerPayUri: orderStatus.taler_pay_uri, }); @@ -206,7 +182,7 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { t.assertTrue(r.status === PreparePayResultType.PaymentPossible); - const cpr = await wallet.client.call(WalletApiOperation.ConfirmPay, { + const cpr = await walletClient.call(WalletApiOperation.ConfirmPay, { proposalId: r.proposalId, }); |