commit 41036ee5bab28e68c124ffcea3f7a33b66c2c343
parent 7e9067c033f489b330d79e901e170d1bb629276d
Author: Florian Dold <florian@dold.me>
Date: Sun, 27 Apr 2025 16:07:48 +0200
harness: test aborting a peer-push-debit transaction before purse creation
Diffstat:
2 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts
@@ -307,14 +307,20 @@ export class GlobalTestState {
throw Error(`duplicate step (${spanName})`);
}
let steps = `${this.testDir}/steps.txt`;
- fs.appendFileSync(steps, `START ${spanName}\n`);
+ const stepStart = `START ${spanName}`;
+ fs.appendFileSync(steps, `${stepStart}\n`);
+ logger.info(`STEP: ${stepStart}`);
try {
await block();
} catch (e) {
- fs.appendFileSync(steps, `FAIL ${(e as any).message}\n`);
+ const stepFail = `FAIL ${spanName} - ${(e as any).message}`;
+ fs.appendFileSync(steps, `${stepFail}\n`);
+ logger.info(`STEP: ${stepFail}`);
throw e;
}
- fs.appendFileSync(steps, `END ${spanName}\n`);
+ const stepEnd = `END ${spanName}`;
+ fs.appendFileSync(steps, `${stepEnd}\n`);
+ logger.info(`STEP: ${stepEnd}`);
}
async assertThrowsTalerErrorAsync(
diff --git a/packages/taler-harness/src/integrationtests/test-peer-push.ts b/packages/taler-harness/src/integrationtests/test-peer-push.ts
@@ -303,6 +303,41 @@ export async function runPeerPushTest(t: GlobalTestState) {
t.assertAmountEquals(bal.balances[0].available, "TESTKUDOS:189.99");
}
+ await t.runSpanAsync("P2P push abort before create purse", async () => {
+ // Make sure the reserve can't be created.
+ // This will test the case where the transaction is aborted
+ // before the purse could even have been created.
+ await exchange.stop();
+ const initResp = await wallet1.call(
+ WalletApiOperation.InitiatePeerPushDebit,
+ {
+ partialContractTerms: {
+ summary: "foo",
+ amount: "TESTKUDOS:5",
+ purse_expiration: purseExpiration,
+ },
+ },
+ );
+ await wallet1.call(WalletApiOperation.AbortTransaction, {
+ transactionId: initResp.transactionId,
+ });
+ await wallet1.call(WalletApiOperation.TestingWaitTransactionState, {
+ transactionId: initResp.transactionId,
+ txState: {
+ major: TransactionMajorState.Aborting,
+ minor: TransactionMinorState.DeletePurse,
+ },
+ });
+ // Restart the exchange for the remainder of the test
+ await exchange.start();
+ await wallet1.call(WalletApiOperation.TestingWaitTransactionState, {
+ transactionId: initResp.transactionId,
+ txState: {
+ major: TransactionMajorState.Aborted,
+ },
+ });
+ });
+
t.logStep("P2P push expire");
{
const tx = await initPeerPushDebit(wallet1, "expire");
@@ -386,3 +421,4 @@ export async function runPeerPushTest(t: GlobalTestState) {
}
runPeerPushTest.suites = ["wallet"];
+runPeerPushTest.timeoutMs = 120000;