diff options
Diffstat (limited to 'packages/taler-harness/src')
13 files changed, 139 insertions, 47 deletions
diff --git a/packages/taler-harness/src/bench1.ts b/packages/taler-harness/src/bench1.ts index b78fadf0b..428114e0e 100644 --- a/packages/taler-harness/src/bench1.ts +++ b/packages/taler-harness/src/bench1.ts @@ -29,6 +29,7 @@ import { } from "@gnu-taler/taler-util"; import { AccessStats, + applyRunConfigDefaults, createNativeWalletHost2, Wallet, WalletApiOperation, @@ -82,6 +83,10 @@ export async function runBench1(configJson: any): Promise<void> { // No persistent DB storage. persistentStoragePath: undefined, httpLib: harnessHttpLib, + }); + wallet = res.wallet; + getDbStats = res.getDbStats; + await wallet.client.call(WalletApiOperation.InitWallet, { config: { testing: { insecureTrustExchange: trustExchange, @@ -89,16 +94,13 @@ export async function runBench1(configJson: any): Promise<void> { features: {}, }, }); - wallet = res.wallet; - getDbStats = res.getDbStats; - await wallet.client.call(WalletApiOperation.InitWallet, {}); } logger.trace(`Starting withdrawal amount=${withdrawAmount}`); let start = Date.now(); await wallet.client.call(WalletApiOperation.WithdrawTestBalance, { - amount: b1conf.currency + ":" + withdrawAmount as AmountString, + amount: (b1conf.currency + ":" + withdrawAmount) as AmountString, corebankApiBaseUrl: b1conf.bank, exchangeBaseUrl: b1conf.exchange, }); @@ -117,7 +119,7 @@ export async function runBench1(configJson: any): Promise<void> { start = Date.now(); await wallet.client.call(WalletApiOperation.CreateDepositGroup, { - amount: b1conf.currency + ":10" as AmountString, + amount: (b1conf.currency + ":10") as AmountString, depositPaytoUri: b1conf.payto, }); diff --git a/packages/taler-harness/src/bench2.ts b/packages/taler-harness/src/bench2.ts index c85bd6a5d..90924caec 100644 --- a/packages/taler-harness/src/bench2.ts +++ b/packages/taler-harness/src/bench2.ts @@ -27,6 +27,7 @@ import { } from "@gnu-taler/taler-util"; import { createPlatformHttpLib } from "@gnu-taler/taler-util/http"; import { + applyRunConfigDefaults, CryptoDispatcher, SynchronousCryptoWorkerFactoryPlain, Wallet, @@ -67,6 +68,8 @@ export async function runBench2(configJson: any): Promise<void> { const reserveAmount = (numDeposits + 1) * 10; + const defaultConfig = applyRunConfigDefaults(); + for (let i = 0; i < numIter; i++) { const exchangeInfo = await downloadExchangeInfo(benchConf.exchange, http); @@ -89,7 +92,7 @@ export async function runBench2(configJson: any): Promise<void> { console.log("reserve found"); const d1 = findDenomOrThrow(exchangeInfo, `${curr}:8` as AmountString, { - denomselAllowLate: Wallet.defaultConfig.testing.denomselAllowLate, + denomselAllowLate: defaultConfig.testing.denomselAllowLate, }); for (let j = 0; j < numDeposits; j++) { @@ -118,10 +121,10 @@ export async function runBench2(configJson: any): Promise<void> { const refreshDenoms = [ findDenomOrThrow(exchangeInfo, `${curr}:1` as AmountString, { - denomselAllowLate: Wallet.defaultConfig.testing.denomselAllowLate, + denomselAllowLate: defaultConfig.testing.denomselAllowLate, }), findDenomOrThrow(exchangeInfo, `${curr}:1` as AmountString, { - denomselAllowLate: Wallet.defaultConfig.testing.denomselAllowLate, + denomselAllowLate: defaultConfig.testing.denomselAllowLate, }), ]; diff --git a/packages/taler-harness/src/bench3.ts b/packages/taler-harness/src/bench3.ts index c810f6804..f138dff68 100644 --- a/packages/taler-harness/src/bench3.ts +++ b/packages/taler-harness/src/bench3.ts @@ -93,6 +93,10 @@ export async function runBench3(configJson: any): Promise<void> { // No persistent DB storage. persistentStoragePath: undefined, httpLib: myHttpLib, + }); + wallet = res.wallet; + getDbStats = res.getDbStats; + await wallet.client.call(WalletApiOperation.InitWallet, { config: { features: {}, testing: { @@ -100,16 +104,13 @@ export async function runBench3(configJson: any): Promise<void> { }, }, }); - wallet = res.wallet; - getDbStats = res.getDbStats; - await wallet.client.call(WalletApiOperation.InitWallet, {}); } logger.trace(`Starting withdrawal amount=${withdrawAmount}`); let start = Date.now(); await wallet.client.call(WalletApiOperation.WithdrawTestBalance, { - amount: b3conf.currency + ":" + withdrawAmount as AmountString, + amount: (b3conf.currency + ":" + withdrawAmount) as AmountString, corebankApiBaseUrl: b3conf.bank, exchangeBaseUrl: b3conf.exchange, }); @@ -130,7 +131,7 @@ export async function runBench3(configJson: any): Promise<void> { let payto = b3conf.paytoTemplate.replace("${id}", merchID.toString()); await wallet.client.call(WalletApiOperation.CreateDepositGroup, { - amount: b3conf.currency + ":10" as AmountString, + amount: (b3conf.currency + ":10") as AmountString, depositPaytoUri: payto, }); diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts index 9418a3256..587860547 100644 --- a/packages/taler-harness/src/harness/harness.ts +++ b/packages/taler-harness/src/harness/harness.ts @@ -1961,6 +1961,7 @@ export class WalletService { "serve", "--unix-path", unixPath, + "--no-init", ], `wallet-${this.opts.name}`, ); diff --git a/packages/taler-harness/src/harness/helpers.ts b/packages/taler-harness/src/harness/helpers.ts index f567a87ff..46dc9f9d4 100644 --- a/packages/taler-harness/src/harness/helpers.ts +++ b/packages/taler-harness/src/harness/helpers.ts @@ -31,6 +31,7 @@ import { MerchantApiClient, MerchantContractTerms, NotificationType, + PartialWalletRunConfig, PreparePayResultType, TalerCorebankApiClient, TransactionMajorState, @@ -406,6 +407,7 @@ export interface CreateWalletArgs { name: string; persistent?: boolean; overrideDbPath?: string; + config?: PartialWalletRunConfig; } export async function createWalletDaemonWithClient( @@ -431,8 +433,13 @@ export async function createWalletDaemonWithClient( }, }); await walletClient.connect(); + const defaultRunConfig = { + testing: { + skipDefaults: true, + }, + }; await walletClient.client.call(WalletApiOperation.InitWallet, { - skipDefaults: true, + config: args.config ?? defaultRunConfig, }); return { walletClient, walletService }; diff --git a/packages/taler-harness/src/integrationtests/test-exchange-deposit.ts b/packages/taler-harness/src/integrationtests/test-exchange-deposit.ts index ca8b9e375..05e6e153b 100644 --- a/packages/taler-harness/src/integrationtests/test-exchange-deposit.ts +++ b/packages/taler-harness/src/integrationtests/test-exchange-deposit.ts @@ -28,7 +28,6 @@ import { createPlatformHttpLib } from "@gnu-taler/taler-util/http"; import { CryptoDispatcher, SynchronousCryptoWorkerFactoryPlain, - Wallet, } from "@gnu-taler/taler-wallet-core"; import { checkReserve, @@ -76,9 +75,11 @@ export async function runExchangeDepositTest(t: GlobalTestState) { await checkReserve(http, exchange.baseUrl, reserveKeyPair.pub); - const d1 = findDenomOrThrow(exchangeInfo, "TESTKUDOS:8" as AmountString, { - denomselAllowLate: Wallet.defaultConfig.testing.denomselAllowLate, - }); + const d1 = findDenomOrThrow( + exchangeInfo, + "TESTKUDOS:8" as AmountString, + {}, + ); const coin = await withdrawCoin({ http, diff --git a/packages/taler-harness/src/integrationtests/test-exchange-purse.ts b/packages/taler-harness/src/integrationtests/test-exchange-purse.ts index 8ff740732..83ee13d4e 100644 --- a/packages/taler-harness/src/integrationtests/test-exchange-purse.ts +++ b/packages/taler-harness/src/integrationtests/test-exchange-purse.ts @@ -29,14 +29,12 @@ import { j2s, PeerContractTerms, TalerError, - TalerPreciseTimestamp, } from "@gnu-taler/taler-util"; import { CryptoDispatcher, EncryptContractRequest, SpendCoinDetails, SynchronousCryptoWorkerFactoryPlain, - Wallet, } from "@gnu-taler/taler-wallet-core"; import { checkReserve, @@ -94,9 +92,11 @@ export async function runExchangePurseTest(t: GlobalTestState) { await checkReserve(http, exchange.baseUrl, reserveKeyPair.pub); - const d1 = findDenomOrThrow(exchangeInfo, "TESTKUDOS:8" as AmountString, { - denomselAllowLate: Wallet.defaultConfig.testing.denomselAllowLate, - }); + const d1 = findDenomOrThrow( + exchangeInfo, + "TESTKUDOS:8" as AmountString, + {}, + ); const coin = await withdrawCoin({ http, @@ -110,9 +110,6 @@ export async function runExchangePurseTest(t: GlobalTestState) { }); const amount = "TESTKUDOS:5" as AmountString; - const purseFee = "TESTKUDOS:0"; - - const mergeTimestamp = TalerPreciseTimestamp.now(); const contractTerms: PeerContractTerms = { amount, diff --git a/packages/taler-harness/src/integrationtests/test-kyc.ts b/packages/taler-harness/src/integrationtests/test-kyc.ts index cc756f617..a9ef654fd 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc.ts @@ -18,15 +18,14 @@ * Imports. */ import { - TalerCorebankApiClient, Duration, - j2s, Logger, NotificationType, + TalerCorebankApiClient, TransactionMajorState, TransactionMinorState, TransactionType, - encodeCrock, + j2s, } from "@gnu-taler/taler-util"; import { createPlatformHttpLib } from "@gnu-taler/taler-util/http"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; @@ -35,12 +34,12 @@ import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; import { BankService, ExchangeService, - generateRandomPayto, GlobalTestState, MerchantService, - setupDb, WalletClient, WalletService, + generateRandomPayto, + setupDb, } from "../harness/harness.js"; import { EnvOptions, SimpleTestEnvironmentNg } from "../harness/helpers.js"; @@ -199,7 +198,11 @@ export async function createKycTestkudosEnvironment( }); await walletClient.connect(); await walletClient.client.call(WalletApiOperation.InitWallet, { - skipDefaults: true, + config: { + testing: { + skipDefaults: true, + }, + }, }); console.log("setup done!"); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-config.ts b/packages/taler-harness/src/integrationtests/test-wallet-config.ts new file mode 100644 index 000000000..81a723473 --- /dev/null +++ b/packages/taler-harness/src/integrationtests/test-wallet-config.ts @@ -0,0 +1,65 @@ +/* + This file is part of GNU Taler + (C) 2020 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +/** + * Imports. + */ +import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; +import { GlobalTestState } from "../harness/harness.js"; +import { createWalletDaemonWithClient } from "../harness/helpers.js"; + +export async function runWalletConfigTest(t: GlobalTestState) { + const w1 = await createWalletDaemonWithClient(t, { + name: "w1", + config: { + builtin: { + exchanges: [], + }, + }, + }); + + const exchangesResp1 = await w1.walletClient.call( + WalletApiOperation.ListExchanges, + {}, + ); + + t.assertDeepEqual(exchangesResp1.exchanges.length, 0); + + const w2 = await createWalletDaemonWithClient(t, { + name: "w2", + config: { + builtin: { + exchanges: [ + { + exchangeBaseUrl: "https://exchange.demo.taler.net/", + }, + { + exchangeBaseUrl: "https://exchange.test.taler.net/", + }, + ], + }, + }, + }); + + const exchangesResp2 = await w2.walletClient.call( + WalletApiOperation.ListExchanges, + {}, + ); + + t.assertDeepEqual(exchangesResp2.exchanges.length, 2); +} + +runWalletConfigTest.suites = ["wallet"]; diff --git a/packages/taler-harness/src/integrationtests/test-wallet-dbless.ts b/packages/taler-harness/src/integrationtests/test-wallet-dbless.ts index 1c4c16e0f..fadb34732 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-dbless.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-dbless.ts @@ -25,9 +25,9 @@ import { TalerError, } from "@gnu-taler/taler-util"; import { + applyRunConfigDefaults, CryptoDispatcher, SynchronousCryptoWorkerFactoryPlain, - Wallet, } from "@gnu-taler/taler-wallet-core"; import { checkReserve, @@ -87,8 +87,10 @@ export async function runWalletDblessTest(t: GlobalTestState) { await checkReserve(http, exchange.baseUrl, reserveKeyPair.pub); + const defaultConfig = applyRunConfigDefaults(); + const d1 = findDenomOrThrow(exchangeInfo, "TESTKUDOS:8" as AmountString, { - denomselAllowLate: Wallet.defaultConfig.testing.denomselAllowLate, + denomselAllowLate: defaultConfig.testing.denomselAllowLate, }); const coin = await withdrawCoin({ @@ -131,10 +133,10 @@ export async function runWalletDblessTest(t: GlobalTestState) { const refreshDenoms = [ findDenomOrThrow(exchangeInfo, "TESTKUDOS:1" as AmountString, { - denomselAllowLate: Wallet.defaultConfig.testing.denomselAllowLate, + denomselAllowLate: defaultConfig.testing.denomselAllowLate, }), findDenomOrThrow(exchangeInfo, "TESTKUDOS:1" as AmountString, { - denomselAllowLate: Wallet.defaultConfig.testing.denomselAllowLate, + denomselAllowLate: defaultConfig.testing.denomselAllowLate, }), ]; diff --git a/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts b/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts index 47c96e0e2..3341b6a53 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts @@ -17,6 +17,14 @@ /** * Imports. */ +import { + ExchangeEntryStatus, + NotificationType, + TalerError, + TalerErrorCode, + WalletNotification, + j2s, +} from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; import { @@ -27,14 +35,6 @@ import { WalletService, setupDb, } from "../harness/harness.js"; -import { - ExchangeEntryStatus, - NotificationType, - TalerError, - TalerErrorCode, - WalletNotification, - j2s, -} from "@gnu-taler/taler-util"; import { withdrawViaBankV2 } from "../harness/helpers.js"; /** @@ -96,7 +96,11 @@ export async function runWalletDd48Test(t: GlobalTestState) { }); await walletClient.connect(); await walletClient.client.call(WalletApiOperation.InitWallet, { - skipDefaults: true, + config: { + testing: { + skipDefaults: true, + }, + }, }); await walletClient.call(WalletApiOperation.AddExchange, { @@ -152,7 +156,7 @@ export async function runWalletDd48Test(t: GlobalTestState) { x.type === NotificationType.ExchangeStateTransition && x.oldExchangeState == null && x.newExchangeState.exchangeEntryStatus === - ExchangeEntryStatus.Ephemeral, + ExchangeEntryStatus.Ephemeral, ), ); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts index c0c32a008..28b73a9f9 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts @@ -119,7 +119,11 @@ export async function runWalletNotificationsTest(t: GlobalTestState) { }); await walletClient.connect(); await walletClient.client.call(WalletApiOperation.InitWallet, { - skipDefaults: true, + config: { + testing: { + skipDefaults: true, + } + } }); const bankAccessApiClient = new TalerCorebankApiClient( diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts index b57d82939..73619a047 100644 --- a/packages/taler-harness/src/integrationtests/testrunner.ts +++ b/packages/taler-harness/src/integrationtests/testrunner.ts @@ -89,6 +89,7 @@ import { runWalletBackupDoublespendTest } from "./test-wallet-backup-doublespend import { runWalletBalanceNotificationsTest } from "./test-wallet-balance-notifications.js"; import { runWalletBalanceTest } from "./test-wallet-balance.js"; import { runWalletCliTerminationTest } from "./test-wallet-cli-termination.js"; +import { runWalletConfigTest } from "./test-wallet-config.js"; import { runWalletCryptoWorkerTest } from "./test-wallet-cryptoworker.js"; import { runWalletDblessTest } from "./test-wallet-dbless.js"; import { runWalletDd48Test } from "./test-wallet-dd48.js"; @@ -196,6 +197,7 @@ const allTests: TestMainFunction[] = [ runOtpTest, runWalletBalanceNotificationsTest, runExchangeManagementTest, + runWalletConfigTest, ]; export interface TestRunSpec { |