summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2024-04-04 13:09:02 -0600
committerIván Ávalos <avalos@disroot.org>2024-04-12 11:42:56 -0600
commit79c0ac1af156e8c26f78447d755a3b58f823fb3c (patch)
tree0210c878238fa13f467ae6bf9f70082a7a2a0fe7
parentbe698f1a180cfbf794df8c35e70f29cb50a58bb0 (diff)
downloadwallet-core-79c0ac1af156e8c26f78447d755a3b58f823fb3c.tar.gz
wallet-core-79c0ac1af156e8c26f78447d755a3b58f823fb3c.tar.bz2
wallet-core-79c0ac1af156e8c26f78447d755a3b58f823fb3c.zip
harness: initial libeufin testing setup
-rw-r--r--packages/taler-harness/src/harness/harness.ts3
-rw-r--r--packages/taler-harness/src/harness/helpers.ts34
-rw-r--r--packages/taler-harness/src/integrationtests/test-payment.ts10
3 files changed, 18 insertions, 29 deletions
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts
index 74545a4d7..f0eed6e84 100644
--- a/packages/taler-harness/src/harness/harness.ts
+++ b/packages/taler-harness/src/harness/harness.ts
@@ -779,6 +779,9 @@ export class LibeufinBankService
config.setString("libeufin-bank", "currency", bc.currency);
config.setString("libeufin-bank", "port", `${bc.httpPort}`);
config.setString("libeufin-bank", "serve", "tcp");
+ config.setString("libeufin-bank", "wire_type", "x-taler-bank");
+ config.setString("libeufin-bank", "x_taler_bank_payto_hostname", "localhost");
+ config.setString("libeufin-bank", "default_debt_limit", bc.maxDebt ?? `${bc.currency}:100`);
config.setString(
"libeufin-bank",
"DEFAULT_DEBT_LIMIT",
diff --git a/packages/taler-harness/src/harness/helpers.ts b/packages/taler-harness/src/harness/helpers.ts
index 8891a9316..2763ad0a5 100644
--- a/packages/taler-harness/src/harness/helpers.ts
+++ b/packages/taler-harness/src/harness/helpers.ts
@@ -448,13 +448,10 @@ export async function createSimpleTestkudosEnvironmentV3(
database: db.connStr,
});
- const receiverName = "exchange";
+ const receiverName = "Exchange";
const exchangeBankUsername = "exchange";
const exchangeBankPassword = "mypw";
- const exchangePlainPayto = opts.withLibeufin === true
- ? `payto://iban/SANDBOXX/${generateRandomTestIban()}`
- : `payto://x-taler-bank/localhost/${receiverName}`
- const exchangeExtendedPayto = `${exchangePlainPayto}?receiver-name=${receiverName}`
+ const exchangePaytoUri = generateRandomPayto(exchangeBankUsername);
const wireGatewayApiBaseUrl = new URL(
"accounts/exchange/taler-wire-gateway/",
bank.corebankApiBaseUrl,
@@ -464,10 +461,10 @@ export async function createSimpleTestkudosEnvironmentV3(
wireGatewayApiBaseUrl,
accountName: exchangeBankUsername,
accountPassword: exchangeBankPassword,
- accountPaytoUri: exchangeExtendedPayto,
- }
+ accountPaytoUri: exchangePaytoUri,
+ };
- exchange.addBankAccount("1", exchangeBankAccount);
+ await exchange.addBankAccount("1", exchangeBankAccount);
bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri);
@@ -801,18 +798,13 @@ export async function withdrawViaBankV3(
): Promise<WithdrawViaBankResult> {
const { walletClient: wallet, bankClient, exchange, amount } = p;
- console.log("line 804")
-
const user = await bankClient.createRandomBankUser();
- const bankClient2 = new TalerCorebankApiClient(bankClient.baseUrl, {
- auth: {
- username: user.username,
- password: user.password,
- }
+ bankClient.setAuth({
+ username: user.username,
+ password: user.password,
});
- const wop = await bankClient2.createWithdrawalOperation(user.username, amount);
- console.log("line 815")
+ const wop = await bankClient.createWithdrawalOperation(user.username, amount);
// Hand it to the wallet
@@ -821,8 +813,6 @@ export async function withdrawViaBankV3(
restrictAge: p.restrictAge,
});
- console.log("line 824")
-
// Withdraw (AKA select)
const acceptRes = await wallet.client.call(
@@ -834,8 +824,6 @@ export async function withdrawViaBankV3(
},
);
- console.log("line 837")
-
const withdrawalFinishedCond = wallet.waitForNotificationCond(
(x) =>
x.type === NotificationType.TransactionStateTransition &&
@@ -843,11 +831,9 @@ export async function withdrawViaBankV3(
x.transactionId === acceptRes.transactionId,
);
- console.log("line 846")
-
// Confirm it
- await bankClient2.confirmWithdrawalOperation(user.username, {
+ await bankClient.confirmWithdrawalOperation(user.username, {
withdrawalOperationId: wop.withdrawal_id,
});
diff --git a/packages/taler-harness/src/integrationtests/test-payment.ts b/packages/taler-harness/src/integrationtests/test-payment.ts
index da9f97bf4..651d0edfa 100644
--- a/packages/taler-harness/src/integrationtests/test-payment.ts
+++ b/packages/taler-harness/src/integrationtests/test-payment.ts
@@ -24,6 +24,7 @@ import {
createSimpleTestkudosEnvironmentV3,
makeTestPaymentV2,
withdrawViaBankV2,
+ withdrawViaBankV3,
} from "../harness/helpers.js";
/**
@@ -32,24 +33,23 @@ import {
export async function runPaymentTest(t: GlobalTestState) {
// Set up test environment
- const { bank, walletClient, exchange, merchant } =
+ const { bankClient, walletClient, exchange, merchant } =
await createSimpleTestkudosEnvironmentV3(t, undefined, {
withLibeufin: false,
});
// Withdraw digital cash into the wallet.
- await withdrawViaBankV2(t, {
+ t.assertTrue(bankClient !== undefined);
+ await withdrawViaBankV3(t, {
walletClient,
exchange,
amount: "TESTKUDOS:20",
- bank,
+ bankClient,
});
await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
- console.log("line 51");
-
const order = {
summary: "Buy me!",
amount: "TESTKUDOS:5",