aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-harness/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-harness/src')
-rw-r--r--packages/taler-harness/src/harness/helpers.ts4
-rw-r--r--packages/taler-harness/src/integrationtests/test-wallet-refresh.ts70
2 files changed, 68 insertions, 6 deletions
diff --git a/packages/taler-harness/src/harness/helpers.ts b/packages/taler-harness/src/harness/helpers.ts
index 7a91353c8..f567a87ff 100644
--- a/packages/taler-harness/src/harness/helpers.ts
+++ b/packages/taler-harness/src/harness/helpers.ts
@@ -25,7 +25,6 @@
*/
import {
AmountString,
- TalerCorebankApiClient,
ConfirmPayResultType,
Duration,
Logger,
@@ -33,6 +32,7 @@ import {
MerchantContractTerms,
NotificationType,
PreparePayResultType,
+ TalerCorebankApiClient,
TransactionMajorState,
WalletNotification,
} from "@gnu-taler/taler-util";
@@ -678,7 +678,7 @@ export async function makeTestPaymentV2(
);
const r2 = await walletClient.call(WalletApiOperation.ConfirmPay, {
- proposalId: preparePayResult.proposalId,
+ transactionId: preparePayResult.transactionId,
});
t.assertTrue(r2.type === ConfirmPayResultType.Done);
diff --git a/packages/taler-harness/src/integrationtests/test-wallet-refresh.ts b/packages/taler-harness/src/integrationtests/test-wallet-refresh.ts
index 9f8d1503e..b86dfadcf 100644
--- a/packages/taler-harness/src/integrationtests/test-wallet-refresh.ts
+++ b/packages/taler-harness/src/integrationtests/test-wallet-refresh.ts
@@ -17,14 +17,21 @@
/**
* Imports.
*/
-import { Wallet, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import { GlobalTestState } from "../harness/harness.js";
+import {
+ AmountString,
+ NotificationType,
+ TransactionMajorState,
+ TransactionType,
+ j2s,
+} from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { parseTransactionIdentifier } from "../../../taler-wallet-core/src/transactions.js";
+import { GlobalTestState, generateRandomPayto } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironmentV2,
- withdrawViaBankV2,
makeTestPaymentV2,
+ withdrawViaBankV2,
} from "../harness/helpers.js";
-import { TransactionType, j2s } from "@gnu-taler/taler-util";
/**
* Run test for refreshe after a payment.
@@ -77,6 +84,61 @@ export async function runWalletRefreshTest(t: GlobalTestState) {
);
t.assertDeepEqual(refreshTx.type, TransactionType.Refresh);
+
+ // Now we test a pending refresh operation.
+ {
+ await exchange.stop();
+
+ const refreshCreatedCond = walletClient.waitForNotificationCond((x) => {
+ if (
+ x.type === NotificationType.TransactionStateTransition &&
+ parseTransactionIdentifier(x.transactionId)?.tag ===
+ TransactionType.Refresh
+ ) {
+ return true;
+ }
+ return false;
+ });
+
+ const refreshDoneCond = walletClient.waitForNotificationCond((x) => {
+ if (
+ x.type === NotificationType.TransactionStateTransition &&
+ parseTransactionIdentifier(x.transactionId)?.tag ===
+ TransactionType.Refresh &&
+ x.newTxState.major === TransactionMajorState.Done
+ ) {
+ return true;
+ }
+ return false;
+ });
+
+ const depositGroupResult = await walletClient.client.call(
+ WalletApiOperation.CreateDepositGroup,
+ {
+ amount: "TESTKUDOS:10.5" as AmountString,
+ depositPaytoUri: generateRandomPayto("foo"),
+ },
+ );
+
+ await refreshCreatedCond;
+
+ // Here, the refresh operation should be in a pending state.
+
+ const bal1 = await walletClient.call(WalletApiOperation.GetBalances, {});
+
+ await exchange.start();
+
+ await refreshDoneCond;
+
+ const bal2 = await walletClient.call(WalletApiOperation.GetBalances, {});
+
+ // The refresh operation completing should not change the available balance,
+ // as we're accounting pending refreshes towards the available (but not material!) balance.
+ t.assertAmountEquals(
+ bal1.balances[0].available,
+ bal2.balances[0].available,
+ );
+ }
}
runWalletRefreshTest.suites = ["wallet"];