aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-05-31 12:31:21 -0300
committerSebastian <sebasjm@gmail.com>2024-05-31 12:31:21 -0300
commit5863d8d877b5d838344e214ba5aeb5e893b7bb1a (patch)
tree80da6a92d2e49f2b5d0b835b1f136993975dfb75 /packages
parent38c9f87ae471d340fd45b96bb42afb937373324a (diff)
downloadwallet-core-5863d8d877b5d838344e214ba5aeb5e893b7bb1a.tar.xz
time travel adding coins up without removing old
Diffstat (limited to 'packages')
-rw-r--r--packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts52
1 files changed, 46 insertions, 6 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..8b8b45c40 100644
--- a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts
+++ b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts
@@ -18,17 +18,19 @@
* Imports.
*/
import {
+ Amounts,
ConfirmPayResultType,
Duration,
MerchantApiClient,
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 +80,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,
});
@@ -133,14 +138,17 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
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(
@@ -148,10 +156,18 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
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.assertTrue(
+ Amounts.cmp(balance.balances[0].available, "TESTKUDOS:15") === 0,
+ );
+ }
// 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 +178,18 @@ 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, wahting tx");
await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
-
+ {
+ const balance = await walletClient.call(WalletApiOperation.GetBalances, {});
+ t.assertTrue(
+ Amounts.cmp(balance.balances[0].available, "TESTKUDOS:15") === 0,
+ );
+ }
+
+ t.logStep("withdrawing second time");
const wres2 = await withdrawViaBankV3(t, {
walletClient,
bankClient,
@@ -173,8 +198,16 @@ 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.assertTrue(
+ Amounts.cmp(balance.balances[0].available, "TESTKUDOS:35") === 0,
+ );
+ }
+
const exchangeUpdated2Cond = walletClient.waitForNotificationCond(
(x) =>
x.type === NotificationType.ExchangeStateTransition &&
@@ -183,7 +216,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 +227,15 @@ 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.assertTrue(
+ Amounts.cmp(balance.balances[0].available, "TESTKUDOS:35") === 0,
+ );
+ }
// At this point, the original coins should've been refreshed.
// It would be too late to refresh them now, as we're past