diff options
20 files changed, 618 insertions, 235 deletions
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts index 77b6f0e11..fd34fe241 100644 --- a/packages/taler-harness/src/harness/harness.ts +++ b/packages/taler-harness/src/harness/harness.ts @@ -903,8 +903,8 @@ export interface BankServiceHandle { export type BankService = BankServiceHandle; export const BankService = useLibeufinBank - ? FakebankService - : LibeufinBankService; + ? LibeufinBankService + : FakebankService; export interface ExchangeConfig { name: string; diff --git a/packages/taler-harness/src/harness/helpers.ts b/packages/taler-harness/src/harness/helpers.ts index 4e67854f7..efcef8706 100644 --- a/packages/taler-harness/src/harness/helpers.ts +++ b/packages/taler-harness/src/harness/helpers.ts @@ -635,6 +635,16 @@ export interface FaultyMerchantTestEnvironment { walletClient: WalletClient; } +export interface FaultyMerchantTestEnvironmentNg { + commonDb: DbInfo; + bankClient: TalerCorebankApiClient; + exchange: ExchangeService; + faultyExchange: FaultInjectedExchangeService; + merchant: MerchantService; + faultyMerchant: FaultInjectedMerchantService; + walletClient: WalletClient; +} + /** * Run a test case with a simple TESTKUDOS Taler environment, consisting * of one exchange, one bank and one merchant. diff --git a/packages/taler-harness/src/integrationtests/test-bank-api.ts b/packages/taler-harness/src/integrationtests/test-bank-api.ts index 490931d83..58f8bb106 100644 --- a/packages/taler-harness/src/integrationtests/test-bank-api.ts +++ b/packages/taler-harness/src/integrationtests/test-bank-api.ts @@ -26,8 +26,8 @@ import { } from "@gnu-taler/taler-util"; import { defaultCoinConfig } from "../harness/denomStructures.js"; import { + BankService, ExchangeService, - FakebankService, GlobalTestState, MerchantService, generateRandomPayto, @@ -42,7 +42,7 @@ export async function runBankApiTest(t: GlobalTestState) { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { currency: "TESTKUDOS", httpPort: 8082, database: db.connStr, @@ -63,13 +63,20 @@ export async function runBankApiTest(t: GlobalTestState) { database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - exchange.addBankAccount("1", exchangeBankAccount); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + + let wireGatewayApiBaseUrl = new URL("accounts/exchange/taler-wire-gateway/", bank.baseUrl).href; + await exchange.addBankAccount("1", { + accountName: exchangeBankUsername, + accountPassword: exchangeBankPassword, + wireGatewayApiBaseUrl, + accountPaytoUri: exchangePaytoUri, + }); - bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri); + bank.setSuggestedExchange(exchange, exchangePaytoUri); await bank.start(); @@ -99,7 +106,20 @@ export async function runBankApiTest(t: GlobalTestState) { console.log("setup done!"); - const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); const bankUser = await bankClient.registerAccount("user1", "pw1"); @@ -124,11 +144,11 @@ export async function runBankApiTest(t: GlobalTestState) { const res = createEddsaKeyPair(); const wireGatewayApiClient = new WireGatewayApiClient( - exchangeBankAccount.wireGatewayApiBaseUrl, + wireGatewayApiBaseUrl, { auth: { - username: exchangeBankAccount.accountName, - password: exchangeBankAccount.accountPassword, + username: "admin", + password: "adminpw", }, }, ); diff --git a/packages/taler-harness/src/integrationtests/test-exchange-management-fault.ts b/packages/taler-harness/src/integrationtests/test-exchange-management-fault.ts index 5f02c2080..801162ac8 100644 --- a/packages/taler-harness/src/integrationtests/test-exchange-management-fault.ts +++ b/packages/taler-harness/src/integrationtests/test-exchange-management-fault.ts @@ -31,8 +31,8 @@ import { FaultInjectionResponseContext, } from "../harness/faultInjection.js"; import { + BankService, ExchangeService, - FakebankService, GlobalTestState, MerchantService, WalletCli, @@ -50,7 +50,7 @@ export async function runExchangeManagementFaultTest( const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -71,11 +71,17 @@ export async function runExchangeManagementFaultTest( database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - exchange.addBankAccount("1", exchangeBankAccount); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + + await exchange.addBankAccount("1", { + accountName: exchangeBankUsername, + accountPassword: exchangeBankPassword, + wireGatewayApiBaseUrl: new URL("accounts/exchange/taler-wire-gateway/", bank.baseUrl).href, + accountPaytoUri: exchangePaytoUri, + }); const faultyExchange = new FaultInjectedExchangeService(t, exchange, 8091); // Base URL must contain port that the proxy is listening on. @@ -85,7 +91,7 @@ export async function runExchangeManagementFaultTest( bank.setSuggestedExchange( faultyExchange, - exchangeBankAccount.accountPaytoUri, + exchangePaytoUri, ); await bank.start(); @@ -262,9 +268,19 @@ export async function runExchangeManagementFaultTest( // Create withdrawal operation - const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); const user = await bankClient.createRandomBankUser(); + bankClient.setAuth({ + username: user.username, + password: user.password, + }); + const wop = await bankClient.createWithdrawalOperation( user.username, "TESTKUDOS:10", diff --git a/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts b/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts index 181392ac8..4f2fb1ee4 100644 --- a/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts +++ b/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts @@ -25,6 +25,7 @@ import { Duration, ExchangeKeysJson, Logger, + TalerCorebankApiClient, } from "@gnu-taler/taler-util"; import { createPlatformHttpLib, @@ -32,8 +33,8 @@ import { } from "@gnu-taler/taler-util/http"; import { makeNoFeeCoinConfig } from "../harness/denomStructures.js"; import { + BankService, ExchangeService, - FakebankService, generateRandomPayto, GlobalTestState, MerchantService, @@ -42,7 +43,7 @@ import { import { applyTimeTravelV2, createWalletDaemonWithClient, - withdrawViaBankV2, + withdrawViaBankV3, } from "../harness/helpers.js"; const logger = new Logger("test-exchange-timetravel.ts"); @@ -103,7 +104,7 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -124,18 +125,39 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) { database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - exchange.addBankAccount("1", exchangeBankAccount); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(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, exchangeBankAccount.accountPaytoUri); + bank.setSuggestedExchange(exchange, exchangePaytoUri); await bank.start(); await bank.pingUntilAvailable(); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); + exchange.addCoinConfigList(makeNoFeeCoinConfig("TESTKUDOS")); await exchange.start(); @@ -166,9 +188,9 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) { // Withdraw digital cash into the wallet. - const wres = await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV3(t, { walletClient, - bank, + bankClient, exchange, amount: "TESTKUDOS:15", }); diff --git a/packages/taler-harness/src/integrationtests/test-fee-regression.ts b/packages/taler-harness/src/integrationtests/test-fee-regression.ts index 58002d5b7..14eb3d147 100644 --- a/packages/taler-harness/src/integrationtests/test-fee-regression.ts +++ b/packages/taler-harness/src/integrationtests/test-fee-regression.ts @@ -19,19 +19,20 @@ */ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { + BankService, ExchangeService, - FakebankService, GlobalTestState, MerchantService, generateRandomPayto, setupDb, } from "../harness/harness.js"; import { - SimpleTestEnvironmentNg, + SimpleTestEnvironmentNg3, createWalletDaemonWithClient, makeTestPaymentV2, - withdrawViaBankV2, + withdrawViaBankV3, } from "../harness/helpers.js"; +import { TalerCorebankApiClient } from "@gnu-taler/taler-util"; /** * Run a test case with a simple TESTKUDOS Taler environment, consisting @@ -39,10 +40,10 @@ import { */ export async function createMyTestkudosEnvironment( t: GlobalTestState, -): Promise<SimpleTestEnvironmentNg> { +): Promise<SimpleTestEnvironmentNg3> { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -63,18 +64,39 @@ export async function createMyTestkudosEnvironment( database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - exchange.addBankAccount("1", exchangeBankAccount); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(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, exchangeBankAccount.accountPaytoUri); + bank.setSuggestedExchange(exchange, exchangePaytoUri); await bank.start(); await bank.pingUntilAvailable(); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); + const coinCommon = { cipher: "RSA" as const, durationLegal: "3 years", @@ -160,8 +182,13 @@ export async function createMyTestkudosEnvironment( merchant, walletClient, walletService, - bank, - exchangeBankAccount, + bankClient, + exchangeBankAccount: { + accountName: '', + accountPassword: '', + accountPaytoUri: '', + wireGatewayApiBaseUrl: '', + }, }; } @@ -171,14 +198,14 @@ export async function createMyTestkudosEnvironment( export async function runFeeRegressionTest(t: GlobalTestState) { // Set up test environment - const { walletClient, bank, exchange, merchant } = + const { walletClient, bankClient, exchange, merchant } = await createMyTestkudosEnvironment(t); // Withdraw digital cash into the wallet. - const wres = await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV3(t, { walletClient, - bank, + bankClient, exchange, amount: "TESTKUDOS:1.92", }); diff --git a/packages/taler-harness/src/integrationtests/test-kyc.ts b/packages/taler-harness/src/integrationtests/test-kyc.ts index ec80c0fc8..213dd9df4 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc.ts @@ -32,8 +32,8 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import * as http from "node:http"; import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; import { + BankService, ExchangeService, - FakebankService, GlobalTestState, MerchantService, WalletClient, @@ -41,7 +41,7 @@ import { generateRandomPayto, setupDb, } from "../harness/harness.js"; -import { EnvOptions, SimpleTestEnvironmentNg } from "../harness/helpers.js"; +import { EnvOptions, SimpleTestEnvironmentNg3 } from "../harness/helpers.js"; const logger = new Logger("test-kyc.ts"); @@ -49,10 +49,10 @@ export async function createKycTestkudosEnvironment( t: GlobalTestState, coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")), opts: EnvOptions = {}, -): Promise<SimpleTestEnvironmentNg> { +): Promise<SimpleTestEnvironmentNg3> { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -73,18 +73,39 @@ export async function createKycTestkudosEnvironment( database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - exchange.addBankAccount("1", exchangeBankAccount); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(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, exchangeBankAccount.accountPaytoUri); + bank.setSuggestedExchange(exchange, exchangePaytoUri); await bank.start(); await bank.pingUntilAvailable(); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); + const ageMaskSpec = opts.ageMaskSpec; if (ageMaskSpec) { @@ -213,8 +234,13 @@ export async function createKycTestkudosEnvironment( merchant, walletClient, walletService, - bank, - exchangeBankAccount, + bankClient, + exchangeBankAccount: { + accountName: '', + accountPassword: '', + accountPaytoUri: '', + wireGatewayApiBaseUrl: '', + }, }; } @@ -310,17 +336,20 @@ async function runTestfakeKycService(): Promise<TestfakeKycService> { export async function runKycTest(t: GlobalTestState) { // Set up test environment - const { walletClient, bank, exchange, merchant } = + const { walletClient, bankClient, exchange, merchant } = await createKycTestkudosEnvironment(t); const kycServer = await runTestfakeKycService(); // Withdraw digital cash into the wallet. - const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl); - const amount = "TESTKUDOS:20"; const user = await bankClient.createRandomBankUser(); + bankClient.setAuth({ + username: user.username, + password: user.password, + }); + const wop = await bankClient.createWithdrawalOperation(user.username, amount); // Hand it to the wallet diff --git a/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts b/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts index 27e754b68..19f89ae2c 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-exchange-confusion.ts @@ -22,6 +22,7 @@ import { ConfirmPayResultType, MerchantApiClient, PreparePayResultType, + TalerCorebankApiClient, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { URL } from "url"; @@ -31,8 +32,8 @@ import { FaultInjectedMerchantService, } from "../harness/faultInjection.js"; import { + BankService, ExchangeService, - FakebankService, generateRandomPayto, GlobalTestState, harnessHttpLib, @@ -41,8 +42,8 @@ import { } from "../harness/harness.js"; import { createWalletDaemonWithClient, - FaultyMerchantTestEnvironment, - withdrawViaBankV2, + FaultyMerchantTestEnvironmentNg, + withdrawViaBankV3, } from "../harness/helpers.js"; /** @@ -51,10 +52,10 @@ import { */ export async function createConfusedMerchantTestkudosEnvironment( t: GlobalTestState, -): Promise<FaultyMerchantTestEnvironment> { +): Promise<FaultyMerchantTestEnvironmentNg> { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -83,21 +84,39 @@ export async function createConfusedMerchantTestkudosEnvironment( config.setString("exchange", "base_url", "http://localhost:9081/"); }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - exchange.addBankAccount("1", exchangeBankAccount); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); - bank.setSuggestedExchange( - faultyExchange, - exchangeBankAccount.accountPaytoUri, - ); + 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(); await bank.pingUntilAvailable(); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); + exchange.addOfferedCoins(defaultCoinConfig); await exchange.start(); @@ -132,8 +151,7 @@ export async function createConfusedMerchantTestkudosEnvironment( exchange, merchant, walletClient, - bank, - exchangeBankAccount, + bankClient, faultyMerchant, faultyExchange, }; @@ -146,14 +164,14 @@ export async function createConfusedMerchantTestkudosEnvironment( export async function runMerchantExchangeConfusionTest(t: GlobalTestState) { // Set up test environment - const { walletClient, bank, faultyExchange, faultyMerchant } = + const { walletClient, bankClient, faultyExchange, faultyMerchant } = await createConfusedMerchantTestkudosEnvironment(t); // Withdraw digital cash into the wallet. - const wres = await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV3(t, { walletClient, - bank, + bankClient, exchange: faultyExchange, amount: "TESTKUDOS:20", }); diff --git a/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts b/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts index 6a26b1325..8a22eae57 100644 --- a/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts +++ b/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts @@ -21,6 +21,7 @@ import { ConfirmPayResultType, MerchantApiClient, PreparePayResultType, + TalerCorebankApiClient, URL, encodeCrock, getRandomBytes, @@ -28,21 +29,20 @@ import { import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { ExchangeService, - FakebankService, GlobalTestState, MerchantService, harnessHttpLib, } from "../harness/harness.js"; import { - createSimpleTestkudosEnvironmentV2, + createSimpleTestkudosEnvironmentV3, createWalletDaemonWithClient, - withdrawViaBankV2, + withdrawViaBankV3, } from "../harness/helpers.js"; interface Context { merchant: MerchantService; merchantBaseUrl: string; - bank: FakebankService; + bankClient: TalerCorebankApiClient; exchange: ExchangeService; } @@ -55,11 +55,11 @@ async function testWithClaimToken( const { walletClient } = await createWalletDaemonWithClient(t, { name: "wct", }); - const { bank, exchange } = c; + const { bankClient, exchange } = c; const { merchant, merchantBaseUrl } = c; - const wres = await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV3(t, { walletClient, - bank, + bankClient, exchange, amount: "TESTKUDOS:20", }); @@ -317,12 +317,12 @@ async function testWithoutClaimToken( name: "wnoct", }); const sessionId = "mysession2"; - const { bank, exchange } = c; + const { bankClient, exchange } = c; const { merchant, merchantBaseUrl } = c; const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl()); - const wres = await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV3(t, { walletClient, - bank, + bankClient, exchange, amount: "TESTKUDOS:20", }); @@ -573,8 +573,8 @@ async function testWithoutClaimToken( * specification of the endpoint. */ export async function runMerchantSpecPublicOrdersTest(t: GlobalTestState) { - const { bank, exchange, merchant } = - await createSimpleTestkudosEnvironmentV2(t); + const { bankClient, exchange, merchant } = + await createSimpleTestkudosEnvironmentV3(t); // Base URL for the default instance. const merchantBaseUrl = merchant.makeInstanceBaseUrl(); @@ -617,14 +617,14 @@ export async function runMerchantSpecPublicOrdersTest(t: GlobalTestState) { merchant, merchantBaseUrl, exchange, - bank, + bankClient, }); await testWithoutClaimToken(t, { merchant, merchantBaseUrl, exchange, - bank, + bankClient, }); } diff --git a/packages/taler-harness/src/integrationtests/test-payment-fault.ts b/packages/taler-harness/src/integrationtests/test-payment-fault.ts index c48b8e2a2..abb589477 100644 --- a/packages/taler-harness/src/integrationtests/test-payment-fault.ts +++ b/packages/taler-harness/src/integrationtests/test-payment-fault.ts @@ -21,7 +21,7 @@ /** * Imports. */ -import { ConfirmPayResultType, MerchantApiClient } from "@gnu-taler/taler-util"; +import { ConfirmPayResultType, MerchantApiClient, TalerCorebankApiClient } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { defaultCoinConfig } from "../harness/denomStructures.js"; import { @@ -30,8 +30,8 @@ import { FaultInjectionResponseContext, } from "../harness/faultInjection.js"; import { + BankService, ExchangeService, - FakebankService, GlobalTestState, MerchantService, generateRandomPayto, @@ -39,7 +39,7 @@ import { } from "../harness/harness.js"; import { createWalletDaemonWithClient, - withdrawViaBankV2, + withdrawViaBankV3, } from "../harness/helpers.js"; /** @@ -50,7 +50,7 @@ export async function runPaymentFaultTest(t: GlobalTestState) { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -64,10 +64,17 @@ export async function runPaymentFaultTest(t: GlobalTestState) { database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + + await exchange.addBankAccount("1", { + accountName: exchangeBankUsername, + accountPassword: exchangeBankPassword, + wireGatewayApiBaseUrl: new URL("accounts/exchange/taler-wire-gateway/", bank.baseUrl).href, + accountPaytoUri: exchangePaytoUri, + }); const faultyExchange = new FaultInjectedExchangeService(t, exchange, 8091); // Base URL must contain port that the proxy is listening on. @@ -77,14 +84,28 @@ export async function runPaymentFaultTest(t: GlobalTestState) { bank.setSuggestedExchange( faultyExchange, - exchangeBankAccount.accountPaytoUri, + exchangePaytoUri, ); await bank.start(); await bank.pingUntilAvailable(); - await exchange.addBankAccount("1", exchangeBankAccount); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); + exchange.addOfferedCoins(defaultCoinConfig); await exchange.start(); @@ -128,9 +149,9 @@ export async function runPaymentFaultTest(t: GlobalTestState) { await walletClient.call(WalletApiOperation.GetBalances, {}); - const wres = await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV3(t, { walletClient, - bank, + bankClient, exchange: faultyExchange, amount: "TESTKUDOS:20", }); diff --git a/packages/taler-harness/src/integrationtests/test-payment-multiple.ts b/packages/taler-harness/src/integrationtests/test-payment-multiple.ts index a3f95518c..3c902ee17 100644 --- a/packages/taler-harness/src/integrationtests/test-payment-multiple.ts +++ b/packages/taler-harness/src/integrationtests/test-payment-multiple.ts @@ -17,12 +17,12 @@ /** * Imports. */ -import { MerchantApiClient } from "@gnu-taler/taler-util"; +import { MerchantApiClient, TalerCorebankApiClient } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { coin_ct10, coin_u1 } from "../harness/denomStructures.js"; import { + BankService, ExchangeService, - FakebankService, GlobalTestState, MerchantService, generateRandomPayto, @@ -30,17 +30,17 @@ import { } from "../harness/harness.js"; import { createWalletDaemonWithClient, - withdrawViaBankV2, + withdrawViaBankV3, } from "../harness/helpers.js"; async function setupTest(t: GlobalTestState): Promise<{ merchant: MerchantService; exchange: ExchangeService; - bank: FakebankService; + bankClient: TalerCorebankApiClient; }> { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -54,20 +54,40 @@ async function setupTest(t: GlobalTestState): Promise<{ database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - exchange.addOfferedCoins([coin_ct10, coin_u1]); - bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(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(); await bank.pingUntilAvailable(); - await exchange.addBankAccount("1", exchangeBankAccount); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); await exchange.start(); await exchange.pingUntilAvailable(); @@ -100,7 +120,7 @@ async function setupTest(t: GlobalTestState): Promise<{ return { merchant, - bank, + bankClient, exchange, }; } @@ -113,7 +133,7 @@ async function setupTest(t: GlobalTestState): Promise<{ export async function runPaymentMultipleTest(t: GlobalTestState) { // Set up test environment - const { merchant, bank, exchange } = await setupTest(t); + const { merchant, bankClient, exchange } = await setupTest(t); const { walletClient } = await createWalletDaemonWithClient(t, { name: "default", @@ -123,9 +143,9 @@ export async function runPaymentMultipleTest(t: GlobalTestState) { // Withdraw digital cash into the wallet. - const wres = await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV3(t, { walletClient, - bank, + bankClient, exchange, amount: "TESTKUDOS:100", }); diff --git a/packages/taler-harness/src/integrationtests/test-revocation.ts b/packages/taler-harness/src/integrationtests/test-revocation.ts index ad5f89cd9..e0f77a445 100644 --- a/packages/taler-harness/src/integrationtests/test-revocation.ts +++ b/packages/taler-harness/src/integrationtests/test-revocation.ts @@ -28,14 +28,16 @@ import { delayMs, generateRandomPayto, WalletClient, - FakebankService, + BankService, } from "../harness/harness.js"; import { SimpleTestEnvironmentNg, + SimpleTestEnvironmentNg3, createWalletDaemonWithClient, makeTestPaymentV2, - withdrawViaBankV2, + withdrawViaBankV3, } from "../harness/helpers.js"; +import { TalerCorebankApiClient } from "@gnu-taler/taler-util"; async function revokeAllWalletCoins(req: { walletClient: WalletClient; @@ -62,10 +64,10 @@ async function revokeAllWalletCoins(req: { async function createTestEnvironment( t: GlobalTestState, -): Promise<SimpleTestEnvironmentNg> { +): Promise<SimpleTestEnvironmentNg3> { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -86,18 +88,39 @@ async function createTestEnvironment( database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - exchange.addBankAccount("1", exchangeBankAccount); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(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, exchangeBankAccount.accountPaytoUri); + bank.setSuggestedExchange(exchange, exchangePaytoUri); await bank.start(); await bank.pingUntilAvailable(); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); + const coin_u1: CoinConfig = { cipher: "RSA" as const, durationLegal: "3 years", @@ -151,8 +174,13 @@ async function createTestEnvironment( merchant, walletClient, walletService, - bank, - exchangeBankAccount, + bankClient, + exchangeBankAccount: { + accountName: '', + accountPassword: '', + accountPaytoUri: '', + wireGatewayApiBaseUrl: '', + }, }; } @@ -162,14 +190,14 @@ async function createTestEnvironment( export async function runRevocationTest(t: GlobalTestState) { // Set up test environment - const { walletClient, bank, exchange, merchant } = + const { walletClient, bankClient, exchange, merchant } = await createTestEnvironment(t); // Withdraw digital cash into the wallet. - const wres = await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV3(t, { walletClient, - bank, + bankClient, exchange, amount: "TESTKUDOS:15", }); @@ -197,9 +225,9 @@ export async function runRevocationTest(t: GlobalTestState) { await walletClient.call(WalletApiOperation.ClearDb, {}); - await withdrawViaBankV2(t, { + await withdrawViaBankV3(t, { walletClient, - bank, + bankClient, exchange, amount: "TESTKUDOS:15", }); diff --git a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts index b52a2cf7b..e6c84b75d 100644 --- a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts +++ b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts @@ -23,12 +23,13 @@ import { MerchantApiClient, NotificationType, PreparePayResultType, + TalerCorebankApiClient, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { makeNoFeeCoinConfig } from "../harness/denomStructures.js"; import { + BankService, ExchangeService, - FakebankService, GlobalTestState, MerchantService, generateRandomPayto, @@ -37,7 +38,7 @@ import { import { applyTimeTravelV2, createWalletDaemonWithClient, - withdrawViaBankV2, + withdrawViaBankV3, } from "../harness/helpers.js"; /** @@ -48,7 +49,7 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -69,18 +70,39 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - exchange.addBankAccount("1", exchangeBankAccount); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(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, exchangeBankAccount.accountPaytoUri); + bank.setSuggestedExchange(exchange, exchangePaytoUri); await bank.start(); await bank.pingUntilAvailable(); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); + exchange.addCoinConfigList(makeNoFeeCoinConfig("TESTKUDOS")); await exchange.start(); @@ -113,9 +135,9 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { // Withdraw digital cash into the wallet. - const wres = await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV3(t, { walletClient, - bank, + bankClient, exchange, amount: "TESTKUDOS:15", }); @@ -143,9 +165,9 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { await exchangeUpdated1Cond; await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); - const wres2 = await withdrawViaBankV2(t, { + const wres2 = await withdrawViaBankV3(t, { walletClient, - bank, + bankClient, exchange, amount: "TESTKUDOS:20", }); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts b/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts index 3341b6a53..ba2b2670c 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts @@ -20,6 +20,7 @@ import { ExchangeEntryStatus, NotificationType, + TalerCorebankApiClient, TalerError, TalerErrorCode, WalletNotification, @@ -28,14 +29,15 @@ import { import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; import { + BankService, ExchangeService, - FakebankService, GlobalTestState, WalletClient, WalletService, + generateRandomPayto, setupDb, } from "../harness/harness.js"; -import { withdrawViaBankV2 } from "../harness/helpers.js"; +import { withdrawViaBankV3 } from "../harness/helpers.js"; /** * Test for DD48 notifications. @@ -45,7 +47,7 @@ export async function runWalletDd48Test(t: GlobalTestState) { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -59,18 +61,39 @@ export async function runWalletDd48Test(t: GlobalTestState) { database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - exchange.addBankAccount("1", exchangeBankAccount); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(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, exchangeBankAccount.accountPaytoUri); + bank.setSuggestedExchange(exchange, exchangePaytoUri); await bank.start(); await bank.pingUntilAvailable(); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); + const coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")); exchange.addCoinConfigList(coinConfig); @@ -129,10 +152,10 @@ export async function runWalletDd48Test(t: GlobalTestState) { t.assertDeepEqual(resources.hasResources, false); } - const wres = await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV3(t, { walletClient, amount: "TESTKUDOS:20", - bank, + bankClient, exchange, }); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-denom-expire.ts b/packages/taler-harness/src/integrationtests/test-wallet-denom-expire.ts index 745c01e69..b9d028efd 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-denom-expire.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-denom-expire.ts @@ -17,10 +17,11 @@ /** * Imports. */ -import { Duration, Logger, NotificationType, j2s } from "@gnu-taler/taler-util"; +import { Duration, Logger, NotificationType, TalerCorebankApiClient, j2s } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { makeNoFeeCoinConfig } from "../harness/denomStructures.js"; import { + BankService, ExchangeService, FakebankService, GlobalTestState, @@ -31,7 +32,7 @@ import { import { applyTimeTravelV2, createWalletDaemonWithClient, - withdrawViaBankV2, + withdrawViaBankV3, } from "../harness/helpers.js"; const logger = new Logger("test-exchange-timetravel.ts"); @@ -44,7 +45,7 @@ export async function runWalletDenomExpireTest(t: GlobalTestState) { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -65,18 +66,39 @@ export async function runWalletDenomExpireTest(t: GlobalTestState) { database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - exchange.addBankAccount("1", exchangeBankAccount); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(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, exchangeBankAccount.accountPaytoUri); + bank.setSuggestedExchange(exchange, exchangePaytoUri); await bank.start(); await bank.pingUntilAvailable(); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); + exchange.addCoinConfigList(makeNoFeeCoinConfig("TESTKUDOS")); await exchange.start(); @@ -109,9 +131,9 @@ export async function runWalletDenomExpireTest(t: GlobalTestState) { // Withdraw digital cash into the wallet. - const wres = await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV3(t, { walletClient, - bank, + bankClient, exchange, amount: "TESTKUDOS:15", }); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts index 28b73a9f9..5088c8228 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts @@ -26,12 +26,13 @@ import { import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; import { + BankService, ExchangeService, - FakebankService, GlobalTestState, MerchantService, WalletClient, WalletService, + generateRandomPayto, generateRandomTestIban, setupDb, } from "../harness/harness.js"; @@ -44,7 +45,7 @@ export async function runWalletNotificationsTest(t: GlobalTestState) { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -58,6 +59,11 @@ export async function runWalletNotificationsTest(t: GlobalTestState) { database: db.connStr, }); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(exchangeBankUsername); + const merchant = await MerchantService.create(t, { name: "testmerchant-1", currency: "TESTKUDOS", @@ -65,18 +71,34 @@ export async function runWalletNotificationsTest(t: GlobalTestState) { database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - exchange.addBankAccount("1", exchangeBankAccount); + await exchange.addBankAccount("1", { + accountName: exchangeBankUsername, + accountPassword: exchangeBankPassword, + wireGatewayApiBaseUrl: new URL("accounts/exchange/taler-wire-gateway/", bank.baseUrl).href, + accountPaytoUri: exchangePaytoUri, + }); - bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri); + bank.setSuggestedExchange(exchange, exchangePaytoUri); await bank.start(); await bank.pingUntilAvailable(); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); + const coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")); exchange.addCoinConfigList(coinConfig); @@ -126,12 +148,9 @@ export async function runWalletNotificationsTest(t: GlobalTestState) { } }); - const bankAccessApiClient = new TalerCorebankApiClient( - bank.corebankApiBaseUrl, - ); - const user = await bankAccessApiClient.createRandomBankUser(); - bankAccessApiClient.setAuth(user); - const wop = await bankAccessApiClient.createWithdrawalOperation( + const user = await bankClient.createRandomBankUser(); + bankClient.setAuth(user); + const wop = await bankClient.createWithdrawalOperation( user.username, "TESTKUDOS:20", ); @@ -166,7 +185,7 @@ export async function runWalletNotificationsTest(t: GlobalTestState) { // Confirm it - await bankAccessApiClient.confirmWithdrawalOperation(user.username, { + await bankClient.confirmWithdrawalOperation(user.username, { withdrawalOperationId: wop.withdrawal_id, }); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-observability.ts b/packages/taler-harness/src/integrationtests/test-wallet-observability.ts index 5dff8670e..55a60cb76 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-observability.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-observability.ts @@ -17,25 +17,26 @@ /** * Imports. */ -import { NotificationType, WalletNotification } from "@gnu-taler/taler-util"; +import { NotificationType, TalerCorebankApiClient, WalletNotification } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; import { + BankService, ExchangeService, - FakebankService, GlobalTestState, WalletClient, WalletService, + generateRandomPayto, setupDb, } from "../harness/harness.js"; -import { withdrawViaBankV2 } from "../harness/helpers.js"; +import { withdrawViaBankV3 } from "../harness/helpers.js"; export async function runWalletObservabilityTest(t: GlobalTestState) { // Set up test environment const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -49,18 +50,39 @@ export async function runWalletObservabilityTest(t: GlobalTestState) { database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - exchange.addBankAccount("1", exchangeBankAccount); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(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, exchangeBankAccount.accountPaytoUri); + bank.setSuggestedExchange(exchange, exchangePaytoUri); await bank.start(); await bank.pingUntilAvailable(); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); + const coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")); exchange.addCoinConfigList(coinConfig); @@ -94,9 +116,9 @@ export async function runWalletObservabilityTest(t: GlobalTestState) { }, }); - const wres = await withdrawViaBankV2(t, { + const wres = await withdrawViaBankV3(t, { amount: "TESTKUDOS:10", - bank, + bankClient, exchange, walletClient, }); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-wirefees.ts b/packages/taler-harness/src/integrationtests/test-wallet-wirefees.ts index 361eec0f9..3be4088cc 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-wirefees.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-wirefees.ts @@ -22,13 +22,14 @@ import { MerchantApiClient, MerchantContractTerms, PreparePayResultType, + TalerCorebankApiClient, TransactionMajorState, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; import { + BankService, ExchangeService, - FakebankService, GlobalTestState, MerchantService, generateRandomPayto, @@ -36,7 +37,7 @@ import { } from "../harness/harness.js"; import { createWalletDaemonWithClient, - withdrawViaBankV2, + withdrawViaBankV3, } from "../harness/helpers.js"; /** @@ -47,7 +48,7 @@ export async function runWalletWirefeesTest(t: GlobalTestState) { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -70,17 +71,39 @@ export async function runWalletWirefeesTest(t: GlobalTestState) { database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - await exchange.addBankAccount("1", exchangeBankAccount); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(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); - bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri); await bank.start(); await bank.pingUntilAvailable(); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); + const coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")); exchange.addCoinConfigList(coinConfig); @@ -119,9 +142,9 @@ export async function runWalletWirefeesTest(t: GlobalTestState) { // Withdraw digital cash into the wallet. - await withdrawViaBankV2(t, { + await withdrawViaBankV3(t, { walletClient, - bank, + bankClient, exchange, amount: "TESTKUDOS:20", }); diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts index 7ab029932..1c65de7d9 100644 --- a/packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts +++ b/packages/taler-harness/src/integrationtests/test-withdrawal-fees.ts @@ -21,10 +21,11 @@ import { TalerCorebankApiClient, j2s } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { CoinConfig } from "../harness/denomStructures.js"; import { + BankService, ExchangeService, - FakebankService, GlobalTestState, WalletCli, + generateRandomPayto, setupDb, } from "../harness/harness.js"; @@ -67,7 +68,7 @@ export async function runWithdrawalFeesTest(t: GlobalTestState) { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { allowRegistrations: true, currency: "TESTKUDOS", database: db.connStr, @@ -81,16 +82,39 @@ export async function runWithdrawalFeesTest(t: GlobalTestState) { database: db.connStr, }); - const exchangeBankAccount = await bank.createExchangeAccount( - "myexchange", - "x", - ); - await exchange.addBankAccount("1", exchangeBankAccount); + let receiverName = "Exchange"; + let exchangeBankUsername = "exchange"; + let exchangeBankPassword = "mypw"; + let exchangePaytoUri = generateRandomPayto(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(); await bank.pingUntilAvailable(); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + }, + }); + + await bankClient.registerAccountExtended({ + name: receiverName, + password: exchangeBankPassword, + username: exchangeBankUsername, + is_taler_exchange: true, + payto_uri: exchangePaytoUri, + }); + const coinConfig: CoinConfig[] = weirdCoinConfig.map((x) => x("TESTKUDOS")); exchange.addCoinConfigList(coinConfig); @@ -107,12 +131,9 @@ export async function runWithdrawalFeesTest(t: GlobalTestState) { const amount = "TESTKUDOS:7.5"; - const bankAccessApiClient = new TalerCorebankApiClient( - bank.corebankApiBaseUrl, - ); - const user = await bankAccessApiClient.createRandomBankUser(); - bankAccessApiClient.setAuth(user); - const wop = await bankAccessApiClient.createWithdrawalOperation( + const user = await bankClient.createRandomBankUser(); + bankClient.setAuth(user); + const wop = await bankClient.createWithdrawalOperation( user.username, amount, ); @@ -152,7 +173,7 @@ export async function runWithdrawalFeesTest(t: GlobalTestState) { // Confirm it - await bankAccessApiClient.confirmWithdrawalOperation(user.username, { + await bankClient.confirmWithdrawalOperation(user.username, { withdrawalOperationId: wop.withdrawal_id, }); await wallet.runUntilDone(); diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts index b483b8706..aaa6701f8 100644 --- a/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts +++ b/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts @@ -21,15 +21,16 @@ import { GlobalTestState, setupDb, ExchangeService, - FakebankService, WalletService, WalletClient, + BankService, } from "../harness/harness.js"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js"; import { AmountString, NotificationType, + TalerCorebankApiClient, TransactionMajorState, URL, } from "@gnu-taler/taler-util"; @@ -45,7 +46,7 @@ export async function runWithdrawalHugeTest(t: GlobalTestState) { const db = await setupDb(t); - const bank = await FakebankService.create(t, { + const bank = await BankService.create(t, { currency: "TESTKUDOS", httpPort: 8082, allowRegistrations: true, @@ -60,17 +61,36 @@ export async function runWithdrawalHugeTest(t: GlobalTestState) { database: db.connStr, }); - exchange.addBankAccount("1", { + let paytoUri = "payto://x-taler-bank/localhost/exchange"; + + await exchange.addBankAccount("1", { accountName: "exchange", accountPassword: "x", - wireGatewayApiBaseUrl: new URL("/exchange/", bank.baseUrl).href, - accountPaytoUri: "payto://x-taler-bank/localhost/exchange", + wireGatewayApiBaseUrl: new URL("accounts/exchange/taler-wire-gateway/", bank.baseUrl).href, + accountPaytoUri: paytoUri, }); + bank.setSuggestedExchange(exchange, paytoUri); + await bank.start(); await bank.pingUntilAvailable(); + const bankClient = new TalerCorebankApiClient(bank.corebankApiBaseUrl, { + auth: { + username: "admin", + password: "adminpw", + } + }); + + await bankClient.registerAccountExtended({ + name: "Exchange", + password: "x", + username: "exchange", + is_taler_exchange: true, + payto_uri: paytoUri, + }); + const coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")); exchange.addCoinConfigList(coinConfig); |