aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-02-20 00:57:02 +0100
committerFlorian Dold <florian@dold.me>2024-02-20 00:57:02 +0100
commit578bd4b1ed12049800556460359cb55a1e8545a2 (patch)
tree8d7846882b342ceaa1048d5a42120ae973d6ce49 /packages/taler-wallet-core
parente10df554c9746971be0ec3f39a9cd98520066380 (diff)
downloadwallet-core-578bd4b1ed12049800556460359cb55a1e8545a2.tar.xz
taler-harness: test for balance during a pending refresh operation
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r--packages/taler-wallet-core/src/deposits.ts20
-rw-r--r--packages/taler-wallet-core/src/refresh.ts14
2 files changed, 30 insertions, 4 deletions
diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts
index dc3831595..6f247501e 100644
--- a/packages/taler-wallet-core/src/deposits.ts
+++ b/packages/taler-wallet-core/src/deposits.ts
@@ -95,7 +95,11 @@ import {
generateDepositPermissions,
getTotalPaymentCost,
} from "./pay-merchant.js";
-import { createRefreshGroup, getTotalRefreshCost } from "./refresh.js";
+import {
+ CreateRefreshGroupResult,
+ createRefreshGroup,
+ getTotalRefreshCost,
+} from "./refresh.js";
import {
constructTransactionIdentifier,
notifyTransition,
@@ -532,7 +536,7 @@ async function refundDepositGroup(
const currency = Amounts.currencyOf(depositGroup.totalPayCost);
- await ws.db.runReadWriteTx(
+ const res = await ws.db.runReadWriteTx(
[
"depositGroups",
"refreshGroups",
@@ -553,8 +557,9 @@ async function refundDepositGroup(
coinPub: depositGroup.payCoinSelection.coinPubs[i],
});
}
+ let refreshRes: CreateRefreshGroupResult | undefined = undefined;
if (isDone) {
- const rgid = await createRefreshGroup(
+ refreshRes = await createRefreshGroup(
ws,
tx,
currency,
@@ -565,12 +570,19 @@ async function refundDepositGroup(
depositGroupId: newDg.depositGroupId,
}),
);
- newDg.abortRefreshGroupId = rgid.refreshGroupId;
+ newDg.abortRefreshGroupId = refreshRes.refreshGroupId;
}
await tx.depositGroups.put(newDg);
+ return { refreshRes };
},
);
+ if (res?.refreshRes) {
+ for (const notif of res.refreshRes.notifications) {
+ ws.notify(notif);
+ }
+ }
+
return TaskRunResult.backoff();
}
diff --git a/packages/taler-wallet-core/src/refresh.ts b/packages/taler-wallet-core/src/refresh.ts
index df0ab25f9..09cd75bdd 100644
--- a/packages/taler-wallet-core/src/refresh.ts
+++ b/packages/taler-wallet-core/src/refresh.ts
@@ -54,6 +54,7 @@ import {
TransactionState,
TransactionType,
URL,
+ WalletNotification,
} from "@gnu-taler/taler-util";
import {
readSuccessResponseJsonOrThrow,
@@ -1254,6 +1255,7 @@ async function applyRefresh(
export interface CreateRefreshGroupResult {
refreshGroupId: string;
+ notifications: WalletNotification[];
}
/**
@@ -1310,6 +1312,8 @@ export async function createRefreshGroup(
await tx.refreshGroups.put(refreshGroup);
+ const newTxState = computeRefreshTransactionState(refreshGroup);
+
logger.trace(`created refresh group ${refreshGroupId}`);
const ctx = new RefreshTransactionContext(ws, refreshGroupId);
@@ -1321,6 +1325,16 @@ export async function createRefreshGroup(
return {
refreshGroupId,
+ notifications: [
+ {
+ type: NotificationType.TransactionStateTransition,
+ transactionId: ctx.transactionId,
+ oldTxState: {
+ major: TransactionMajorState.None,
+ },
+ newTxState,
+ },
+ ],
};
}