aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-09-23 21:47:38 +0200
committerFlorian Dold <florian@dold.me>2022-09-23 21:47:38 +0200
commit2337ddab6126722b46a0ea0b6e244955a38b09df (patch)
treee814990f2ca19970561eb31a297be77f6fe36245 /packages
parent8d19b801538e2be842ebe2d03ca464f72bb95edb (diff)
wallet-core: fix withdrawal state machine
Diffstat (limited to 'packages')
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts2
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-doublespend.ts2
-rw-r--r--packages/taler-wallet-core/src/db.ts5
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts5
-rw-r--r--packages/taler-wallet-core/src/wallet.ts1
5 files changed, 14 insertions, 1 deletions
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts b/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts
index c82d1e650..af294da8e 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-basic.ts
@@ -84,6 +84,8 @@ export async function runWalletBackupBasicTest(t: GlobalTestState) {
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:10" });
+ await wallet.runUntilDone();
+
await wallet.client.call(WalletApiOperation.RunBackupCycle, {});
{
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-doublespend.ts b/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-doublespend.ts
index f5c9af07e..228712da5 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-doublespend.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-wallet-backup-doublespend.ts
@@ -59,6 +59,8 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:10" });
+ await wallet.runUntilDone();
+
await wallet.client.call(WalletApiOperation.RunBackupCycle, {});
await wallet.runUntilDone();
await wallet.client.call(WalletApiOperation.RunBackupCycle, {});
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
index 3bbe5f002..f8fddb255 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -127,6 +127,11 @@ export enum WithdrawalGroupStatus {
QueryingStatus = OperationStatusRange.ACTIVE_START + 2,
/**
+ * Ready for withdrawal.
+ */
+ Ready = OperationStatusRange.ACTIVE_START + 3,
+
+ /**
* The corresponding withdraw record has been created.
* No further processing is done, unless explicitly requested
* by the user.
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts
index 4901fdc86..461b96079 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -1023,7 +1023,7 @@ async function queryReserve(
logger.warn(`withdrawal group ${withdrawalGroupId} not found`);
return;
}
- wg.status = WithdrawalGroupStatus.Finished;
+ wg.status = WithdrawalGroupStatus.Ready;
await tx.withdrawalGroups.put(wg);
});
@@ -1138,6 +1138,9 @@ export async function processWithdrawalGroup(
case WithdrawalGroupStatus.Finished:
// We can try to withdraw, nothing needs to be done with the reserve.
break;
+ case WithdrawalGroupStatus.Ready:
+ // Continue with the actual withdrawal!
+ break;
default:
throw new InvariantViolatedError(
`unknown reserve record status: ${withdrawalGroup.status}`,
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index 3b9a323a7..4323f68f5 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -492,6 +492,7 @@ async function runTaskLoop(
ws: InternalWalletState,
opts: RetryLoopOpts = {},
): Promise<TaskLoopResult> {
+ logger.info(`running task loop opts=${j2s(opts)}`);
let retriesExceeded = false;
for (let iteration = 0; !ws.stopped; iteration++) {
const pending = await getPendingOperations(ws);