aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-08-03 19:24:04 +0200
committerFlorian Dold <florian@dold.me>2023-08-03 19:24:04 +0200
commitee47aa4837fedcaa8257b57138ea34fda220d2b7 (patch)
tree33fb9e52d148cdd30e234586fe77abecff3856cd /packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts
parent57e86b759e0376238f993fea1617609977fefb46 (diff)
downloadwallet-core-ee47aa4837fedcaa8257b57138ea34fda220d2b7.tar.xz
fix integration tests
Instead of using the deprecated runUntilDone, we now wait for specific notifications. The old way doesn't work, since p2p push transactions are not considered done until the counterparty has accepted the payment.
Diffstat (limited to 'packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts')
-rw-r--r--packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts66
1 files changed, 46 insertions, 20 deletions
diff --git a/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts b/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts
index eae04cd2e..d15858322 100644
--- a/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts
+++ b/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts
@@ -17,13 +17,20 @@
/**
* Imports.
*/
-import { AbsoluteTime, Duration } from "@gnu-taler/taler-util";
+import {
+ AbsoluteTime,
+ Duration,
+ NotificationType,
+ TransactionMajorState,
+ TransactionMinorState,
+} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { defaultCoinConfig } from "../harness/denomStructures.js";
import { GlobalTestState, WalletCli } from "../harness/harness.js";
import {
- createSimpleTestkudosEnvironment,
- withdrawViaBank,
+ createSimpleTestkudosEnvironmentV2,
+ createWalletDaemonWithClient,
+ withdrawViaBankV2,
} from "../harness/helpers.js";
/**
@@ -32,12 +39,7 @@ import {
export async function runAgeRestrictionsPeerTest(t: GlobalTestState) {
// Set up test environment
- const {
- wallet: walletOne,
- bank,
- exchange,
- merchant,
- } = await createSimpleTestkudosEnvironment(
+ const { bank, exchange } = await createSimpleTestkudosEnvironmentV2(
t,
defaultCoinConfig.map((x) => x("TESTKUDOS")),
{
@@ -45,20 +47,29 @@ export async function runAgeRestrictionsPeerTest(t: GlobalTestState) {
},
);
- const walletTwo = new WalletCli(t, "walletTwo");
- const walletThree = new WalletCli(t, "walletThree");
+ const w1 = await createWalletDaemonWithClient(t, {
+ name: "w1",
+ persistent: true,
+ });
+ const w2 = await createWalletDaemonWithClient(t, {
+ name: "w2",
+ persistent: true,
+ });
- {
- const wallet = walletOne;
+ const wallet1 = w1.walletClient;
+ const wallet2 = w2.walletClient;
- await withdrawViaBank(t, {
- wallet,
+ {
+ const withdrawalRes = await withdrawViaBankV2(t, {
+ walletClient: wallet1,
bank,
exchange,
amount: "TESTKUDOS:20",
restrictAge: 13,
});
+ await withdrawalRes.withdrawalFinishedCond;
+
const purse_expiration = AbsoluteTime.toProtocolTimestamp(
AbsoluteTime.addDuration(
AbsoluteTime.now(),
@@ -66,7 +77,7 @@ export async function runAgeRestrictionsPeerTest(t: GlobalTestState) {
),
);
- const initResp = await wallet.client.call(
+ const initResp = await wallet1.client.call(
WalletApiOperation.InitiatePeerPushDebit,
{
partialContractTerms: {
@@ -77,20 +88,35 @@ export async function runAgeRestrictionsPeerTest(t: GlobalTestState) {
},
);
- await wallet.runUntilDone();
+ const peerPushReadyCond = wallet1.waitForNotificationCond(
+ (x) =>
+ x.type === NotificationType.TransactionStateTransition &&
+ x.newTxState.major === TransactionMajorState.Pending &&
+ x.newTxState.minor === TransactionMinorState.Ready &&
+ x.transactionId === initResp.transactionId,
+ );
+
+ await peerPushReadyCond;
- const checkResp = await walletTwo.client.call(
+ const checkResp = await wallet2.call(
WalletApiOperation.PreparePeerPushCredit,
{
talerUri: initResp.talerUri,
},
);
- await walletTwo.client.call(WalletApiOperation.ConfirmPeerPushCredit, {
+ await wallet2.call(WalletApiOperation.ConfirmPeerPushCredit, {
peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId,
});
- await walletTwo.runUntilDone();
+ const peerPullCreditDoneCond = wallet2.waitForNotificationCond(
+ (x) =>
+ x.type === NotificationType.TransactionStateTransition &&
+ x.newTxState.major === TransactionMajorState.Done &&
+ x.transactionId === checkResp.transactionId,
+ );
+
+ await peerPullCreditDoneCond;
}
}