gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 01/02: harness: modernize some tests, temporarily di


From: gnunet
Subject: [taler-wallet-core] 01/02: harness: modernize some tests, temporarily disable revocation test
Date: Fri, 25 Aug 2023 11:53:31 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

commit 3d6cff9c8400c2b5d1b5a0ce149656801b2300fe
Author: Florian Dold <florian@dold.me>
AuthorDate: Fri Aug 25 11:22:52 2023 +0200

    harness: modernize some tests, temporarily disable revocation test
---
 .../test-age-restrictions-mixed-merchant.ts        | 21 +++++---
 .../src/integrationtests/test-denom-unoffered.ts   | 20 ++++++--
 .../src/integrationtests/test-fee-regression.ts    | 40 +++++++++------
 .../integrationtests/test-merchant-longpolling.ts  |  4 +-
 .../integrationtests/test-payment-forgettable.ts   |  4 +-
 .../src/integrationtests/test-paywall-flow.ts      | 60 +++++++++++-----------
 .../src/integrationtests/test-revocation.ts        |  1 +
 packages/taler-harness/src/sandcastle-config.ts    | 10 ++++
 8 files changed, 100 insertions(+), 60 deletions(-)

diff --git 
a/packages/taler-harness/src/integrationtests/test-age-restrictions-mixed-merchant.ts
 
b/packages/taler-harness/src/integrationtests/test-age-restrictions-mixed-merchant.ts
index 970acbb72..af90ef1c5 100644
--- 
a/packages/taler-harness/src/integrationtests/test-age-restrictions-mixed-merchant.ts
+++ 
b/packages/taler-harness/src/integrationtests/test-age-restrictions-mixed-merchant.ts
@@ -19,13 +19,12 @@
  */
 import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
 import { defaultCoinConfig } from "../harness/denomStructures.js";
-import { GlobalTestState, WalletCli } from "../harness/harness.js";
+import { GlobalTestState } from "../harness/harness.js";
 import {
-  makeTestPayment,
   createSimpleTestkudosEnvironmentV2,
-  withdrawViaBankV2,
-  makeTestPaymentV2,
   createWalletDaemonWithClient,
+  makeTestPaymentV2,
+  withdrawViaBankV2,
 } from "../harness/helpers.js";
 
 /**
@@ -59,7 +58,7 @@ export async function runAgeRestrictionsMixedMerchantTest(t: 
GlobalTestState) {
   {
     const walletClient = walletOne;
 
-    await withdrawViaBankV2(t, {
+    const wres = await withdrawViaBankV2(t, {
       walletClient,
       bank,
       exchange,
@@ -67,6 +66,8 @@ export async function runAgeRestrictionsMixedMerchantTest(t: 
GlobalTestState) {
       restrictAge: 13,
     });
 
+    await wres.withdrawalFinishedCond;
+
     const order = {
       summary: "Buy me!",
       amount: "TESTKUDOS:5",
@@ -82,7 +83,7 @@ export async function runAgeRestrictionsMixedMerchantTest(t: 
GlobalTestState) {
   }
 
   {
-    await withdrawViaBankV2(t, {
+    const wres = await withdrawViaBankV2(t, {
       walletClient: walletTwo,
       bank,
       exchange,
@@ -90,6 +91,9 @@ export async function runAgeRestrictionsMixedMerchantTest(t: 
GlobalTestState) {
       restrictAge: 13,
     });
 
+
+    await wres.withdrawalFinishedCond;
+
     const order = {
       summary: "Buy me!",
       amount: "TESTKUDOS:5",
@@ -101,13 +105,16 @@ export async function 
runAgeRestrictionsMixedMerchantTest(t: GlobalTestState) {
   }
 
   {
-    await withdrawViaBankV2(t, {
+    const wres = await withdrawViaBankV2(t, {
       walletClient: walletThree,
       bank,
       exchange,
       amount: "TESTKUDOS:20",
     });
 
+
+    await wres.withdrawalFinishedCond;
+
     const order = {
       summary: "Buy me!",
       amount: "TESTKUDOS:5",
diff --git 
a/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts 
b/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts
index 1b9b91603..5a471b9aa 100644
--- a/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts
+++ b/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts
@@ -18,12 +18,10 @@
  * Imports.
  */
 import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
