gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: harness: simplify test


From: gnunet
Subject: [taler-wallet-core] branch master updated: harness: simplify test
Date: Mon, 09 Dec 2024 19:03:49 +0100

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

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

The following commit(s) were added to refs/heads/master by this push:
     new 599fb50d4 harness: simplify test
599fb50d4 is described below

commit 599fb50d49c5e173118126196c7d0d58bacd0f96
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Dec 9 19:03:33 2024 +0100

    harness: simplify test
---
 packages/taler-harness/src/harness/environments.ts |   7 +-
 .../test-kyc-merchant-aggregate.ts                 | 243 +++------------------
 2 files changed, 30 insertions(+), 220 deletions(-)

diff --git a/packages/taler-harness/src/harness/environments.ts 
b/packages/taler-harness/src/harness/environments.ts
index fa5d4a395..480e91a89 100644
--- a/packages/taler-harness/src/harness/environments.ts
+++ b/packages/taler-harness/src/harness/environments.ts
@@ -997,7 +997,7 @@ export async function makeTestPaymentV2(
     instance,
   });
 
-  t.assertTrue(orderStatus.order_status === "paid");
+  t.assertDeepEqual(orderStatus.order_status, "paid");
 
   return {
     transactionId: preparePayResult.transactionId,
@@ -1101,11 +1101,10 @@ export async function postAmlDecision(
   t.assertDeepEqual(resp.status, HttpStatusCode.NoContent);
 }
 
-function defaultOnNotification(n: WalletNotification):void {
+function defaultOnNotification(n: WalletNotification): void {
   console.log("wallet-core notification", n);
 }
 
-
 export interface KycEnvOptions {
   coinConfig?: CoinConfig[];
   onWalletNotification?: (n: WalletNotification) => void;
@@ -1123,7 +1122,6 @@ export interface KycTestEnv {
   merchant: MerchantService;
 }
 
-
 export async function createKycTestkudosEnvironment(
   t: GlobalTestState,
   opts: KycEnvOptions = {},
@@ -1212,7 +1210,6 @@ export async function createKycTestkudosEnvironment(
   await walletService.start();
   await walletService.pingUntilAvailable();
 
-
   const walletClient = new WalletClient({
     name: "wallet",
     unixPath: walletService.socketPath,
diff --git 
a/packages/taler-harness/src/integrationtests/test-kyc-merchant-aggregate.ts 
b/packages/taler-harness/src/integrationtests/test-kyc-merchant-aggregate.ts
index 45443c781..7643e6a9d 100644
--- a/packages/taler-harness/src/integrationtests/test-kyc-merchant-aggregate.ts
+++ b/packages/taler-harness/src/integrationtests/test-kyc-merchant-aggregate.ts
@@ -17,231 +17,44 @@
 /**
  * Imports.
  */
-import { Duration, j2s, TalerCorebankApiClient } from "@gnu-taler/taler-util";
+import { Configuration, j2s } from "@gnu-taler/taler-util";
 import {
-  createSyncCryptoApi,
-  EddsaKeyPairStrings,
-  WalletApiOperation,
-} from "@gnu-taler/taler-wallet-core";
-import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js";
-import {
-  BankService,
-  DbInfo,
-  ExchangeService,
-  getTestHarnessPaytoForLabel,
-  GlobalTestState,
-  HarnessExchangeBankAccount,
-  harnessHttpLib,
-  MerchantService,
-  setupDb,
-  WalletClient,
-  WalletService,
-} from "../harness/harness.js";
-import {
-  EnvOptions,
+  createKycTestkudosEnvironment,
   makeTestPaymentV2,
   withdrawViaBankV3,
 } from "../harness/environments.js";
-
-interface KycTestEnv {
-  commonDb: DbInfo;
-  bankClient: TalerCorebankApiClient;
-  exchange: ExchangeService;
-  exchangeBankAccount: HarnessExchangeBankAccount;
-  walletClient: WalletClient;
-  walletService: WalletService;
-  amlKeypair: EddsaKeyPairStrings;
-  merchant: MerchantService;
-}
-
-async function createKycTestkudosEnvironment(
-  t: GlobalTestState,
-  coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")),
-  opts: EnvOptions = {},
-): Promise<KycTestEnv> {
-  const db = await setupDb(t);
-
-  const bank = await BankService.create(t, {
-    allowRegistrations: true,
-    currency: "TESTKUDOS",
-    database: db.connStr,
-    httpPort: 8082,
-  });
-
-  const exchange = ExchangeService.create(t, {
-    name: "testexchange-1",
-    currency: "TESTKUDOS",
-    httpPort: 8081,
-    database: db.connStr,
-  });
-
-  let receiverName = "Exchange";
-  let exchangeBankUsername = "exchange";
-  let exchangeBankPassword = "mypw-password";
-  let exchangePaytoUri = getTestHarnessPaytoForLabel(exchangeBankUsername);
-
-  await exchange.addBankAccount("1", {
-    accountName: exchangeBankUsername,
-    accountPassword: exchangeBankPassword,
-    wireGatewayApiBaseUrl: new URL(
-      "accounts/exchange/taler-wire-gateway/",
-      bank.baseUrl,
-    ).href,
-    accountPaytoUri: exchangePaytoUri,
-  });
-
-  bank.setSuggestedExchange(exchange, exchangePaytoUri);
-
-  await bank.start();
-
-  const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, {
-    auth: {
-      username: "admin",
-      password: "admin-password",
-    },
-  });
-
-  await bankClient.registerAccountExtended({
-    name: receiverName,
-    password: exchangeBankPassword,
-    username: exchangeBankUsername,
-    is_taler_exchange: true,
-    payto_uri: exchangePaytoUri,
-  });
-
-  const ageMaskSpec = opts.ageMaskSpec;
-
-  if (ageMaskSpec) {
-    exchange.enableAgeRestrictions(ageMaskSpec);
-    // Enable age restriction for all coins.
-    exchange.addCoinConfigList(
-      coinConfig.map((x) => ({
-        ...x,
-        name: `${x.name}-age`,
-        ageRestricted: true,
-      })),
-    );
-    // For mixed age restrictions, we also offer coins without age restrictions
-    if (opts.mixedAgeRestriction) {
-      exchange.addCoinConfigList(
-        coinConfig.map((x) => ({ ...x, ageRestricted: false })),
-      );
-    }
-  } else {
-    exchange.addCoinConfigList(coinConfig);
-  }
-
-  await exchange.modifyConfig(async (config) => {
-    config.setString("exchange", "enable_kyc", "yes");
-
-    config.setString("KYC-RULE-R1", "operation_type", "aggregate");
-    config.setString("KYC-RULE-R1", "enabled", "yes");
-    config.setString("KYC-RULE-R1", "exposed", "yes");
-    config.setString("KYC-RULE-R1", "is_and_combinator", "yes");
-    config.setString("KYC-RULE-R1", "threshold", "TESTKUDOS:5");
-    config.setString("KYC-RULE-R1", "timeframe", "1d");
-    config.setString("KYC-RULE-R1", "next_measures", "M1");
-
-    config.setString("KYC-MEASURE-M1", "check_name", "C1");
-    config.setString("KYC-MEASURE-M1", "context", "{}");
-    config.setString("KYC-MEASURE-M1", "program", "P1");
-
-    config.setString("AML-PROGRAM-P1", "command", "/bin/true");
-    config.setString("AML-PROGRAM-P1", "enabled", "true");
-    config.setString("AML-PROGRAM-P1", "description", "this does nothing");
-    config.setString("AML-PROGRAM-P1", "fallback", "M1");
-
-    config.setString("KYC-CHECK-C1", "type", "INFO");
-    config.setString("KYC-CHECK-C1", "description", "my check!");
-    config.setString("KYC-CHECK-C1", "fallback", "M1");
-  });
-
-  await exchange.start();
-
-  const cryptoApi = createSyncCryptoApi();
-  const amlKeypair = await cryptoApi.createEddsaKeypair({});
-
-  await exchange.enableAmlAccount(amlKeypair.pub, "Alice");
-
-  const walletService = new WalletService(t, {
-    name: "wallet",
-    useInMemoryDb: true,
-  });
-  await walletService.start();
-  await walletService.pingUntilAvailable();
-
-  const walletClient = new WalletClient({
-    name: "wallet",
-    unixPath: walletService.socketPath,
-    onNotification(n) {
-      console.log("got notification", n);
-    },
-  });
-  await walletClient.connect();
-  await walletClient.client.call(WalletApiOperation.InitWallet, {
-    config: {
-      testing: {
-        skipDefaults: true,
-      },
-    },
-  });
-
-  const merchant = await MerchantService.create(t, {
-    name: "testmerchant-1",
-    httpPort: 8083,
-    database: db.connStr,
-  });
-
-  merchant.addExchange(exchange);
-
-  if (opts.additionalMerchantConfig) {
-    opts.additionalMerchantConfig(merchant);
-  }
-  await merchant.start();
-  await merchant.pingUntilAvailable();
-
-  await merchant.addInstanceWithWireAccount({
-    id: "default",
-    name: "Default Instance",
-    paytoUris: [getTestHarnessPaytoForLabel("merchant-default")],
-    defaultWireTransferDelay: Duration.toTalerProtocolDuration(
-      Duration.fromSpec({ minutes: 1 }),
-    ),
-  });
-
-  await merchant.addInstanceWithWireAccount({
-    id: "minst1",
-    name: "minst1",
-    paytoUris: [getTestHarnessPaytoForLabel("minst1")],
-    defaultWireTransferDelay: Duration.toTalerProtocolDuration(
-      Duration.fromSpec({ minutes: 1 }),
-    ),
-  });
-
-  console.log("setup done!");
-
-  return {
-    commonDb: db,
-    exchange,
-    amlKeypair,
-    walletClient,
-    walletService,
-    bankClient,
-    merchant,
-    exchangeBankAccount: {
-      accountName: "",
-      accountPassword: "",
-      accountPaytoUri: "",
-      wireGatewayApiBaseUrl: "",
-    },
-  };
+import { GlobalTestState, harnessHttpLib } from "../harness/harness.js";
+
+function adjustExchangeConfig(config: Configuration) {
+  config.setString("exchange", "enable_kyc", "yes");
+
+  config.setString("KYC-RULE-R1", "operation_type", "aggregate");
+  config.setString("KYC-RULE-R1", "enabled", "yes");
+  config.setString("KYC-RULE-R1", "exposed", "yes");
+  config.setString("KYC-RULE-R1", "is_and_combinator", "yes");
+  config.setString("KYC-RULE-R1", "threshold", "TESTKUDOS:5");
+  config.setString("KYC-RULE-R1", "timeframe", "1d");
+  config.setString("KYC-RULE-R1", "next_measures", "M1");
+
+  config.setString("KYC-MEASURE-M1", "check_name", "C1");
+  config.setString("KYC-MEASURE-M1", "context", "{}");
+  config.setString("KYC-MEASURE-M1", "program", "P1");
+
+  config.setString("AML-PROGRAM-P1", "command", "/bin/true");
+  config.setString("AML-PROGRAM-P1", "enabled", "true");
+  config.setString("AML-PROGRAM-P1", "description", "this does nothing");
+  config.setString("AML-PROGRAM-P1", "fallback", "M1");
+
+  config.setString("KYC-CHECK-C1", "type", "INFO");
+  config.setString("KYC-CHECK-C1", "description", "my check!");
+  config.setString("KYC-CHECK-C1", "fallback", "M1");
 }
 
 export async function runKycMerchantAggregateTest(t: GlobalTestState) {
   // Set up test environment
 
   const { merchant, walletClient, bankClient, exchange, amlKeypair } =
-    await createKycTestkudosEnvironment(t);
+    await createKycTestkudosEnvironment(t, { adjustExchangeConfig });
 
   // Withdraw digital cash into the wallet.
 

-- 
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]