This commit is contained in:
Sebastian 2023-01-19 16:16:42 -03:00
parent b5c29a8bad
commit 40279ae7f0
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
40 changed files with 238 additions and 231 deletions

View File

@ -49,7 +49,9 @@ export async function runBench2(configJson: any): Promise<void> {
// Validate the configuration file for this benchmark. // Validate the configuration file for this benchmark.
const benchConf = codecForBench2Config().decode(configJson); const benchConf = codecForBench2Config().decode(configJson);
const curr = benchConf.currency; const curr = benchConf.currency;
const cryptoDisp = new CryptoDispatcher(new SynchronousCryptoWorkerFactoryNode()); const cryptoDisp = new CryptoDispatcher(
new SynchronousCryptoWorkerFactoryNode(),
);
const cryptoApi = cryptoDisp.cryptoApi; const cryptoApi = cryptoDisp.cryptoApi;
const http = new NodeHttpLib(); const http = new NodeHttpLib();

View File

@ -59,7 +59,10 @@ export async function runBench3(configJson: any): Promise<void> {
const withdrawAmount = (numDeposits + 1) * 10; const withdrawAmount = (numDeposits + 1) * 10;
const IDGenerator = benchMerchantIDGenerator(b3conf.randomAlg, b3conf.numMerchants ?? 100); const IDGenerator = benchMerchantIDGenerator(
b3conf.randomAlg,
b3conf.numMerchants ?? 100,
);
logger.info( logger.info(
`Starting Benchmark iterations=${numIter} deposits=${numDeposits} with ${b3conf.randomAlg} merchant selection`, `Starting Benchmark iterations=${numIter} deposits=${numDeposits} with ${b3conf.randomAlg} merchant selection`,

View File

@ -16,16 +16,15 @@
@author: Boss Marco @author: Boss Marco
*/ */
const getRandomInt = function(max: number) { const getRandomInt = function (max: number) {
return Math.floor(Math.random() * max); return Math.floor(Math.random() * max);
} };
abstract class BenchMerchantIDGenerator { abstract class BenchMerchantIDGenerator {
abstract getRandomMerchantID(): number abstract getRandomMerchantID(): number;
} }
class ZipfGenerator extends BenchMerchantIDGenerator { class ZipfGenerator extends BenchMerchantIDGenerator {
weights: number[]; weights: number[];
total_weight: number; total_weight: number;
@ -36,7 +35,7 @@ class ZipfGenerator extends BenchMerchantIDGenerator {
/* we use integers (floor), make sure we have big enough values /* we use integers (floor), make sure we have big enough values
* by multiplying with * by multiplying with
* numMerchants again */ * numMerchants again */
this.weights[i] = Math.floor((numMerchants/(i+1)) * numMerchants); this.weights[i] = Math.floor((numMerchants / (i + 1)) * numMerchants);
} }
this.total_weight = this.weights.reduce((p, n) => p + n); this.total_weight = this.weights.reduce((p, n) => p + n);
} }
@ -48,7 +47,7 @@ class ZipfGenerator extends BenchMerchantIDGenerator {
for (var i = 0; i < this.weights.length; i++) { for (var i = 0; i < this.weights.length; i++) {
current += this.weights[i]; current += this.weights[i];
if (random <= current) { if (random <= current) {
return i+1; return i + 1;
} }
} }
@ -58,12 +57,11 @@ class ZipfGenerator extends BenchMerchantIDGenerator {
} }
class RandomGenerator extends BenchMerchantIDGenerator { class RandomGenerator extends BenchMerchantIDGenerator {
max: number;
max: number
constructor(numMerchants: number) { constructor(numMerchants: number) {
super(); super();
this.max = numMerchants this.max = numMerchants;
} }
getRandomMerchantID() { getRandomMerchantID() {
@ -71,7 +69,10 @@ class RandomGenerator extends BenchMerchantIDGenerator {
} }
} }
export default function(type: string, maxID: number): BenchMerchantIDGenerator { export default function (
type: string,
maxID: number,
): BenchMerchantIDGenerator {
switch (type) { switch (type) {
case "zipf": case "zipf":
return new ZipfGenerator(maxID); return new ZipfGenerator(maxID);

View File

@ -1086,7 +1086,9 @@ export class ExchangeService implements ExchangeServiceInterface {
* The modified exchange configuration will then be written to the * The modified exchange configuration will then be written to the
* file system. * file system.
*/ */
async modifyConfig(f: (config: Configuration) => Promise<void>): Promise<void> { async modifyConfig(
f: (config: Configuration) => Promise<void>,
): Promise<void> {
const config = Configuration.load(this.configFilename); const config = Configuration.load(this.configFilename);
await f(config); await f(config);
config.write(this.configFilename); config.write(this.configFilename);

View File

@ -197,16 +197,13 @@ export namespace LibeufinSandboxApi {
username: string, username: string,
password: string, password: string,
libeufinSandboxService: LibeufinSandboxServiceInterface, libeufinSandboxService: LibeufinSandboxServiceInterface,
iban: string|null = null, iban: string | null = null,
) { ) {
let url = new URL( let url = new URL("testing/register", libeufinSandboxService.baseUrl);
"testing/register",
libeufinSandboxService.baseUrl
);
await axios.post(url.href, { await axios.post(url.href, {
username: username, username: username,
password: password, password: password,
iban: iban iban: iban,
}); });
} }
// Need /demobanks/$id as the base URL // Need /demobanks/$id as the base URL
@ -218,10 +215,7 @@ export namespace LibeufinSandboxApi {
password: string = "secret", password: string = "secret",
) { ) {
// baseUrl should already be pointed to one demobank. // baseUrl should already be pointed to one demobank.
let url = new URL( let url = new URL("ebics/subscribers", libeufinSandboxService.baseUrl);
"ebics/subscribers",
libeufinSandboxService.baseUrl
);
await axios.post( await axios.post(
url.href, url.href,
{ {

View File

@ -56,7 +56,6 @@ import {
CreateNexusUserRequest, CreateNexusUserRequest,
} from "../harness/libeufin-apis.js"; } from "../harness/libeufin-apis.js";
const logger = new Logger("libeufin.ts"); const logger = new Logger("libeufin.ts");
export { LibeufinSandboxApi, LibeufinNexusApi }; export { LibeufinSandboxApi, LibeufinNexusApi };
@ -451,7 +450,10 @@ export class LibeufinCli {
); );
} }
async registerBankCustomer(username: string, password: string): Promise<void> { async registerBankCustomer(
username: string,
password: string,
): Promise<void> {
const stdout = await sh( const stdout = await sh(
this.globalTestState, this.globalTestState,
"libeufin-cli-registercustomer", "libeufin-cli-registercustomer",
@ -830,12 +832,12 @@ export async function launchLibeufinServices(
await LibeufinSandboxApi.createDemobankAccount( await LibeufinSandboxApi.createDemobankAccount(
sb.ebicsBankAccount.label, sb.ebicsBankAccount.label,
"password-unused", "password-unused",
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/access-api/" } { baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/access-api/" },
); );
await LibeufinSandboxApi.createDemobankEbicsSubscriber( await LibeufinSandboxApi.createDemobankEbicsSubscriber(
sb.ebicsBankAccount.subscriber, sb.ebicsBankAccount.subscriber,
sb.ebicsBankAccount.label, sb.ebicsBankAccount.label,
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/" } { baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/" },
); );
} }
console.log("Sandbox user(s) / account(s) / subscriber(s): created"); console.log("Sandbox user(s) / account(s) / subscriber(s): created");

View File

@ -82,7 +82,6 @@ export const codecForPostOrderResponse = (): Codec<PostOrderResponse> =>
.property("token", codecOptional(codecForString())) .property("token", codecOptional(codecForString()))
.build("PostOrderResponse"); .build("PostOrderResponse");
export const codecForRefundDetails = (): Codec<RefundDetails> => export const codecForRefundDetails = (): Codec<RefundDetails> =>
buildCodecForObject<RefundDetails>() buildCodecForObject<RefundDetails>()
.property("reason", codecForString()) .property("reason", codecForString())

View File

@ -115,5 +115,5 @@ export class SyncService {
private globalState: GlobalTestState, private globalState: GlobalTestState,
private syncConfig: SyncConfig, private syncConfig: SyncConfig,
private configFilename: string, private configFilename: string,
) { } ) {}
} }

View File

@ -1,2 +1,2 @@
// Helper to make 'import.meta.url' available in esbuild-bundled code as well. // Helper to make 'import.meta.url' available in esbuild-bundled code as well.
export const import_meta_url = require('url').pathToFileURL(__filename); export const import_meta_url = require("url").pathToFileURL(__filename);

View File

@ -18,7 +18,10 @@
* Imports. * Imports.
*/ */
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js"; import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "../harness/helpers.js"; import {
createSimpleTestkudosEnvironment,
withdrawViaBank,
} from "../harness/helpers.js";
/** /**
* Run test for basic, bank-integrated withdrawal. * Run test for basic, bank-integrated withdrawal.
@ -26,12 +29,8 @@ import { createSimpleTestkudosEnvironment, withdrawViaBank } from "../harness/he
export async function runPromptPaymentScenario(t: GlobalTestState) { export async function runPromptPaymentScenario(t: GlobalTestState) {
// Set up test environment // Set up test environment
const { const { wallet, bank, exchange, merchant } =
wallet, await createSimpleTestkudosEnvironment(t);
bank,
exchange,
merchant,
} = await createSimpleTestkudosEnvironment(t);
// Withdraw digital cash into the wallet. // Withdraw digital cash into the wallet.

View File

@ -18,7 +18,10 @@
* Imports. * Imports.
*/ */
import { AbsoluteTime, Duration } from "@gnu-taler/taler-util"; import { AbsoluteTime, Duration } from "@gnu-taler/taler-util";
import { getDefaultNodeWallet2, WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import {
getDefaultNodeWallet2,
WalletApiOperation,
} from "@gnu-taler/taler-wallet-core";
import { defaultCoinConfig } from "../harness/denomStructures.js"; import { defaultCoinConfig } from "../harness/denomStructures.js";
import { GlobalTestState, WalletCli } from "../harness/harness.js"; import { GlobalTestState, WalletCli } from "../harness/harness.js";
import { import {
@ -67,19 +70,25 @@ export async function runAgeRestrictionsPeerTest(t: GlobalTestState) {
), ),
); );
const initResp = await wallet.client.call(WalletApiOperation.InitiatePeerPushPayment, { const initResp = await wallet.client.call(
partialContractTerms: { WalletApiOperation.InitiatePeerPushPayment,
summary: "Hello, World", {
amount: "TESTKUDOS:1", partialContractTerms: {
purse_expiration, summary: "Hello, World",
amount: "TESTKUDOS:1",
purse_expiration,
},
}, },
}); );
await wallet.runUntilDone(); await wallet.runUntilDone();
const checkResp = await walletTwo.client.call(WalletApiOperation.CheckPeerPushPayment, { const checkResp = await walletTwo.client.call(
talerUri: initResp.talerUri, WalletApiOperation.CheckPeerPushPayment,
}); {
talerUri: initResp.talerUri,
},
);
await walletTwo.client.call(WalletApiOperation.AcceptPeerPushPayment, { await walletTwo.client.call(WalletApiOperation.AcceptPeerPushPayment, {
peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId, peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId,

View File

@ -18,7 +18,10 @@
* Imports. * Imports.
*/ */
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js"; import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "../harness/helpers.js"; import {
createSimpleTestkudosEnvironment,
withdrawViaBank,
} from "../harness/helpers.js";
import { URL } from "url"; import { URL } from "url";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
@ -31,12 +34,8 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
export async function runClaimLoopTest(t: GlobalTestState) { export async function runClaimLoopTest(t: GlobalTestState) {
// Set up test environment // Set up test environment
const { const { wallet, bank, exchange, merchant } =
wallet, await createSimpleTestkudosEnvironment(t);
bank,
exchange,
merchant,
} = await createSimpleTestkudosEnvironment(t);
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" }); await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" });

View File

@ -55,54 +55,46 @@ export async function runDenomUnofferedTest(t: GlobalTestState) {
fulfillment_url: "taler://fulfillment-success/thx", fulfillment_url: "taler://fulfillment-success/thx",
}; };
const orderResp = await MerchantPrivateApi.createOrder( const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
merchant, order: order,
"default", });
{
order: order,
},
);
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus( let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
merchant, orderId: orderResp.order_id,
{ });
orderId: orderResp.order_id,
},
);
t.assertTrue(orderStatus.order_status === "unpaid"); t.assertTrue(orderStatus.order_status === "unpaid");
// Make wallet pay for the order // Make wallet pay for the order
const preparePayResult = await wallet.client.call( const preparePayResult = await wallet.client.call(
WalletApiOperation.PreparePayForUri, WalletApiOperation.PreparePayForUri,
{ {
talerPayUri: orderStatus.taler_pay_uri, talerPayUri: orderStatus.taler_pay_uri,
}, },
); );
t.assertTrue( t.assertTrue(
preparePayResult.status === PreparePayResultType.PaymentPossible, preparePayResult.status === PreparePayResultType.PaymentPossible,
); );
const confirmResp = await wallet.client.call(WalletApiOperation.ConfirmPay, { const confirmResp = await wallet.client.call(WalletApiOperation.ConfirmPay, {
proposalId: preparePayResult.proposalId, proposalId: preparePayResult.proposalId,
}); });
const tx = await wallet.client.call(WalletApiOperation.GetTransactionById, { const tx = await wallet.client.call(WalletApiOperation.GetTransactionById, {
transactionId: confirmResp.transactionId, transactionId: confirmResp.transactionId,
}); });
t.assertTrue( t.assertTrue(
tx.error?.code === TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR tx.error?.code === TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR,
); );
const merchantErrorCode = ((tx.error as any).errorResponse as any) const merchantErrorCode = ((tx.error as any).errorResponse as any).code;
.code; t.assertDeepEqual(
t.assertDeepEqual( merchantErrorCode,
merchantErrorCode, TalerErrorCode.MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_NOT_FOUND,
TalerErrorCode.MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_NOT_FOUND, );
);
await wallet.client.call(WalletApiOperation.AddExchange, { await wallet.client.call(WalletApiOperation.AddExchange, {
exchangeBaseUrl: exchange.baseUrl, exchangeBaseUrl: exchange.baseUrl,

View File

@ -19,7 +19,10 @@
*/ */
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, getPayto } from "../harness/harness.js"; import { GlobalTestState, getPayto } from "../harness/harness.js";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "../harness/helpers.js"; import {
createSimpleTestkudosEnvironment,
withdrawViaBank,
} from "../harness/helpers.js";
/** /**
* Run test for basic, bank-integrated withdrawal and payment. * Run test for basic, bank-integrated withdrawal and payment.
@ -27,12 +30,8 @@ import { createSimpleTestkudosEnvironment, withdrawViaBank } from "../harness/he
export async function runDepositTest(t: GlobalTestState) { export async function runDepositTest(t: GlobalTestState) {
// Set up test environment // Set up test environment
const { const { wallet, bank, exchange, merchant } =
wallet, await createSimpleTestkudosEnvironment(t);
bank,
exchange,
merchant,
} = await createSimpleTestkudosEnvironment(t);
// Withdraw digital cash into the wallet. // Withdraw digital cash into the wallet.

View File

@ -119,26 +119,26 @@ export async function createKycTestkudosEnvironment(
"kyc_oauth2_info_url", "kyc_oauth2_info_url",
"http://localhost:6666/oauth/v2/login", "http://localhost:6666/oauth/v2/login",
); );
config.setString( config.setString(myprov, "kyc_oauth2_client_id", "taler-exchange");
myprov, config.setString(myprov, "kyc_oauth2_client_secret", "exchange-secret");
"kyc_oauth2_client_id", config.setString(myprov, "kyc_oauth2_post_url", "https://taler.com");
"taler-exchange",
);
config.setString(
myprov,
"kyc_oauth2_client_secret",
"exchange-secret",
);
config.setString(
myprov,
"kyc_oauth2_post_url",
"https://taler.com",
);
config.setString("kyc-legitimization-withdraw1", "operation_type", "withdraw"); config.setString(
config.setString("kyc-legitimization-withdraw1", "required_checks", "dummy1"); "kyc-legitimization-withdraw1",
"operation_type",
"withdraw",
);
config.setString(
"kyc-legitimization-withdraw1",
"required_checks",
"dummy1",
);
config.setString("kyc-legitimization-withdraw1", "timeframe", "1d"); config.setString("kyc-legitimization-withdraw1", "timeframe", "1d");
config.setString("kyc-legitimization-withdraw1", "threshold", "TESTKUDOS:5"); config.setString(
"kyc-legitimization-withdraw1",
"threshold",
"TESTKUDOS:5",
);
}); });
await exchange.start(); await exchange.start();

View File

@ -53,7 +53,7 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
"mock", "mock",
"password-unused", "password-unused",
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" }, { baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
"DE71500105179674997361" "DE71500105179674997361",
); );
await LibeufinSandboxApi.createDemobankEbicsSubscriber( await LibeufinSandboxApi.createDemobankEbicsSubscriber(
{ {
@ -62,7 +62,7 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
userID: "mock", userID: "mock",
}, },
"mock", "mock",
{ baseUrl: sandbox.baseUrl + "/demobanks/default/" } { baseUrl: sandbox.baseUrl + "/demobanks/default/" },
); );
await LibeufinNexusApi.createEbicsBankConnection(nexus, { await LibeufinNexusApi.createEbicsBankConnection(nexus, {
name: "bankaccount-api-test-connection", name: "bankaccount-api-test-connection",

View File

@ -37,12 +37,12 @@ export async function runLibeufinApiSandboxCamtTest(t: GlobalTestState) {
await LibeufinSandboxApi.createDemobankAccount( await LibeufinSandboxApi.createDemobankAccount(
"mock-account-0", "mock-account-0",
"password-unused", "password-unused",
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" } { baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
); );
await LibeufinSandboxApi.createDemobankAccount( await LibeufinSandboxApi.createDemobankAccount(
"mock-account-1", "mock-account-1",
"password-unused", "password-unused",
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" } { baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
); );
await sandbox.makeTransaction( await sandbox.makeTransaction(
"mock-account-0", "mock-account-0",

View File

@ -36,7 +36,7 @@ export async function runLibeufinApiSandboxTransactionsTest(
"mock-account", "mock-account",
"password-unused", "password-unused",
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" }, { baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
"DE71500105179674997361" "DE71500105179674997361",
); );
await LibeufinSandboxApi.simulateIncomingTransaction( await LibeufinSandboxApi.simulateIncomingTransaction(
sandbox, sandbox,
@ -46,7 +46,7 @@ export async function runLibeufinApiSandboxTransactionsTest(
debtorBic: "BELADEBEXXX", debtorBic: "BELADEBEXXX",
debtorName: "mock2", debtorName: "mock2",
subject: "mock subject", subject: "mock subject",
amount: "EUR:1" amount: "EUR:1",
}, },
); );
await LibeufinSandboxApi.simulateIncomingTransaction( await LibeufinSandboxApi.simulateIncomingTransaction(
@ -57,7 +57,7 @@ export async function runLibeufinApiSandboxTransactionsTest(
debtorBic: "BELADEBEXXX", debtorBic: "BELADEBEXXX",
debtorName: "mock2", debtorName: "mock2",
subject: "mock subject 2", subject: "mock subject 2",
amount: "EUR:1.1" amount: "EUR:1.1",
}, },
); );
let ret = await LibeufinSandboxApi.getAccountInfoWithBalance( let ret = await LibeufinSandboxApi.getAccountInfoWithBalance(

View File

@ -34,7 +34,8 @@ export async function runLibeufinBadGatewayTest(t: GlobalTestState) {
* User saltetd "01" * User saltetd "01"
*/ */
const user01nexus = new NexusUserBundle( const user01nexus = new NexusUserBundle(
"01", "http://localhost:5010/not-found", // the EBICS endpoint at Sandbox "01",
"http://localhost:5010/not-found", // the EBICS endpoint at Sandbox
); );
// Start Nexus // Start Nexus
@ -56,7 +57,7 @@ export async function runLibeufinBadGatewayTest(t: GlobalTestState) {
// Connecting to a non-existent Sandbox endpoint. // Connecting to a non-existent Sandbox endpoint.
await LibeufinNexusApi.createEbicsBankConnection( await LibeufinNexusApi.createEbicsBankConnection(
libeufinNexus, libeufinNexus,
user01nexus.connReq user01nexus.connReq,
); );
// 502 Bad Gateway expected. // 502 Bad Gateway expected.
@ -65,7 +66,7 @@ export async function runLibeufinBadGatewayTest(t: GlobalTestState) {
libeufinNexus, libeufinNexus,
user01nexus.connReq.name, user01nexus.connReq.name,
); );
} catch(e: any) { } catch (e: any) {
t.assertTrue(e.response.status == 502); t.assertTrue(e.response.status == 502);
return; return;
} }

View File

@ -17,7 +17,11 @@
/** /**
* Imports. * Imports.
*/ */
import { AbsoluteTime, MerchantContractTerms, Duration } from "@gnu-taler/taler-util"; import {
AbsoluteTime,
MerchantContractTerms,
Duration,
} from "@gnu-taler/taler-util";
import { import {
WalletApiOperation, WalletApiOperation,
HarnessExchangeBankAccount, HarnessExchangeBankAccount,
@ -85,7 +89,7 @@ export async function createLibeufinTestEnvironment(
"exchangeacct", "exchangeacct",
"password-unused", "password-unused",
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/access-api/" }, { baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/access-api/" },
exchangeIban exchangeIban,
); );
await LibeufinSandboxApi.createDemobankEbicsSubscriber( await LibeufinSandboxApi.createDemobankEbicsSubscriber(
{ {
@ -94,14 +98,14 @@ export async function createLibeufinTestEnvironment(
userID: "user01", userID: "user01",
}, },
"exchangeacct", "exchangeacct",
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/" } { baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/" },
); );
await LibeufinSandboxApi.createDemobankAccount( await LibeufinSandboxApi.createDemobankAccount(
"merchantacct", "merchantacct",
"password-unused", "password-unused",
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/access-api/" }, { baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/access-api/" },
merchantIban merchantIban,
); );
await LibeufinSandboxApi.createDemobankEbicsSubscriber( await LibeufinSandboxApi.createDemobankEbicsSubscriber(
{ {

View File

@ -52,7 +52,9 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
); );
// check that original facade shows up. // check that original facade shows up.
t.assertTrue(resp.data["facades"][0]["name"] == user01nexus.anastasisReq["name"]); t.assertTrue(
resp.data["facades"][0]["name"] == user01nexus.anastasisReq["name"],
);
const anastasisBaseUrl: string = resp.data["facades"][0]["baseUrl"]; const anastasisBaseUrl: string = resp.data["facades"][0]["baseUrl"];
t.assertTrue(typeof anastasisBaseUrl === "string"); t.assertTrue(typeof anastasisBaseUrl === "string");
t.assertTrue(anastasisBaseUrl.startsWith("http://")); t.assertTrue(anastasisBaseUrl.startsWith("http://"));
@ -63,23 +65,23 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
user01nexus.localAccountName, user01nexus.localAccountName,
); );
await LibeufinNexusApi.postPermission( await LibeufinNexusApi.postPermission(libeufinServices.libeufinNexus, {
libeufinServices.libeufinNexus, { action: "grant",
action: "grant", permission: {
permission: { subjectId: user01nexus.userReq.username,
subjectId: user01nexus.userReq.username, subjectType: "user",
subjectType: "user", resourceType: "facade",
resourceType: "facade", resourceId: user01nexus.anastasisReq.name,
resourceId: user01nexus.anastasisReq.name, permissionName: "facade.anastasis.history",
permissionName: "facade.anastasis.history", },
}, });
}
);
// check if empty. // check if empty.
let txsEmpty = await LibeufinNexusApi.getAnastasisTransactions( let txsEmpty = await LibeufinNexusApi.getAnastasisTransactions(
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
anastasisBaseUrl, {delta: 5}) anastasisBaseUrl,
{ delta: 5 },
);
t.assertTrue(txsEmpty.data.incoming_transactions.length == 0); t.assertTrue(txsEmpty.data.incoming_transactions.length == 0);
@ -93,7 +95,7 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
subject: "Anastasis donation", subject: "Anastasis donation",
amount: "EUR:3", // Sandbox takes currency from its 'config' amount: "EUR:3", // Sandbox takes currency from its 'config'
}, },
) );
LibeufinSandboxApi.simulateIncomingTransaction( LibeufinSandboxApi.simulateIncomingTransaction(
libeufinServices.libeufinSandbox, libeufinServices.libeufinSandbox,
@ -105,7 +107,7 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
subject: "another Anastasis donation", subject: "another Anastasis donation",
amount: "EUR:1", // Sandbox takes currency from its "config" amount: "EUR:1", // Sandbox takes currency from its "config"
}, },
) );
await LibeufinNexusApi.fetchTransactions( await LibeufinNexusApi.fetchTransactions(
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
@ -115,18 +117,24 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
let txs = await LibeufinNexusApi.getAnastasisTransactions( let txs = await LibeufinNexusApi.getAnastasisTransactions(
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
anastasisBaseUrl, anastasisBaseUrl,
{delta: 5}, { delta: 5 },
user01nexus.userReq.username, user01nexus.userReq.username,
user01nexus.userReq.password, user01nexus.userReq.password,
); );
// check the two payments show up // check the two payments show up
let txsList = txs.data.incoming_transactions let txsList = txs.data.incoming_transactions;
t.assertTrue(txsList.length == 2); t.assertTrue(txsList.length == 2);
t.assertTrue([txsList[0].subject, txsList[1].subject].includes("Anastasis donation")); t.assertTrue(
t.assertTrue([txsList[0].subject, txsList[1].subject].includes("another Anastasis donation")); [txsList[0].subject, txsList[1].subject].includes("Anastasis donation"),
t.assertTrue(txsList[0].row_id == 1) );
t.assertTrue(txsList[1].row_id == 2) t.assertTrue(
[txsList[0].subject, txsList[1].subject].includes(
"another Anastasis donation",
),
);
t.assertTrue(txsList[0].row_id == 1);
t.assertTrue(txsList[1].row_id == 2);
LibeufinSandboxApi.simulateIncomingTransaction( LibeufinSandboxApi.simulateIncomingTransaction(
libeufinServices.libeufinSandbox, libeufinServices.libeufinSandbox,
@ -138,7 +146,7 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
subject: "last Anastasis donation", subject: "last Anastasis donation",
amount: "EUR:10.10", // Sandbox takes currency from its "config" amount: "EUR:10.10", // Sandbox takes currency from its "config"
}, },
) );
await LibeufinNexusApi.fetchTransactions( await LibeufinNexusApi.fetchTransactions(
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
@ -148,16 +156,18 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
let txsLast = await LibeufinNexusApi.getAnastasisTransactions( let txsLast = await LibeufinNexusApi.getAnastasisTransactions(
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
anastasisBaseUrl, anastasisBaseUrl,
{delta: 5, start: 2}, { delta: 5, start: 2 },
user01nexus.userReq.username, user01nexus.userReq.username,
user01nexus.userReq.password, user01nexus.userReq.password,
); );
console.log(txsLast.data.incoming_transactions[0].subject == "last Anastasis donation"); console.log(
txsLast.data.incoming_transactions[0].subject == "last Anastasis donation",
);
let txsReverse = await LibeufinNexusApi.getAnastasisTransactions( let txsReverse = await LibeufinNexusApi.getAnastasisTransactions(
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
anastasisBaseUrl, anastasisBaseUrl,
{delta: -5, start: 4}, { delta: -5, start: 4 },
user01nexus.userReq.username, user01nexus.userReq.username,
user01nexus.userReq.password, user01nexus.userReq.password,
); );

View File

@ -43,7 +43,9 @@ export async function runLibeufinKeyrotationTest(t: GlobalTestState) {
* Launch Sandbox and Nexus. * Launch Sandbox and Nexus.
*/ */
const libeufinServices = await launchLibeufinServices( const libeufinServices = await launchLibeufinServices(
t, [user01nexus], [user01sandbox], t,
[user01nexus],
[user01sandbox],
); );
await LibeufinNexusApi.fetchTransactions( await LibeufinNexusApi.fetchTransactions(

View File

@ -23,7 +23,7 @@ import {
NexusUserBundle, NexusUserBundle,
launchLibeufinServices, launchLibeufinServices,
LibeufinNexusApi, LibeufinNexusApi,
LibeufinCli LibeufinCli,
} from "../harness/libeufin.js"; } from "../harness/libeufin.js";
/** /**

View File

@ -36,13 +36,13 @@ export async function runLibeufinSandboxWireTransferCliTest(
"mock-account", "mock-account",
"password-unused", "password-unused",
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" }, { baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
"DE71500105179674997361" "DE71500105179674997361",
); );
await LibeufinSandboxApi.createDemobankAccount( await LibeufinSandboxApi.createDemobankAccount(
"mock-account-2", "mock-account-2",
"password-unused", "password-unused",
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" }, { baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
"DE71500105179674997364" "DE71500105179674997364",
); );
await sandbox.makeTransaction( await sandbox.makeTransaction(

View File

@ -101,8 +101,10 @@ export async function runLibeufinTutorialTest(t: GlobalTestState) {
}; };
await libeufinCli.importBankAccount(bankAccountImportDetails); await libeufinCli.importBankAccount(bankAccountImportDetails);
await libeufinSandbox.c53tick() await libeufinSandbox.c53tick();
await libeufinCli.fetchTransactions(bankAccountImportDetails.nexusBankAccountName); await libeufinCli.fetchTransactions(
bankAccountImportDetails.nexusBankAccountName,
);
await libeufinCli.transactions(bankAccountImportDetails.nexusBankAccountName); await libeufinCli.transactions(bankAccountImportDetails.nexusBankAccountName);
const paymentDetails = { const paymentDetails = {

View File

@ -26,7 +26,7 @@ import {
MerchantApiClient, MerchantApiClient,
MerchantService, MerchantService,
setupDb, setupDb,
getPayto getPayto,
} from "../harness/harness.js"; } from "../harness/harness.js";
/** /**

View File

@ -18,7 +18,10 @@
* Imports. * Imports.
*/ */
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js"; import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "../harness/helpers.js"; import {
createSimpleTestkudosEnvironment,
withdrawViaBank,
} from "../harness/helpers.js";
import { import {
PreparePayResultType, PreparePayResultType,
codecForMerchantOrderStatusUnpaid, codecForMerchantOrderStatusUnpaid,
@ -35,12 +38,8 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
export async function runMerchantLongpollingTest(t: GlobalTestState) { export async function runMerchantLongpollingTest(t: GlobalTestState) {
// Set up test environment // Set up test environment
const { const { wallet, bank, exchange, merchant } =
wallet, await createSimpleTestkudosEnvironment(t);
bank,
exchange,
merchant,
} = await createSimpleTestkudosEnvironment(t);
// Withdraw digital cash into the wallet. // Withdraw digital cash into the wallet.

View File

@ -22,7 +22,10 @@ import {
withdrawViaBank, withdrawViaBank,
createFaultInjectedMerchantTestkudosEnvironment, createFaultInjectedMerchantTestkudosEnvironment,
} from "../harness/helpers.js"; } from "../harness/helpers.js";
import { FaultInjectionRequestContext, FaultInjectionResponseContext } from "../harness/faultInjection.js"; import {
FaultInjectionRequestContext,
FaultInjectionResponseContext,
} from "../harness/faultInjection.js";
import { import {
codecForMerchantOrderStatusUnpaid, codecForMerchantOrderStatusUnpaid,
ConfirmPayResultType, ConfirmPayResultType,
@ -147,7 +150,10 @@ export async function runPaymentAbortTest(t: GlobalTestState) {
await wallet.runUntilDone(); await wallet.runUntilDone();
const txns2 = await wallet.client.call(WalletApiOperation.GetTransactions, {}); const txns2 = await wallet.client.call(
WalletApiOperation.GetTransactions,
{},
);
console.log(j2s(txns2)); console.log(j2s(txns2));
const txTypes = txns2.transactions.map((x) => x.type); const txTypes = txns2.transactions.map((x) => x.type);

View File

@ -30,12 +30,8 @@ import {
export async function runPaymentForgettableTest(t: GlobalTestState) { export async function runPaymentForgettableTest(t: GlobalTestState) {
// Set up test environment // Set up test environment
const { const { wallet, bank, exchange, merchant } =
wallet, await createSimpleTestkudosEnvironment(t);
bank,
exchange,
merchant,
} = await createSimpleTestkudosEnvironment(t);
// Withdraw digital cash into the wallet. // Withdraw digital cash into the wallet.

View File

@ -25,15 +25,13 @@ import {
MerchantService, MerchantService,
WalletCli, WalletCli,
MerchantPrivateApi, MerchantPrivateApi,
getPayto getPayto,
} from "../harness/harness.js"; } from "../harness/harness.js";
import { withdrawViaBank } from "../harness/helpers.js"; import { withdrawViaBank } from "../harness/helpers.js";
import { coin_ct10, coin_u1 } from "../harness/denomStructures.js"; import { coin_ct10, coin_u1 } from "../harness/denomStructures.js";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
async function setupTest( async function setupTest(t: GlobalTestState): Promise<{
t: GlobalTestState,
): Promise<{
merchant: MerchantService; merchant: MerchantService;
exchange: ExchangeService; exchange: ExchangeService;
bank: BankService; bank: BankService;

View File

@ -22,9 +22,7 @@ import {
withdrawViaBank, withdrawViaBank,
createFaultInjectedMerchantTestkudosEnvironment, createFaultInjectedMerchantTestkudosEnvironment,
} from "../harness/helpers.js"; } from "../harness/helpers.js";
import { import { FaultInjectionResponseContext } from "../harness/faultInjection.js";
FaultInjectionResponseContext,
} from "../harness/faultInjection.js";
import { import {
codecForMerchantOrderStatusUnpaid, codecForMerchantOrderStatusUnpaid,
ConfirmPayResultType, ConfirmPayResultType,
@ -44,12 +42,8 @@ const axios = axiosImp.default;
export async function runPaymentTransientTest(t: GlobalTestState) { export async function runPaymentTransientTest(t: GlobalTestState) {
// Set up test environment // Set up test environment
const { const { wallet, bank, exchange, faultyMerchant } =
wallet, await createFaultInjectedMerchantTestkudosEnvironment(t);
bank,
exchange,
faultyMerchant,
} = await createFaultInjectedMerchantTestkudosEnvironment(t);
// Withdraw digital cash into the wallet. // Withdraw digital cash into the wallet.
@ -81,8 +75,6 @@ export async function runPaymentTransientTest(t: GlobalTestState) {
}); });
if (publicOrderStatusResp.status != 402) { if (publicOrderStatusResp.status != 402) {
throw Error( throw Error(
`expected status 402 (before claiming), but got ${publicOrderStatusResp.status}`, `expected status 402 (before claiming), but got ${publicOrderStatusResp.status}`,
); );

View File

@ -32,12 +32,8 @@ import {
export async function runPaymentZeroTest(t: GlobalTestState) { export async function runPaymentZeroTest(t: GlobalTestState) {
// Set up test environment // Set up test environment
const { const { wallet, bank, exchange, merchant } =
wallet, await createSimpleTestkudosEnvironment(t);
bank,
exchange,
merchant,
} = await createSimpleTestkudosEnvironment(t);
// First, make a "free" payment when we don't even have // First, make a "free" payment when we don't even have
// any money in the // any money in the

View File

@ -30,12 +30,8 @@ import {
export async function runPaymentTest(t: GlobalTestState) { export async function runPaymentTest(t: GlobalTestState) {
// Set up test environment // Set up test environment
const { const { wallet, bank, exchange, merchant } =
wallet, await createSimpleTestkudosEnvironment(t);
bank,
exchange,
merchant,
} = await createSimpleTestkudosEnvironment(t);
// Withdraw digital cash into the wallet. // Withdraw digital cash into the wallet.

View File

@ -61,7 +61,7 @@ export async function runPeerToPeerPullTest(t: GlobalTestState) {
partialContractTerms: { partialContractTerms: {
summary: "Hello World", summary: "Hello World",
amount: "TESTKUDOS:5", amount: "TESTKUDOS:5",
purse_expiration purse_expiration,
}, },
}, },
); );

View File

@ -61,7 +61,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
partialContractTerms: { partialContractTerms: {
summary: "Hello World 😁😇", summary: "Hello World 😁😇",
amount: "TESTKUDOS:5", amount: "TESTKUDOS:5",
purse_expiration purse_expiration,
}, },
}, },
); );
@ -74,7 +74,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
partialContractTerms: { partialContractTerms: {
summary: "Hello World 🥺", summary: "Hello World 🥺",
amount: "TESTKUDOS:5", amount: "TESTKUDOS:5",
purse_expiration purse_expiration,
}, },
}, },
); );
@ -115,16 +115,13 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
console.log(`txn2: ${j2s(txn2)}`); console.log(`txn2: ${j2s(txn2)}`);
const ex1 = await t.assertThrowsTalerErrorAsync(async () => { const ex1 = await t.assertThrowsTalerErrorAsync(async () => {
await wallet1.client.call( await wallet1.client.call(WalletApiOperation.InitiatePeerPushPayment, {
WalletApiOperation.InitiatePeerPushPayment, partialContractTerms: {
{ summary: "(this will fail)",
partialContractTerms: { amount: "TESTKUDOS:15",
summary: "(this will fail)", purse_expiration,
amount: "TESTKUDOS:15",
purse_expiration
},
}, },
); });
}); });
console.log("got expected exception detail", j2s(ex1.errorDetail)); console.log("got expected exception detail", j2s(ex1.errorDetail));

View File

@ -103,9 +103,12 @@ export async function runRefundTest(t: GlobalTestState) {
} }
{ {
const r3 = await wallet.client.call(WalletApiOperation.ApplyRefundFromPurchaseId, { const r3 = await wallet.client.call(
purchaseId: r1.proposalId WalletApiOperation.ApplyRefundFromPurchaseId,
}); {
purchaseId: r1.proposalId,
},
);
console.log(r3); console.log(r3);
await wallet.runUntilDone(); await wallet.runUntilDone();

View File

@ -36,7 +36,7 @@ import {
MerchantService, MerchantService,
setupDb, setupDb,
WalletCli, WalletCli,
getPayto getPayto,
} from "../harness/harness.js"; } from "../harness/harness.js";
import { startWithdrawViaBank, withdrawViaBank } from "../harness/helpers.js"; import { startWithdrawViaBank, withdrawViaBank } from "../harness/helpers.js";

View File

@ -143,7 +143,9 @@ export async function runWalletBalanceTest(t: GlobalTestState) {
); );
t.assertTrue( t.assertTrue(
Amounts.isNonZero(preparePayResult.balanceDetails.balanceMerchantAcceptable), Amounts.isNonZero(
preparePayResult.balanceDetails.balanceMerchantAcceptable,
),
); );
t.assertTrue( t.assertTrue(

View File

@ -43,7 +43,9 @@ export async function runWalletDblessTest(t: GlobalTestState) {
const { bank, exchange } = await createSimpleTestkudosEnvironment(t); const { bank, exchange } = await createSimpleTestkudosEnvironment(t);
const http = new NodeHttpLib(); const http = new NodeHttpLib();
const cryptiDisp = new CryptoDispatcher(new SynchronousCryptoWorkerFactoryNode()); const cryptiDisp = new CryptoDispatcher(
new SynchronousCryptoWorkerFactoryNode(),
);
const cryptoApi = cryptiDisp.cryptoApi; const cryptoApi = cryptiDisp.cryptoApi;
try { try {