-import { Wallet, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
 import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
 import {
-  createSimpleTestkudosEnvironment,
   createSimpleTestkudosEnvironmentV2,
-  withdrawViaBank,
   withdrawViaBankV2,
 } from "../harness/helpers.js";
 
@@ -35,7 +33,14 @@ export async function runDenomUnofferedTest(t: 
GlobalTestState) {
 
   // Withdraw digital cash into the wallet.
 
-  await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: 
"TESTKUDOS:20" });
+  const wres = await withdrawViaBankV2(t, {
+    walletClient,
+    bank,
+    exchange,
+    amount: "TESTKUDOS:20",
+  });
+
+  await wres.withdrawalFinishedCond;
 
   // Make the exchange forget the denomination.
   // Effectively we completely reset the exchange,
@@ -108,7 +113,12 @@ export async function runDenomUnofferedTest(t: 
GlobalTestState) {
   });
 
   // Now withdrawal should work again.
-  await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: 
"TESTKUDOS:20" });
+  await withdrawViaBankV2(t, {
+    walletClient,
+    bank,
+    exchange,
+    amount: "TESTKUDOS:20",
+  });
 
   await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
 
diff --git a/packages/taler-harness/src/integrationtests/test-fee-regression.ts 
b/packages/taler-harness/src/integrationtests/test-fee-regression.ts
index 8c5a5bea4..e0dc4bc3b 100644
--- a/packages/taler-harness/src/integrationtests/test-fee-regression.ts
+++ b/packages/taler-harness/src/integrationtests/test-fee-regression.ts
@@ -19,18 +19,18 @@
  */
 import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
 import {
-  GlobalTestState,
   BankService,
   ExchangeService,
+  GlobalTestState,
   MerchantService,
-  setupDb,
-  WalletCli,
   getPayto,
+  setupDb,
 } from "../harness/harness.js";
 import {
-  withdrawViaBank,
-  makeTestPayment,
-  SimpleTestEnvironment,
+  SimpleTestEnvironmentNg,
+  createWalletDaemonWithClient,
+  makeTestPaymentV2,
+  withdrawViaBankV2,
 } from "../harness/helpers.js";
 
 /**
@@ -39,7 +39,7 @@ import {
  */
 export async function createMyTestkudosEnvironment(
   t: GlobalTestState,
-): Promise<SimpleTestEnvironment> {
+): Promise<SimpleTestEnvironmentNg> {
   const db = await setupDb(t);
 
   const bank = await BankService.create(t, {
@@ -147,13 +147,19 @@ export async function createMyTestkudosEnvironment(
 
   console.log("setup done!");
 
-  const wallet = new WalletCli(t);
+  const { walletClient, walletService } = await createWalletDaemonWithClient(
+    t,
+    {
+      name: "w1",
+    },
+  );
 
   return {
     commonDb: db,
     exchange,
     merchant,
-    wallet,
+    walletClient,
+    walletService,
     bank,
     exchangeBankAccount,
   };
@@ -165,19 +171,21 @@ export async function createMyTestkudosEnvironment(
 export async function runFeeRegressionTest(t: GlobalTestState) {
   // Set up test environment
 
-  const { wallet, bank, exchange, merchant } =
+  const { walletClient, bank, exchange, merchant } =
     await createMyTestkudosEnvironment(t);
 
   // Withdraw digital cash into the wallet.
 
-  await withdrawViaBank(t, {
-    wallet,
+  const wres = await withdrawViaBankV2(t, {
+    walletClient,
     bank,
     exchange,
     amount: "TESTKUDOS:1.92",
   });
 
-  const coins = await wallet.client.call(WalletApiOperation.DumpCoins, {});
+  await wres.withdrawalFinishedCond;
+
+  const coins = await walletClient.call(WalletApiOperation.DumpCoins, {});
 
   // Make sure we really withdraw one 0.64 and one 1.28 coin.
   t.assertTrue(coins.coins.length === 2);
@@ -188,11 +196,11 @@ export async function runFeeRegressionTest(t: 
GlobalTestState) {
     fulfillment_url: "taler://fulfillment-success/thx",
   };
 
-  await makeTestPayment(t, { wallet, merchant, order });
+  await makeTestPaymentV2(t, { walletClient, merchant, order });
 
-  await wallet.runUntilDone();
+  await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
 
-  const txs = await wallet.client.call(WalletApiOperation.GetTransactions, {});
+  const txs = await walletClient.call(WalletApiOperation.GetTransactions, {});
   t.assertAmountEquals(txs.transactions[1].amountEffective, "TESTKUDOS:1.30");
   console.log(txs);
 }
diff --git 
a/packages/taler-harness/src/integrationtests/test-merchant-longpolling.ts 
b/packages/taler-harness/src/integrationtests/test-merchant-longpolling.ts
index 161e8beac..59f23fe5d 100644
--- a/packages/taler-harness/src/integrationtests/test-merchant-longpolling.ts
+++ b/packages/taler-harness/src/integrationtests/test-merchant-longpolling.ts
@@ -43,13 +43,15 @@ export async function runMerchantLongpollingTest(t: 
GlobalTestState) {
 
   // Withdraw digital cash into the wallet.
 
-  await withdrawViaBankV2(t, {
+  const wres = await withdrawViaBankV2(t, {
     walletClient,
     bank,
     exchange,
     amount: "TESTKUDOS:20",
   });
 
+  await wres.withdrawalFinishedCond;
+
   /**
    * =========================================================================
    * Create an order and let the wallet pay under a session ID
diff --git 
a/packages/taler-harness/src/integrationtests/test-payment-forgettable.ts 
b/packages/taler-harness/src/integrationtests/test-payment-forgettable.ts
index 83f19e58e..21d76397d 100644
--- a/packages/taler-harness/src/integrationtests/test-payment-forgettable.ts
+++ b/packages/taler-harness/src/integrationtests/test-payment-forgettable.ts
@@ -36,13 +36,15 @@ export async function runPaymentForgettableTest(t: 
GlobalTestState) {
 
   // Withdraw digital cash into the wallet.
 
-  await withdrawViaBankV2(t, {
+  const wres = await withdrawViaBankV2(t, {
     walletClient,
     bank,
     exchange,
     amount: "TESTKUDOS:20",
   });
 
+  await wres.withdrawalFinishedCond;
+
   {
     const order = {
       summary: "Buy me!",
diff --git a/packages/taler-harness/src/integrationtests/test-paywall-flow.ts 
b/packages/taler-harness/src/integrationtests/test-paywall-flow.ts
index c90898034..b0477a049 100644
--- a/packages/taler-harness/src/integrationtests/test-paywall-flow.ts
+++ b/packages/taler-harness/src/integrationtests/test-paywall-flow.ts
@@ -24,10 +24,17 @@ import {
   ConfirmPayResultType,
   URL,
 } from "@gnu-taler/taler-util";
-import axiosImp from "axios";
-const axios = axiosImp.default;
 import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import { createSimpleTestkudosEnvironmentV2, withdrawViaBankV2 } from 
"../harness/helpers.js";
+import {
+  createSimpleTestkudosEnvironmentV2,
+  withdrawViaBankV2,
+} from "../harness/helpers.js";
+import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
+
+const httpLib = createPlatformHttpLib({
+  allowHttp: true,
+  enableThrottling: false,
+});
 
 /**
  * Run test for basic, bank-integrated withdrawal.
@@ -40,7 +47,12 @@ export async function runPaywallFlowTest(t: GlobalTestState) 
{
 
   // Withdraw digital cash into the wallet.
 
-  await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: 
"TESTKUDOS:20" });
+  await withdrawViaBankV2(t, {
+    walletClient,
+    bank,
+    exchange,
+    amount: "TESTKUDOS:20",
+  });
 
   /**
    * =========================================================================
@@ -74,9 +86,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
   t.assertTrue(orderStatus.already_paid_order_id === undefined);
   let publicOrderStatusUrl = new URL(orderStatus.order_status_url);
 
-  let publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
-    validateStatus: () => true,
-  });
+  let publicOrderStatusResp = await httpLib.fetch(publicOrderStatusUrl.href);
 
   if (publicOrderStatusResp.status != 402) {
     throw Error(
@@ -85,7 +95,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
   }
 
   let pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode(
-    publicOrderStatusResp.data,
+    publicOrderStatusResp.json(),
   );
 
   console.log(pubUnpaidStatus);
@@ -102,10 +112,8 @@ export async function runPaywallFlowTest(t: 
GlobalTestState) {
   const proposalId = preparePayResp.proposalId;
 
   console.log("requesting", publicOrderStatusUrl.href);
-  publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
-    validateStatus: () => true,
-  });
-  console.log("response body", publicOrderStatusResp.data);
+  publicOrderStatusResp = await httpLib.fetch(publicOrderStatusUrl.href);
+  console.log("response body", publicOrderStatusResp.json());
   if (publicOrderStatusResp.status != 402) {
     throw Error(
       `expected status 402 (after claiming), but got 
${publicOrderStatusResp.status}`,
@@ -113,26 +121,20 @@ export async function runPaywallFlowTest(t: 
GlobalTestState) {
   }
 
   pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode(
-    publicOrderStatusResp.data,
+    publicOrderStatusResp.json(),
   );
 
-  const confirmPayRes = await walletClient.call(
-    WalletApiOperation.ConfirmPay,
-    {
-      proposalId: proposalId,
-    },
-  );
+  const confirmPayRes = await walletClient.call(WalletApiOperation.ConfirmPay, 
{
+    proposalId: proposalId,
+  });
 
   t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
+  publicOrderStatusResp = await httpLib.fetch(publicOrderStatusUrl.href);
 
-  publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
-    validateStatus: () => true,
-  });
-
-  console.log(publicOrderStatusResp.data);
+  console.log(publicOrderStatusResp.json());
 
   if (publicOrderStatusResp.status != 200) {
-    console.log(publicOrderStatusResp.data);
+    console.log(publicOrderStatusResp.json());
     throw Error(
       `expected status 200 (after paying), but got 
${publicOrderStatusResp.status}`,
     );
@@ -229,19 +231,17 @@ export async function runPaywallFlowTest(t: 
GlobalTestState) {
   console.log("requesting public status", publicOrderStatusUrl);
 
   // Ask the order status of the claimed-but-unpaid order
-  publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
-    validateStatus: () => true,
-  });
+  publicOrderStatusResp = await httpLib.fetch(publicOrderStatusUrl.href);
 
   if (publicOrderStatusResp.status != 402) {
     throw Error(`expected status 402, but got 
${publicOrderStatusResp.status}`);
   }
 
   pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode(
-    publicOrderStatusResp.data,
+    publicOrderStatusResp.json(),
   );
 
-  console.log(publicOrderStatusResp.data);
+  console.log(publicOrderStatusResp.json());
 
   t.assertTrue(pubUnpaidStatus.already_paid_order_id === firstOrderId);
 }
diff --git a/packages/taler-harness/src/integrationtests/test-revocation.ts 
b/packages/taler-harness/src/integrationtests/test-revocation.ts
index 0fbb4960e..04707e51a 100644
--- a/packages/taler-harness/src/integrationtests/test-revocation.ts
+++ b/packages/taler-harness/src/integrationtests/test-revocation.ts
@@ -213,3 +213,4 @@ export async function runRevocationTest(t: GlobalTestState) 
{
 
 runRevocationTest.timeoutMs = 120000;
 runRevocationTest.suites = ["wallet"];
+runRevocationTest.excludeByDefault = true;
\ No newline at end of file
diff --git a/packages/taler-harness/src/sandcastle-config.ts 
b/packages/taler-harness/src/sandcastle-config.ts
new file mode 100644
index 000000000..a7f7233ac
--- /dev/null
+++ b/packages/taler-harness/src/sandcastle-config.ts
@@ -0,0 +1,10 @@
+// Work in progress.
+// TS-based schema for the sandcastle configuration.
+
+export interface SandcastleConfig {
+  currency: string;
+  merchant: {
+    apiKey: string;
+    baseUrl: string;
+  };
+}

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]