aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-09-05 11:35:06 +0200
committerFlorian Dold <florian@dold.me>2023-09-05 11:35:06 +0200
commit49b0f5337c27c5da3e85c512de72e6903e928bc8 (patch)
treeff979ed992c0fcea501f2d45b2bbed21f951b0b6
parenta3f370b0d83030e1a265374fd23371b000ada1c9 (diff)
harness: check expected balance in test-pay-expired
-rw-r--r--packages/taler-harness/src/harness/harness.ts6
-rw-r--r--packages/taler-harness/src/harness/helpers.ts2
-rw-r--r--packages/taler-harness/src/integrationtests/test-payment-expired.ts30
-rw-r--r--packages/taler-wallet-core/src/remote.ts1
-rw-r--r--packages/taler-wallet-core/src/wallet.ts1
5 files changed, 38 insertions, 2 deletions
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts
index b5197afd7..7c54c0c47 100644
--- a/packages/taler-harness/src/harness/harness.ts
+++ b/packages/taler-harness/src/harness/harness.ts
@@ -384,7 +384,11 @@ export class GlobalTestState {
logger.warn(`could not start process (${command})`, err);
});
proc.on("exit", (code, signal) => {
- logger.warn(`process ${logName} exited ${j2s({ code, signal })}`);
+ if (code == 0 && signal == null) {
+ logger.info(`process ${logName} exited with success`);
+ } else {
+ logger.warn(`process ${logName} exited ${j2s({ code, signal })}`);
+ }
});
const stderrLogFileName = this.testDir + `/${logName}-stderr.log`;
const stderrLog = fs.createWriteStream(stderrLogFileName, {
diff --git a/packages/taler-harness/src/harness/helpers.ts b/packages/taler-harness/src/harness/helpers.ts
index 39d411a46..ece003e1b 100644
--- a/packages/taler-harness/src/harness/helpers.ts
+++ b/packages/taler-harness/src/harness/helpers.ts
@@ -624,7 +624,7 @@ export async function applyTimeTravelV2(
}
if (s.walletClient) {
- s.walletClient.call(WalletApiOperation.TestingSetTimetravel, {
+ await s.walletClient.call(WalletApiOperation.TestingSetTimetravel, {
offsetMs: timetravelOffsetMs,
});
}
diff --git a/packages/taler-harness/src/integrationtests/test-payment-expired.ts b/packages/taler-harness/src/integrationtests/test-payment-expired.ts
index e4034108f..4817efba5 100644
--- a/packages/taler-harness/src/integrationtests/test-payment-expired.ts
+++ b/packages/taler-harness/src/integrationtests/test-payment-expired.ts
@@ -20,14 +20,17 @@
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js";
import {
+ applyTimeTravelV2,
createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2,
} from "../harness/helpers.js";
import {
AbsoluteTime,
+ ConfirmPayResultType,
Duration,
MerchantContractTerms,
PreparePayResultType,
+ j2s,
} from "@gnu-taler/taler-util";
/**
@@ -95,6 +98,33 @@ export async function runPaymentExpiredTest(t: GlobalTestState) {
preparePayResult.status,
PreparePayResultType.PaymentPossible,
);
+
+ await applyTimeTravelV2(
+ Duration.toMilliseconds(Duration.fromSpec({ hours: 1 })),
+ { walletClient, exchange, merchant },
+ );
+
+ const confirmPayResult = await walletClient.call(
+ WalletApiOperation.ConfirmPay,
+ { transactionId: preparePayResult.transactionId },
+ );
+ console.log("confirm pay result:");
+ console.log(j2s(confirmPayResult));
+ t.assertDeepEqual(confirmPayResult.type, ConfirmPayResultType.Pending);
+ await walletClient.call(WalletApiOperation.AbortTransaction, {
+ transactionId: preparePayResult.transactionId,
+ });
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
+
+ const bal = await walletClient.call(WalletApiOperation.GetBalances, {});
+ console.log(bal);
+
+ t.assertAmountEquals(bal.balances[0].available, "TESTKUDOS:18.93");
+
+ const txns = await walletClient.call(WalletApiOperation.GetTransactions, {
+ includeRefreshes: true,
+ });
+ console.log(j2s(txns));
}
runPaymentExpiredTest.suites = ["wallet"];
diff --git a/packages/taler-wallet-core/src/remote.ts b/packages/taler-wallet-core/src/remote.ts
index 89348698e..164f7cfe9 100644
--- a/packages/taler-wallet-core/src/remote.ts
+++ b/packages/taler-wallet-core/src/remote.ts
@@ -65,6 +65,7 @@ export async function createRemoteWallet(
const ctx: RemoteWallet = {
makeCoreApiRequest(operation, payload) {
const id = `req-${nextRequestId}`;
+ nextRequestId += 1;
const req: CoreApiRequestEnvelope = {
operation,
id,
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index 4194ab9eb..f42365c00 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -1680,6 +1680,7 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
const req = codecForTestingSetTimetravelRequest().decode(payload);
setDangerousTimetravel(req.offsetMs);
ws.workAvailable.trigger();
+ return {};
}
// default:
// assertUnreachable(operation);