harness: check expected balance in test-pay-expired

This commit is contained in:
Florian Dold 2023-09-05 11:35:06 +02:00
parent a3f370b0d8
commit 49b0f5337c
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
5 changed files with 38 additions and 2 deletions

View File

@ -384,7 +384,11 @@ export class GlobalTestState {
logger.warn(`could not start process (${command})`, err); logger.warn(`could not start process (${command})`, err);
}); });
proc.on("exit", (code, signal) => { proc.on("exit", (code, signal) => {
if (code == 0 && signal == null) {
logger.info(`process ${logName} exited with success`);
} else {
logger.warn(`process ${logName} exited ${j2s({ code, signal })}`); logger.warn(`process ${logName} exited ${j2s({ code, signal })}`);
}
}); });
const stderrLogFileName = this.testDir + `/${logName}-stderr.log`; const stderrLogFileName = this.testDir + `/${logName}-stderr.log`;
const stderrLog = fs.createWriteStream(stderrLogFileName, { const stderrLog = fs.createWriteStream(stderrLogFileName, {

View File

@ -624,7 +624,7 @@ export async function applyTimeTravelV2(
} }
if (s.walletClient) { if (s.walletClient) {
s.walletClient.call(WalletApiOperation.TestingSetTimetravel, { await s.walletClient.call(WalletApiOperation.TestingSetTimetravel, {
offsetMs: timetravelOffsetMs, offsetMs: timetravelOffsetMs,
}); });
} }

View File

@ -20,14 +20,17 @@
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantApiClient } from "../harness/harness.js"; import { GlobalTestState, MerchantApiClient } from "../harness/harness.js";
import { import {
applyTimeTravelV2,
createSimpleTestkudosEnvironmentV2, createSimpleTestkudosEnvironmentV2,
withdrawViaBankV2, withdrawViaBankV2,
} from "../harness/helpers.js"; } from "../harness/helpers.js";
import { import {
AbsoluteTime, AbsoluteTime,
ConfirmPayResultType,
Duration, Duration,
MerchantContractTerms, MerchantContractTerms,
PreparePayResultType, PreparePayResultType,
j2s,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
/** /**
@ -95,6 +98,33 @@ export async function runPaymentExpiredTest(t: GlobalTestState) {
preparePayResult.status, preparePayResult.status,
PreparePayResultType.PaymentPossible, 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"]; runPaymentExpiredTest.suites = ["wallet"];

View File

@ -65,6 +65,7 @@ export async function createRemoteWallet(
const ctx: RemoteWallet = { const ctx: RemoteWallet = {
makeCoreApiRequest(operation, payload) { makeCoreApiRequest(operation, payload) {
const id = `req-${nextRequestId}`; const id = `req-${nextRequestId}`;
nextRequestId += 1;
const req: CoreApiRequestEnvelope = { const req: CoreApiRequestEnvelope = {
operation, operation,
id, id,

View File

@ -1680,6 +1680,7 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
const req = codecForTestingSetTimetravelRequest().decode(payload); const req = codecForTestingSetTimetravelRequest().decode(payload);
setDangerousTimetravel(req.offsetMs); setDangerousTimetravel(req.offsetMs);
ws.workAvailable.trigger(); ws.workAvailable.trigger();
return {};
} }
// default: // default:
// assertUnreachable(operation); // assertUnreachable(operation);