From 57000c22141afde7eb7b13ccbd16f06d6b6eb5cd Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 20 Aug 2020 11:59:06 +0530 Subject: add auto-refund test case, fix bug detected by it --- packages/taler-wallet-core/src/operations/refresh.ts | 9 +++++++++ packages/taler-wallet-core/src/operations/refund.ts | 4 +++- packages/taler-wallet-core/src/operations/transactions.ts | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'packages/taler-wallet-core/src/operations') diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts index 409ae58cc..430675328 100644 --- a/packages/taler-wallet-core/src/operations/refresh.ts +++ b/packages/taler-wallet-core/src/operations/refresh.ts @@ -571,10 +571,19 @@ export async function createRefreshGroup( retryInfo: initRetryInfo(), }; + if (oldCoinPubs.length == 0) { + logger.warn("created refresh group with zero coins"); + refreshGroup.timestampFinished = getTimestampNow(); + } + await tx.put(Stores.refreshGroups, refreshGroup); logger.trace(`created refresh group ${refreshGroupId}`); + processRefreshGroup(ws, refreshGroupId).catch((e) => { + logger.warn(`processing refresh group ${refreshGroupId} failed`); + }); + return { refreshGroupId, }; diff --git a/packages/taler-wallet-core/src/operations/refund.ts b/packages/taler-wallet-core/src/operations/refund.ts index e9324712e..0d6b9ec86 100644 --- a/packages/taler-wallet-core/src/operations/refund.ts +++ b/packages/taler-wallet-core/src/operations/refund.ts @@ -259,7 +259,9 @@ async function acceptRefunds( } const refreshCoinsPubs = Object.values(refreshCoinsMap); - await createRefreshGroup(ws, tx, refreshCoinsPubs, RefreshReason.Refund); + if (refreshCoinsPubs.length > 0) { + await createRefreshGroup(ws, tx, refreshCoinsPubs, RefreshReason.Refund); + } // Are we done with querying yet, or do we need to do another round // after a retry delay? diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index e17dfac3a..8d0558dbd 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -265,7 +265,7 @@ export async function getTransactions( refundGroupKeys.forEach((groupKey: string) => { const refundTransactionId = makeEventId( - TransactionType.Payment, + TransactionType.Refund, pr.proposalId, groupKey, ); -- cgit v1.2.3