diff --git a/packages/idb-bridge/src/tree/b+tree.ts b/packages/idb-bridge/src/tree/b+tree.ts index 59a49baa3..ea09d0c0c 100644 --- a/packages/idb-bridge/src/tree/b+tree.ts +++ b/packages/idb-bridge/src/tree/b+tree.ts @@ -948,8 +948,11 @@ export default class BTree /** Ensures mutations are allowed, reversing the effect of freeze(). */ unfreeze() { + // @ts-ignore delete this.clear; + // @ts-ignore delete this.set; + // @ts-ignore delete this.editRange; } diff --git a/packages/taler-integrationtests/src/harness.ts b/packages/taler-integrationtests/src/harness.ts index e40798b4b..b71fe4104 100644 --- a/packages/taler-integrationtests/src/harness.ts +++ b/packages/taler-integrationtests/src/harness.ts @@ -91,6 +91,7 @@ import { } from "./merchantApiTypes"; import { ApplyRefundResponse } from "taler-wallet-core"; import { PendingOperationsResponse } from "taler-wallet-core"; +import { CoinConfig } from "./denomStructures"; const exec = util.promisify(require("child_process").exec); @@ -221,96 +222,6 @@ export class ProcessWrapper { } } -interface CoinConfig { - name: string; - value: string; - durationWithdraw: string; - durationSpend: string; - durationLegal: string; - feeWithdraw: string; - feeDeposit: string; - feeRefresh: string; - feeRefund: string; - rsaKeySize: number; -} - -const coinCommon = { - durationLegal: "3 years", - durationSpend: "2 years", - durationWithdraw: "7 days", - rsaKeySize: 1024, -}; - -export const coin_ct1 = (curr: string): CoinConfig => ({ - ...coinCommon, - name: `${curr}_ct1`, - value: `${curr}:0.01`, - feeDeposit: `${curr}:0.00`, - feeRefresh: `${curr}:0.01`, - feeRefund: `${curr}:0.00`, - feeWithdraw: `${curr}:0.01`, -}); - -export const coin_ct10 = (curr: string): CoinConfig => ({ - ...coinCommon, - name: `${curr}_ct10`, - value: `${curr}:0.10`, - feeDeposit: `${curr}:0.01`, - feeRefresh: `${curr}:0.01`, - feeRefund: `${curr}:0.00`, - feeWithdraw: `${curr}:0.01`, -}); - -export const coin_u1 = (curr: string): CoinConfig => ({ - ...coinCommon, - name: `${curr}_u1`, - value: `${curr}:1`, - feeDeposit: `${curr}:0.02`, - feeRefresh: `${curr}:0.02`, - feeRefund: `${curr}:0.02`, - feeWithdraw: `${curr}:0.02`, -}); - -export const coin_u2 = (curr: string): CoinConfig => ({ - ...coinCommon, - name: `${curr}_u2`, - value: `${curr}:2`, - feeDeposit: `${curr}:0.02`, - feeRefresh: `${curr}:0.02`, - feeRefund: `${curr}:0.02`, - feeWithdraw: `${curr}:0.02`, -}); - -export const coin_u4 = (curr: string): CoinConfig => ({ - ...coinCommon, - name: `${curr}_u4`, - value: `${curr}:4`, - feeDeposit: `${curr}:0.02`, - feeRefresh: `${curr}:0.02`, - feeRefund: `${curr}:0.02`, - feeWithdraw: `${curr}:0.02`, -}); - -export const coin_u8 = (curr: string): CoinConfig => ({ - ...coinCommon, - name: `${curr}_u8`, - value: `${curr}:8`, - feeDeposit: `${curr}:0.16`, - feeRefresh: `${curr}:0.16`, - feeRefund: `${curr}:0.16`, - feeWithdraw: `${curr}:0.16`, -}); - -const coin_u10 = (curr: string): CoinConfig => ({ - ...coinCommon, - name: `${curr}_u10`, - value: `${curr}:10`, - feeDeposit: `${curr}:0.2`, - feeRefresh: `${curr}:0.2`, - feeRefund: `${curr}:0.2`, - feeWithdraw: `${curr}:0.2`, -}); - export class GlobalTestParams { testDir: string; } @@ -832,16 +743,6 @@ const codecForWithdrawalOperationInfo = (): Codec => .property("taler_withdraw_uri", codecForString()) .build("WithdrawalOperationInfo"); -export const defaultCoinConfig = [ - coin_ct1, - coin_ct10, - coin_u1, - coin_u10, - coin_u2, - coin_u4, - coin_u8, -]; - export interface ExchangeConfig { name: string; currency: string; @@ -1003,6 +904,14 @@ export class ExchangeService implements ExchangeServiceInterface { config.write(this.configFilename); } + addCoinConfigList(ccs: CoinConfig[]) { + const config = Configuration.load(this.configFilename); + ccs.forEach((cc) => + setCoin(config, cc), + ); + config.write(this.configFilename); + } + get masterPub() { return encodeCrock(this.keyPair.eddsaPub); } diff --git a/packages/taler-integrationtests/src/helpers.ts b/packages/taler-integrationtests/src/helpers.ts index e248b4a7d..bdccdba8a 100644 --- a/packages/taler-integrationtests/src/helpers.ts +++ b/packages/taler-integrationtests/src/helpers.ts @@ -31,7 +31,6 @@ import { MerchantService, setupDb, BankService, - defaultCoinConfig, ExchangeBankAccount, MerchantServiceInterface, BankApi, @@ -46,6 +45,7 @@ import { ContractTerms, } from "taler-wallet-core"; import { FaultInjectedMerchantService } from "./faultInjection"; +import { defaultCoinConfig } from "./denomStructures"; export interface SimpleTestEnvironment { commonDb: DbInfo; diff --git a/packages/taler-integrationtests/src/test-bank-api.ts b/packages/taler-integrationtests/src/test-bank-api.ts index 51cf2e83a..b6dd3f1b9 100644 --- a/packages/taler-integrationtests/src/test-bank-api.ts +++ b/packages/taler-integrationtests/src/test-bank-api.ts @@ -20,20 +20,17 @@ import { runTest, GlobalTestState, - MerchantPrivateApi, WalletCli, - defaultCoinConfig, ExchangeService, setupDb, BankService, MerchantService, BankApi, - BankUser, BankAccessApi, CreditDebitIndicator, } from "./harness"; -import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; import { createEddsaKeyPair, encodeCrock } from "taler-wallet-core"; +import { defaultCoinConfig } from "./denomStructures"; /** * Run test for basic, bank-integrated withdrawal. diff --git a/packages/taler-integrationtests/src/test-exchange-management.ts b/packages/taler-integrationtests/src/test-exchange-management.ts index 81d2efb78..be990d9b6 100644 --- a/packages/taler-integrationtests/src/test-exchange-management.ts +++ b/packages/taler-integrationtests/src/test-exchange-management.ts @@ -25,11 +25,9 @@ import { BankService, ExchangeService, MerchantService, - defaultCoinConfig, BankApi, BankAccessApi, } from "./harness"; -import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; import { PreparePayResultType, ExchangesListRespose, @@ -40,6 +38,7 @@ import { FaultInjectedExchangeService, FaultInjectionResponseContext, } from "./faultInjection"; +import { defaultCoinConfig } from "./denomStructures"; /** * Test if the wallet handles outdated exchange versions correct.y diff --git a/packages/taler-integrationtests/src/test-payment-fault.ts b/packages/taler-integrationtests/src/test-payment-fault.ts index a29c62374..8a8678a21 100644 --- a/packages/taler-integrationtests/src/test-payment-fault.ts +++ b/packages/taler-integrationtests/src/test-payment-fault.ts @@ -29,7 +29,6 @@ import { setupDb, BankService, WalletCli, - defaultCoinConfig, MerchantPrivateApi, BankApi, BankAccessApi, @@ -40,6 +39,7 @@ import { FaultInjectionResponseContext, } from "./faultInjection"; import { CoreApiResponse } from "taler-wallet-core"; +import { defaultCoinConfig } from "./denomStructures"; /** * Run test for basic, bank-integrated withdrawal. diff --git a/packages/taler-integrationtests/src/test-payment-multiple.ts b/packages/taler-integrationtests/src/test-payment-multiple.ts index 8be8a90f5..8dad515c6 100644 --- a/packages/taler-integrationtests/src/test-payment-multiple.ts +++ b/packages/taler-integrationtests/src/test-payment-multiple.ts @@ -25,11 +25,11 @@ import { ExchangeService, MerchantService, WalletCli, - coin_ct10, - coin_u1, + MerchantPrivateApi, } from "./harness"; import { withdrawViaBank } from "./helpers"; +import { coin_ct10, coin_u1 } from "./denomStructures"; async function setupTest( t: GlobalTestState, diff --git a/packages/taler-integrationtests/src/test-timetravel-autorefresh.ts b/packages/taler-integrationtests/src/test-timetravel-autorefresh.ts index 1f2202091..24e9116df 100644 --- a/packages/taler-integrationtests/src/test-timetravel-autorefresh.ts +++ b/packages/taler-integrationtests/src/test-timetravel-autorefresh.ts @@ -24,6 +24,8 @@ import { ExchangeService, MerchantService, WalletCli, + setupDb, + BankService, } from "./harness"; import { createSimpleTestkudosEnvironment, @@ -37,6 +39,7 @@ import { ConfirmPayResultType, } from "taler-wallet-core"; import { PendingOperationsResponse } from "taler-wallet-core/lib/types/pending"; +import { defaultCoinConfig, makeNoFeeCoinConfig } from "./denomStructures"; async function applyTimeTravel( timetravelDuration: Duration, @@ -71,12 +74,66 @@ async function applyTimeTravel( runTest(async (t: GlobalTestState) => { // Set up test environment - const { - wallet, - bank, - exchange, - merchant, - } = await createSimpleTestkudosEnvironment(t); + 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, + }); + + const merchant = await MerchantService.create(t, { + name: "testmerchant-1", + currency: "TESTKUDOS", + httpPort: 8083, + database: db.connStr, + }); + + const exchangeBankAccount = await bank.createExchangeAccount( + "MyExchange", + "x", + ); + exchange.addBankAccount("1", exchangeBankAccount); + + bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri); + + await bank.start(); + + await bank.pingUntilAvailable(); + + exchange.addCoinConfigList(makeNoFeeCoinConfig("TESTKUDOS")); + + await exchange.start(); + await exchange.pingUntilAvailable(); + + merchant.addExchange(exchange); + + await merchant.start(); + await merchant.pingUntilAvailable(); + + await merchant.addInstance({ + id: "minst1", + name: "minst1", + paytoUris: ["payto://x-taler-bank/minst1"], + }); + + await merchant.addInstance({ + id: "default", + name: "Default Instance", + paytoUris: [`payto://x-taler-bank/merchant-default`], + }); + + console.log("setup done!"); + + const wallet = new WalletCli(t); // Withdraw digital cash into the wallet.