diff options
author | Florian Dold <florian@dold.me> | 2023-12-18 19:25:26 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-12-18 19:25:26 +0100 |
commit | 12a9b08c6f8c31f684239a30fc39acc9189c6571 (patch) | |
tree | 3755eb1a6b7659d44059ddb4cf85c832a8f88a8e /packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts | |
parent | a488ce70d6dbfe08845eccaeb2375b367f7c307a (diff) | |
download | wallet-core-12a9b08c6f8c31f684239a30fc39acc9189c6571.tar.xz |
wallet-core: towards properly handling peer-pull-debit expiry
Diffstat (limited to 'packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts')
-rw-r--r-- | packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts | 54 |
1 files changed, 51 insertions, 3 deletions
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"]; |