gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] 02/02: harness: support tests with multiple exchange


From: gnunet
Subject: [taler-wallet-core] 02/02: harness: support tests with multiple exchanges
Date: Mon, 13 Nov 2023 18:36:39 +0100

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

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

commit 7033150c842f998f1f532d7142bdfa636d4576c4
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Nov 13 18:36:30 2023 +0100

    harness: support tests with multiple exchanges
---
 packages/taler-harness/src/harness/harness.ts      | 27 +++++++--
 .../src/integrationtests/testrunner.ts             |  2 +
 packages/taler-wallet-core/src/wallet.ts           | 70 ++++++++++------------
 3 files changed, 57 insertions(+), 42 deletions(-)

diff --git a/packages/taler-harness/src/harness/harness.ts 
b/packages/taler-harness/src/harness/harness.ts
index 5f90c8daf..5e993b95e 100644
--- a/packages/taler-harness/src/harness/harness.ts
+++ b/packages/taler-harness/src/harness/harness.ts
@@ -435,8 +435,20 @@ export interface DbInfo {
   dbname: string;
 }
 
-export async function setupDb(t: GlobalTestState): Promise<DbInfo> {
-  const dbname = "taler-integrationtest";
+export interface SetupDbOpts {
+  nameSuffix?: string;
+}
+
+export async function setupDb(
+  t: GlobalTestState,
+  opts: SetupDbOpts = {},
+): Promise<DbInfo> {
+  let dbname: string;
+  if (!opts.nameSuffix) {
+    dbname = "taler-integrationtest";
+  } else {
+    dbname = `taler-integrationtest-${opts.nameSuffix}`;
+  }
   try {
     await runCommand(t, "dropdb", "dropdb", [dbname]);
   } catch (e: any) {
@@ -479,11 +491,15 @@ export interface FakeBankConfig {
   httpPort: number;
 }
 
-function setTalerPaths(config: Configuration, home: string) {
+/**
+ * @param name additional component name, needed when launching multiple 
instances of the same component
+ */
+function setTalerPaths(config: Configuration, home: string, name?: string) {
   config.setString("paths", "taler_home", home);
   // We need to make sure that the path of taler_runtime_dir isn't too long,
   // as it contains unix domain sockets (108 character limit).
-  const runDir = fs.mkdtempSync("/tmp/taler-test-");
+  const extraName = name != null ? `${name}-` : "";
+  const runDir = fs.mkdtempSync(`/tmp/taler-test-${extraName}`);
   config.setString("paths", "taler_runtime_dir", runDir);
   config.setString(
     "paths",
@@ -999,7 +1015,7 @@ export class ExchangeService implements 
ExchangeServiceInterface {
   static create(gc: GlobalTestState, e: ExchangeConfig) {
     const testDir = e.overrideTestDir ?? gc.testDir;
     const config = new Configuration();
-    setTalerPaths(config, testDir + "/talerhome");
+    setTalerPaths(config, `${testDir}/talerhome-exchange-${e.name}`, e.name);
     config.setString("taler", "currency", e.currency);
     // Required by the exchange but not really used yet.
     config.setString("exchange", "aml_threshold", `${e.currency}:1000000`);
@@ -1024,6 +1040,7 @@ export class ExchangeService implements 
ExchangeServiceInterface {
       "master_priv_file",
       "${TALER_DATA_HOME}/exchange/offline-keys/master.priv",
     );
+    config.setString("exchange", "base_url", 
`http://localhost:${e.httpPort}/`);
     config.setString("exchange", "serve", "tcp");
     config.setString("exchange", "port", `${e.httpPort}`);
 
diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts 
b/packages/taler-harness/src/integrationtests/testrunner.ts
index cf5691fe3..968204d78 100644
--- a/packages/taler-harness/src/integrationtests/testrunner.ts
+++ b/packages/taler-harness/src/integrationtests/testrunner.ts
@@ -93,6 +93,7 @@ import { runWithdrawalHugeTest } from 
"./test-withdrawal-huge.js";
 import { runWithdrawalManualTest } from "./test-withdrawal-manual.js";
 import { runWalletGenDbTest } from "./test-wallet-gendb.js";
 import { runLibeufinBankTest } from "./test-libeufin-bank.js";
+import { runMultiExchangeTest } from "./test-multiexchange.js";
 
 /**
  * Test runner.
@@ -146,6 +147,7 @@ const allTests: TestMainFunction[] = [
   runPaymentZeroTest,
   runPayPaidTest,
   runPeerRepairTest,
+  runMultiExchangeTest,
   runWalletBalanceTest,
   runPaywallFlowTest,
   runPeerToPeerPullTest,
diff --git a/packages/taler-wallet-core/src/wallet.ts 
b/packages/taler-wallet-core/src/wallet.ts
index 978ce4c39..0694aef8a 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -22,20 +22,26 @@
 /**
  * Imports.
  */
+import { IDBFactory } from "@gnu-taler/idb-bridge";
 import {
   AbsoluteTime,
+  AmountString,
   Amounts,
   CoinDumpJson,
   CoinRefreshRequest,
   CoinStatus,
   CoreApiResponse,
+  CreateStoredBackupResponse,
+  DeleteStoredBackupRequest,
   DenomOperationMap,
   DenominationInfo,
   Duration,
   ExchangeDetailedResponse,
   ExchangeListItem,
   ExchangesListResponse,
+  ExchangesShortListResponse,
   FeeDescription,
+  GetCurrencySpecificationResponse,
   GetExchangeTosResult,
   InitResponse,
   KnownBankAccounts,
@@ -44,9 +50,13 @@ import {
   ManualWithdrawalDetails,
   MerchantUsingTemplateDetails,
   NotificationType,
+  RecoverStoredBackupRequest,
   RefreshReason,
+  StoredBackupList,
   TalerError,
   TalerErrorCode,
+  TaskThrottler,
+  TestingWaitTransactionRequest,
   TransactionState,
   TransactionType,
   URL,
@@ -69,6 +79,7 @@ import {
   codecForConfirmPeerPushPaymentRequest,
   codecForConvertAmountRequest,
   codecForCreateDepositGroupRequest,
+  codecForDeleteStoredBackupRequest,
   codecForDeleteTransactionRequest,
   codecForFailTransactionRequest,
   codecForForceRefreshRequest,
@@ -76,6 +87,7 @@ import {
   codecForGetAmountRequest,
   codecForGetBalanceDetailRequest,
   codecForGetContractTermsDetails,
+  codecForGetCurrencyInfoRequest,
   codecForGetExchangeTosRequest,
   codecForGetWithdrawalDetailsForAmountRequest,
   codecForGetWithdrawalDetailsForUri,
@@ -84,6 +96,7 @@ import {
   codecForInitiatePeerPushDebitRequest,
   codecForIntegrationTestArgs,
   codecForIntegrationTestV2Args,
+  codecForListExchangesForScopedCurrencyRequest,
   codecForListKnownBankAccounts,
   codecForMerchantPostOrderResponse,
   codecForPrepareDepositRequest,
@@ -93,19 +106,22 @@ import {
   codecForPreparePeerPushCreditRequest,
   codecForPrepareRefundRequest,
   codecForPrepareRewardRequest,
+  codecForRecoverStoredBackupRequest,
   codecForResumeTransaction,
   codecForRetryTransactionRequest,
   codecForSetCoinSuspendedRequest,
   codecForSetWalletDeviceIdRequest,
+  codecForSharePaymentRequest,
   codecForStartRefundQueryRequest,
   codecForSuspendTransaction,
   codecForTestPayArgs,
+  codecForTestingSetTimetravelRequest,
   codecForTransactionByIdRequest,
   codecForTransactionsRequest,
+  codecForUpdateExchangeEntryRequest,
   codecForUserAttentionByIdRequest,
   codecForUserAttentionsRequest,
   codecForValidateIbanRequest,
-  codecForWithdrawFakebankRequest,
   codecForWithdrawTestBalance,
   constructPayUri,
   durationFromSpec,
@@ -115,26 +131,8 @@ import {
   parsePayTemplateUri,
   parsePaytoUri,
   sampleWalletCoreTransactions,
-  validateIban,
-  codecForSharePaymentRequest,
-  GetCurrencySpecificationResponse,
-  codecForGetCurrencyInfoRequest,
-  CreateStoredBackupResponse,
-  StoredBackupList,
-  codecForDeleteStoredBackupRequest,
-  DeleteStoredBackupRequest,
-  RecoverStoredBackupRequest,
-  codecForRecoverStoredBackupRequest,
-  codecForTestingSetTimetravelRequest,
   setDangerousTimetravel,
-  TestingWaitTransactionRequest,
-  codecForUpdateExchangeEntryRequest,
-  codecForListExchangesForScopedCurrencyRequest,
-  ListExchangesForScopedCurrencyRequest,
-  ExchangesShortListResponse,
-  AmountString,
-  RequestThrottler,
-  TaskThrottler,
+  validateIban,
 } from "@gnu-taler/taler-util";
 import type { HttpRequestLibrary } from "@gnu-taler/taler-util/http";
 import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http";
@@ -147,7 +145,6 @@ import {
   CoinSourceType,
   ConfigRecordKey,
   DenominationRecord,
-  ExchangeDetailsRecord,
   WalletStoresV1,
   clearDatabase,
   exportDb,
@@ -253,22 +250,22 @@ import {
   createRefreshGroup,
   processRefreshGroup,
 } from "./operations/refresh.js";
+import {
+  acceptTip,
+  computeRewardTransactionStatus,
+  prepareTip,
+  processTip,
+} from "./operations/reward.js";
 import {
   runIntegrationTest,
   runIntegrationTest2,
   testPay,
   waitTransactionState,
-  waitUntilTransactionsFinal,
   waitUntilRefreshesDone,
-  withdrawTestBalance,
   waitUntilTasksProcessed,
+  waitUntilTransactionsFinal,
+  withdrawTestBalance,
 } from "./operations/testing.js";
-import {
-  acceptTip,
-  computeRewardTransactionStatus,
-  prepareTip,
-  processTip,
-} from "./operations/reward.js";
 import {
   abortTransaction,
   deleteTransaction,
@@ -295,6 +292,13 @@ import {
   selectBestForOverlappingDenominations,
   selectMinimumFee,
 } from "./util/denominations.js";
+import {
+  convertDepositAmount,
+  convertPeerPushAmount,
+  convertWithdrawalAmount,
+  getMaxDepositAmount,
+  getMaxPeerPushAmount,
+} from "./util/instructedAmountConversion.js";
 import { checkDbInvariant } from "./util/invariants.js";
 import {
   AsyncCondition,
@@ -320,14 +324,6 @@ import {
   WalletCoreApiClient,
   WalletCoreResponseType,
 } from "./wallet-api-types.js";
-import {
-  convertDepositAmount,
-  getMaxDepositAmount,
-  convertPeerPushAmount,
-  getMaxPeerPushAmount,
-  convertWithdrawalAmount,
-} from "./util/instructedAmountConversion.js";
-import { IDBFactory } from "@gnu-taler/idb-bridge";
 
 const logger = new Logger("wallet.ts");
 

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