diff options
Diffstat (limited to 'packages/taler-harness')
7 files changed, 88 insertions, 43 deletions
| diff --git a/packages/taler-harness/src/harness/helpers.ts b/packages/taler-harness/src/harness/helpers.ts index 6f70b9455..bc2f573e9 100644 --- a/packages/taler-harness/src/harness/helpers.ts +++ b/packages/taler-harness/src/harness/helpers.ts @@ -30,8 +30,8 @@ import {    Duration,    PreparePayResultType,    NotificationType, -  WithdrawalGroupFinishedNotification,    WalletNotification, +  TransactionMajorState,  } from "@gnu-taler/taler-util";  import {    BankAccessApi, @@ -505,7 +505,7 @@ export async function startWithdrawViaBank(  }  export interface WithdrawViaBankResult { -  withdrawalFinishedCond: Promise<WithdrawalGroupFinishedNotification>; +  withdrawalFinishedCond: Promise<true>;  }  /** @@ -535,17 +535,22 @@ export async function withdrawViaBankV2(      restrictAge: p.restrictAge,    }); -  const withdrawalFinishedCond = wallet.waitForNotificationCond((x) => -    x.type === NotificationType.WithdrawGroupFinished ? x : false, -  ); -    // Withdraw (AKA select) -  await wallet.client.call(WalletApiOperation.AcceptBankIntegratedWithdrawal, { -    exchangeBaseUrl: exchange.baseUrl, -    talerWithdrawUri: wop.taler_withdraw_uri, -    restrictAge: p.restrictAge, -  }); +  const acceptRes = await wallet.client.call( +    WalletApiOperation.AcceptBankIntegratedWithdrawal, +    { +      exchangeBaseUrl: exchange.baseUrl, +      talerWithdrawUri: wop.taler_withdraw_uri, +      restrictAge: p.restrictAge, +    }, +  ); + +  const withdrawalFinishedCond = wallet.waitForNotificationCond((x) => +    x.type === NotificationType.TransactionStateTransition && +      x.newTxState.major === TransactionMajorState.Done && +      x.transactionId === acceptRes.transactionId, +  );    // Confirm it diff --git a/packages/taler-harness/src/integrationtests/test-kyc.ts b/packages/taler-harness/src/integrationtests/test-kyc.ts index ac53b0dce..660595845 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc.ts @@ -17,7 +17,14 @@  /**   * Imports.   */ -import { Duration, j2s, NotificationType } from "@gnu-taler/taler-util"; +import { +  Duration, +  j2s, +  NotificationType, +  TransactionMajorState, +  TransactionMinorState, +  TransactionType, +} from "@gnu-taler/taler-util";  import {    BankAccessApi,    BankApi, @@ -310,18 +317,7 @@ export async function runKycTest(t: GlobalTestState) {    // Withdraw -  const kycNotificationCond = walletClient.waitForNotificationCond((x) => { -    if (x.type === NotificationType.KycRequested) { -      return x; -    } -    return false; -  }); - -  const withdrawalDoneCond = walletClient.waitForNotificationCond( -    (x) => x.type === NotificationType.WithdrawGroupFinished, -  ); - -  await walletClient.client.call( +  const acceptResp = await walletClient.client.call(      WalletApiOperation.AcceptBankIntegratedWithdrawal,      {        exchangeBaseUrl: exchange.baseUrl, @@ -329,14 +325,47 @@ export async function runKycTest(t: GlobalTestState) {      },    ); +  const withdrawalTxId = acceptResp.transactionId; +    // Confirm it    await BankApi.confirmWithdrawalOperation(bank, user, wop); +  const kycNotificationCond = walletClient.waitForNotificationCond((x) => { +    if ( +      x.type === NotificationType.TransactionStateTransition && +      x.transactionId === withdrawalTxId && +      x.newTxState.major === TransactionMajorState.Pending && +      x.newTxState.minor === TransactionMinorState.KycRequired +    ) { +      return x; +    } +    return false; +  }); + +  const withdrawalDoneCond = walletClient.waitForNotificationCond( +    (x) => +      x.type === NotificationType.TransactionStateTransition && +      x.transactionId === withdrawalTxId && +      x.newTxState.major === TransactionMajorState.Done, +  ); +    const kycNotif = await kycNotificationCond;    console.log("got kyc notification:", j2s(kycNotif)); +  const txState = await walletClient.client.call(WalletApiOperation.GetTransactionById, { +    transactionId: withdrawalTxId +  }); + +  t.assertDeepEqual(txState.type, TransactionType.Withdrawal); + +  const kycUrl = txState.kycUrl; + +  t.assertTrue(!!kycUrl); + +  console.log(`kyc URL is ${kycUrl}`); +    // We now simulate the user interacting with the KYC service,    // which would usually done in the browser. @@ -344,11 +373,11 @@ export async function runKycTest(t: GlobalTestState) {      allowHttp: true,      enableThrottling: false,    }); -  const kycServerResp = await httpLib.get(kycNotif.kycUrl); +  const kycServerResp = await httpLib.fetch(kycUrl);    const kycLoginResp = await kycServerResp.json();    console.log("kyc server resp:", j2s(kycLoginResp));    const kycProofUrl = kycLoginResp.redirect_uri; -  const proofHttpResp = await httpLib.get(kycProofUrl); +  const proofHttpResp = await httpLib.fetch(kycProofUrl);    console.log("proof resp status", proofHttpResp.status);    console.log("resp headers", proofHttpResp.headers.toJSON()); diff --git a/packages/taler-harness/src/integrationtests/test-peer-repair.ts b/packages/taler-harness/src/integrationtests/test-peer-repair.ts index 77e47b01e..cfa7ec877 100644 --- a/packages/taler-harness/src/integrationtests/test-peer-repair.ts +++ b/packages/taler-harness/src/integrationtests/test-peer-repair.ts @@ -61,7 +61,9 @@ export async function runPeerRepairTest(t: GlobalTestState) {    const wallet2 = w2.walletClient;    const withdrawalDoneCond = wallet1.waitForNotificationCond( -    (x) => x.type === NotificationType.WithdrawGroupFinished, +    (x) => x.type === NotificationType.TransactionStateTransition && +      x.newTxState.major === TransactionMajorState.Done && +      x.transactionId.startsWith("txn:withdrawal:"),    );    await withdrawViaBankV2(t, { diff --git a/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts b/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts index aed3fe8db..30287b51b 100644 --- a/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts +++ b/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts @@ -61,18 +61,14 @@ export async function runPeerToPeerPullTest(t: GlobalTestState) {    const wallet1 = w1.walletClient;    const wallet2 = w2.walletClient; -  const withdrawalDoneCond = wallet2.waitForNotificationCond( -    (x) => x.type === NotificationType.WithdrawGroupFinished, -  ); - -  await withdrawViaBankV2(t, { +  const withdrawRes = await withdrawViaBankV2(t, {      walletClient: wallet2,      bank,      exchange,      amount: "TESTKUDOS:20",    }); -  await withdrawalDoneCond; +  await withdrawRes.withdrawalFinishedCond;    const purse_expiration = AbsoluteTime.toProtocolTimestamp(      AbsoluteTime.addDuration( diff --git a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts index 9f591b9d0..810250f53 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts @@ -22,6 +22,7 @@ import {    Duration,    NotificationType,    PreparePayResultType, +  TransactionMajorState,  } from "@gnu-taler/taler-util";  import {    BankAccessApi, @@ -143,12 +144,7 @@ export async function runWalletNotificationsTest(t: GlobalTestState) {    // Withdraw (AKA select) -  const withdrawalFinishedReceivedPromise = -    walletClient.waitForNotificationCond((x) => { -      return x.type === NotificationType.WithdrawGroupFinished; -    }); - -  await walletClient.client.call( +  const acceptRes = await walletClient.client.call(      WalletApiOperation.AcceptBankIntegratedWithdrawal,      {        exchangeBaseUrl: exchange.baseUrl, @@ -156,6 +152,15 @@ export async function runWalletNotificationsTest(t: GlobalTestState) {      },    ); +  const withdrawalFinishedReceivedPromise = +    walletClient.waitForNotificationCond((x) => { +      return ( +        x.type === NotificationType.TransactionStateTransition && +        x.newTxState.major === TransactionMajorState.Done && +        x.transactionId === acceptRes.transactionId +      ); +    }); +    // Confirm it    await BankApi.confirmWithdrawalOperation(bank, user, wop); diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-bank-integrated.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-bank-integrated.ts index d0515d64f..396f0f03f 100644 --- a/packages/taler-harness/src/integrationtests/test-withdrawal-bank-integrated.ts +++ b/packages/taler-harness/src/integrationtests/test-withdrawal-bank-integrated.ts @@ -82,7 +82,11 @@ export async function runWithdrawalBankIntegratedTest(t: GlobalTestState) {    );    const withdrawalFinishedCond = walletClient.waitForNotificationCond((x) => { -    return x.type === NotificationType.WithdrawGroupFinished; +    return ( +      x.type === NotificationType.TransactionStateTransition && +      x.transactionId === r2.transactionId && +      x.newTxState.major === TransactionMajorState.Done +    );    });    const withdrawalReserveReadyCond = walletClient.waitForNotificationCond( diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts index 2415c8246..f56e4d24d 100644 --- a/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts +++ b/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts @@ -27,11 +27,11 @@ import {  } from "../harness/harness.js";  import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";  import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; -import { NotificationType, URL } from "@gnu-taler/taler-util"; +import { NotificationType, TransactionMajorState, URL } from "@gnu-taler/taler-util";  /**   * Withdraw a high amount.  Mostly intended as a perf test. - *  + *   * It is useful to see whether the wallet stays responsive while doing a huge withdrawal.   * (This is not automatic yet. Use taler-wallet-cli to connect to the daemon and make requests to check.)   */ @@ -83,7 +83,11 @@ export async function runWithdrawalHugeTest(t: GlobalTestState) {    });    await wallet.connect(); -  const withdrawalFinishedCond = wallet.waitForNotificationCond((wn) => wn.type === NotificationType.WithdrawGroupFinished); +  const withdrawalFinishedCond = wallet.waitForNotificationCond( +    (wn) => wn.type === NotificationType.TransactionStateTransition && +      wn.transactionId.startsWith("txn:withdrawal:") && +      wn.newTxState.major === TransactionMajorState.Done, +  );    await wallet.client.call(WalletApiOperation.AddExchange, {      exchangeBaseUrl: exchange.baseUrl, | 
