aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-harness
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-12-18 19:25:26 +0100
committerFlorian Dold <florian@dold.me>2023-12-18 19:25:26 +0100
commit12a9b08c6f8c31f684239a30fc39acc9189c6571 (patch)
tree3755eb1a6b7659d44059ddb4cf85c832a8f88a8e /packages/taler-harness
parenta488ce70d6dbfe08845eccaeb2375b367f7c307a (diff)
downloadwallet-core-12a9b08c6f8c31f684239a30fc39acc9189c6571.tar.xz
wallet-core: towards properly handling peer-pull-debit expiry
Diffstat (limited to 'packages/taler-harness')
-rw-r--r--packages/taler-harness/src/harness/harness.ts28
-rw-r--r--packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts54
2 files changed, 67 insertions, 15 deletions
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts
index a6ed59032..27c54b8b4 100644
--- a/packages/taler-harness/src/harness/harness.ts
+++ b/packages/taler-harness/src/harness/harness.ts
@@ -582,7 +582,7 @@ class BankServiceBase {
protected globalTestState: GlobalTestState,
protected bankConfig: BankConfig,
protected configFile: string,
- ) { }
+ ) {}
}
export interface HarnessExchangeBankAccount {
@@ -602,7 +602,8 @@ export interface HarnessExchangeBankAccount {
*/
export class FakebankService
extends BankServiceBase
- implements BankServiceHandle {
+ implements BankServiceHandle
+{
proc: ProcessWrapper | undefined;
http = createPlatformHttpLib({ enableThrottling: false });
@@ -732,7 +733,8 @@ export class FakebankService
*/
export class LibeufinBankService
extends BankServiceBase
- implements BankServiceHandle {
+ implements BankServiceHandle
+{
proc: ProcessWrapper | undefined;
http = createPlatformHttpLib({ enableThrottling: false });
@@ -928,11 +930,11 @@ export class ExchangeService implements ExchangeServiceInterface {
private exchangeBankAccounts: HarnessExchangeBankAccount[] = [];
- setTimetravel(t: number | undefined): void {
+ setTimetravel(tMs: number | undefined): void {
if (this.isRunning()) {
throw Error("can't set time travel while the exchange is running");
}
- this.currentTimetravelOffsetMs = t;
+ this.currentTimetravelOffsetMs = tMs;
}
private get timetravelArg(): string | undefined {
@@ -1184,7 +1186,7 @@ export class ExchangeService implements ExchangeServiceInterface {
private exchangeConfig: ExchangeConfig,
private configFilename: string,
private keyPair: EddsaKeyPair,
- ) { }
+ ) {}
get name() {
return this.exchangeConfig.name;
@@ -1540,7 +1542,7 @@ export class MerchantService implements MerchantServiceInterface {
private globalState: GlobalTestState,
private merchantConfig: MerchantConfig,
private configFilename: string,
- ) { }
+ ) {}
private currentTimetravelOffsetMs: number | undefined;
@@ -1878,7 +1880,7 @@ export class WalletService {
constructor(
private globalState: GlobalTestState,
private opts: WalletServiceOptions,
- ) { }
+ ) {}
get socketPath() {
const unixPath = path.join(
@@ -1987,7 +1989,7 @@ export class WalletClient {
return client.call(operation, payload);
}
- constructor(private args: WalletClientArgs) { }
+ constructor(private args: WalletClientArgs) {}
async connect(): Promise<void> {
const waiter = this.waiter;
@@ -2054,9 +2056,11 @@ export class WalletCli {
? `--crypto-worker=${cliOpts.cryptoWorkerType}`
: "";
const logName = `wallet-${self.name}`;
- const command = `taler-wallet-cli ${self.timetravelArg ?? ""
- } ${cryptoWorkerArg} --no-throttle -LTRACE --skip-defaults --wallet-db '${self.dbfile
- }' api '${op}' ${shellWrap(JSON.stringify(payload))}`;
+ const command = `taler-wallet-cli ${
+ self.timetravelArg ?? ""
+ } ${cryptoWorkerArg} --no-throttle -LTRACE --skip-defaults --wallet-db '${
+ self.dbfile
+ }' api '${op}' ${shellWrap(JSON.stringify(payload))}`;
const resp = await sh(self.globalTestState, logName, command);
logger.info("--- wallet core response ---");
logger.info(resp);
diff --git a/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts b/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
index a98ea89bb..583dba28d 100644
--- a/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
+++ b/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
@@ -22,17 +22,16 @@ import {
AmountString,
Duration,
NotificationType,
- TalerUriAction,
TransactionMajorState,
TransactionMinorState,
TransactionType,
WalletNotification,
j2s,
- stringifyTalerUri,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState } from "../harness/harness.js";
import {
+ applyTimeTravelV2,
createSimpleTestkudosEnvironmentV2,
createWalletDaemonWithClient,
withdrawViaBankV2,
@@ -139,7 +138,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
const acceptResp = await w2.walletClient.call(
WalletApiOperation.ConfirmPeerPushCredit,
{
- peerPushCreditId: checkResp.peerPushCreditId,
+ transactionId: checkResp.transactionId,
},
);
@@ -157,6 +156,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
console.log(`txn1: ${j2s(txn1)}`);
console.log(`txn2: ${j2s(txn2)}`);
+ // We expect insufficient balance here!
const ex1 = await t.assertThrowsTalerErrorAsync(async () => {
await w1.walletClient.call(WalletApiOperation.InitiatePeerPushDebit, {
partialContractTerms: {
@@ -168,6 +168,54 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
});
console.log("got expected exception detail", j2s(ex1.errorDetail));
+
+ const initiateResp2 = await w1.walletClient.call(
+ WalletApiOperation.InitiatePeerPushDebit,
+ {
+ partialContractTerms: {
+ summary: "second tx, will expire",
+ amount: "TESTKUDOS:5" as AmountString,
+ purse_expiration,
+ },
+ },
+ );
+
+ const peerPushReadyCond2 = w1.walletClient.waitForNotificationCond(
+ (x) =>
+ x.type === NotificationType.TransactionStateTransition &&
+ x.newTxState.major === TransactionMajorState.Pending &&
+ x.newTxState.minor === TransactionMinorState.Ready &&
+ x.transactionId === initiateResp2.transactionId,
+ );
+
+ await peerPushReadyCond2;
+
+ const timetravelOffsetMs = Duration.toMilliseconds(
+ Duration.fromSpec({ days: 5 }),
+ );
+
+ await exchange.stop();
+ exchange.setTimetravel(timetravelOffsetMs);
+ await exchange.start();
+ await exchange.pingUntilAvailable();
+
+ await w1.walletClient.call(WalletApiOperation.TestingSetTimetravel, {
+ offsetMs: timetravelOffsetMs,
+ });
+
+ await w1.walletClient.call(
+ WalletApiOperation.TestingWaitTransactionsFinal,
+ {},
+ );
+
+ const txDetails2 = await w1.walletClient.call(
+ WalletApiOperation.GetTransactionById,
+ {
+ transactionId: initiateResp2.transactionId,
+ },
+ );
+
+ console.log(`tx details 2: ${j2s(txDetails2)}`);
}
runPeerToPeerPushTest.suites = ["wallet"];