pretty
This commit is contained in:
parent
b5c29a8bad
commit
40279ae7f0
@ -49,7 +49,9 @@ export async function runBench2(configJson: any): Promise<void> {
|
||||
// Validate the configuration file for this benchmark.
|
||||
const benchConf = codecForBench2Config().decode(configJson);
|
||||
const curr = benchConf.currency;
|
||||
const cryptoDisp = new CryptoDispatcher(new SynchronousCryptoWorkerFactoryNode());
|
||||
const cryptoDisp = new CryptoDispatcher(
|
||||
new SynchronousCryptoWorkerFactoryNode(),
|
||||
);
|
||||
const cryptoApi = cryptoDisp.cryptoApi;
|
||||
|
||||
const http = new NodeHttpLib();
|
||||
|
@ -59,7 +59,10 @@ export async function runBench3(configJson: any): Promise<void> {
|
||||
|
||||
const withdrawAmount = (numDeposits + 1) * 10;
|
||||
|
||||
const IDGenerator = benchMerchantIDGenerator(b3conf.randomAlg, b3conf.numMerchants ?? 100);
|
||||
const IDGenerator = benchMerchantIDGenerator(
|
||||
b3conf.randomAlg,
|
||||
b3conf.numMerchants ?? 100,
|
||||
);
|
||||
|
||||
logger.info(
|
||||
`Starting Benchmark iterations=${numIter} deposits=${numDeposits} with ${b3conf.randomAlg} merchant selection`,
|
||||
|
@ -16,16 +16,15 @@
|
||||
@author: Boss Marco
|
||||
*/
|
||||
|
||||
const getRandomInt = function(max: number) {
|
||||
const getRandomInt = function (max: number) {
|
||||
return Math.floor(Math.random() * max);
|
||||
}
|
||||
};
|
||||
|
||||
abstract class BenchMerchantIDGenerator {
|
||||
abstract getRandomMerchantID(): number
|
||||
abstract getRandomMerchantID(): number;
|
||||
}
|
||||
|
||||
class ZipfGenerator extends BenchMerchantIDGenerator {
|
||||
|
||||
weights: number[];
|
||||
total_weight: number;
|
||||
|
||||
@ -36,7 +35,7 @@ class ZipfGenerator extends BenchMerchantIDGenerator {
|
||||
/* we use integers (floor), make sure we have big enough values
|
||||
* by multiplying with
|
||||
* 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);
|
||||
}
|
||||
@ -48,7 +47,7 @@ class ZipfGenerator extends BenchMerchantIDGenerator {
|
||||
for (var i = 0; i < this.weights.length; i++) {
|
||||
current += this.weights[i];
|
||||
if (random <= current) {
|
||||
return i+1;
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,12 +57,11 @@ class ZipfGenerator extends BenchMerchantIDGenerator {
|
||||
}
|
||||
|
||||
class RandomGenerator extends BenchMerchantIDGenerator {
|
||||
|
||||
max: number
|
||||
max: number;
|
||||
|
||||
constructor(numMerchants: number) {
|
||||
super();
|
||||
this.max = numMerchants
|
||||
this.max = numMerchants;
|
||||
}
|
||||
|
||||
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) {
|
||||
case "zipf":
|
||||
return new ZipfGenerator(maxID);
|
||||
|
@ -1086,7 +1086,9 @@ export class ExchangeService implements ExchangeServiceInterface {
|
||||
* The modified exchange configuration will then be written to the
|
||||
* 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);
|
||||
await f(config);
|
||||
config.write(this.configFilename);
|
||||
|
@ -197,16 +197,13 @@ export namespace LibeufinSandboxApi {
|
||||
username: string,
|
||||
password: string,
|
||||
libeufinSandboxService: LibeufinSandboxServiceInterface,
|
||||
iban: string|null = null,
|
||||
iban: string | null = null,
|
||||
) {
|
||||
let url = new URL(
|
||||
"testing/register",
|
||||
libeufinSandboxService.baseUrl
|
||||
);
|
||||
let url = new URL("testing/register", libeufinSandboxService.baseUrl);
|
||||
await axios.post(url.href, {
|
||||
username: username,
|
||||
password: password,
|
||||
iban: iban
|
||||
iban: iban,
|
||||
});
|
||||
}
|
||||
// Need /demobanks/$id as the base URL
|
||||
@ -218,10 +215,7 @@ export namespace LibeufinSandboxApi {
|
||||
password: string = "secret",
|
||||
) {
|
||||
// baseUrl should already be pointed to one demobank.
|
||||
let url = new URL(
|
||||
"ebics/subscribers",
|
||||
libeufinSandboxService.baseUrl
|
||||
);
|
||||
let url = new URL("ebics/subscribers", libeufinSandboxService.baseUrl);
|
||||
await axios.post(
|
||||
url.href,
|
||||
{
|
||||
|
@ -56,7 +56,6 @@ import {
|
||||
CreateNexusUserRequest,
|
||||
} from "../harness/libeufin-apis.js";
|
||||
|
||||
|
||||
const logger = new Logger("libeufin.ts");
|
||||
|
||||
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(
|
||||
this.globalTestState,
|
||||
"libeufin-cli-registercustomer",
|
||||
@ -830,12 +832,12 @@ export async function launchLibeufinServices(
|
||||
await LibeufinSandboxApi.createDemobankAccount(
|
||||
sb.ebicsBankAccount.label,
|
||||
"password-unused",
|
||||
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/access-api/" }
|
||||
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
);
|
||||
await LibeufinSandboxApi.createDemobankEbicsSubscriber(
|
||||
sb.ebicsBankAccount.subscriber,
|
||||
sb.ebicsBankAccount.label,
|
||||
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/" }
|
||||
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/" },
|
||||
);
|
||||
}
|
||||
console.log("Sandbox user(s) / account(s) / subscriber(s): created");
|
||||
|
@ -82,7 +82,6 @@ export const codecForPostOrderResponse = (): Codec<PostOrderResponse> =>
|
||||
.property("token", codecOptional(codecForString()))
|
||||
.build("PostOrderResponse");
|
||||
|
||||
|
||||
export const codecForRefundDetails = (): Codec<RefundDetails> =>
|
||||
buildCodecForObject<RefundDetails>()
|
||||
.property("reason", codecForString())
|
||||
|
@ -115,5 +115,5 @@ export class SyncService {
|
||||
private globalState: GlobalTestState,
|
||||
private syncConfig: SyncConfig,
|
||||
private configFilename: string,
|
||||
) { }
|
||||
) {}
|
||||
}
|
||||
|
@ -1,2 +1,2 @@
|
||||
// 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);
|
||||
|
@ -18,7 +18,10 @@
|
||||
* Imports.
|
||||
*/
|
||||
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.
|
||||
@ -26,12 +29,8 @@ import { createSimpleTestkudosEnvironment, withdrawViaBank } from "../harness/he
|
||||
export async function runPromptPaymentScenario(t: GlobalTestState) {
|
||||
// Set up test environment
|
||||
|
||||
const {
|
||||
wallet,
|
||||
bank,
|
||||
exchange,
|
||||
merchant,
|
||||
} = await createSimpleTestkudosEnvironment(t);
|
||||
const { wallet, bank, exchange, merchant } =
|
||||
await createSimpleTestkudosEnvironment(t);
|
||||
|
||||
// Withdraw digital cash into the wallet.
|
||||
|
||||
|
@ -18,7 +18,10 @@
|
||||
* Imports.
|
||||
*/
|
||||
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 { GlobalTestState, WalletCli } from "../harness/harness.js";
|
||||
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(
|
||||
WalletApiOperation.InitiatePeerPushPayment,
|
||||
{
|
||||
partialContractTerms: {
|
||||
summary: "Hello, World",
|
||||
amount: "TESTKUDOS:1",
|
||||
purse_expiration,
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
await wallet.runUntilDone();
|
||||
|
||||
const checkResp = await walletTwo.client.call(WalletApiOperation.CheckPeerPushPayment, {
|
||||
const checkResp = await walletTwo.client.call(
|
||||
WalletApiOperation.CheckPeerPushPayment,
|
||||
{
|
||||
talerUri: initResp.talerUri,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
await walletTwo.client.call(WalletApiOperation.AcceptPeerPushPayment, {
|
||||
peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId,
|
||||
|
@ -18,7 +18,10 @@
|
||||
* Imports.
|
||||
*/
|
||||
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 { 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) {
|
||||
// Set up test environment
|
||||
|
||||
const {
|
||||
wallet,
|
||||
bank,
|
||||
exchange,
|
||||
merchant,
|
||||
} = await createSimpleTestkudosEnvironment(t);
|
||||
const { wallet, bank, exchange, merchant } =
|
||||
await createSimpleTestkudosEnvironment(t);
|
||||
|
||||
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" });
|
||||
|
||||
|
@ -55,20 +55,13 @@ export async function runDenomUnofferedTest(t: GlobalTestState) {
|
||||
fulfillment_url: "taler://fulfillment-success/thx",
|
||||
};
|
||||
|
||||
const orderResp = await MerchantPrivateApi.createOrder(
|
||||
merchant,
|
||||
"default",
|
||||
{
|
||||
const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", {
|
||||
order: order,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(
|
||||
merchant,
|
||||
{
|
||||
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||
orderId: orderResp.order_id,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
t.assertTrue(orderStatus.order_status === "unpaid");
|
||||
|
||||
@ -94,11 +87,10 @@ export async function runDenomUnofferedTest(t: GlobalTestState) {
|
||||
});
|
||||
|
||||
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)
|
||||
.code;
|
||||
const merchantErrorCode = ((tx.error as any).errorResponse as any).code;
|
||||
t.assertDeepEqual(
|
||||
merchantErrorCode,
|
||||
TalerErrorCode.MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_NOT_FOUND,
|
||||
|
@ -19,7 +19,10 @@
|
||||
*/
|
||||
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||
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.
|
||||
@ -27,12 +30,8 @@ import { createSimpleTestkudosEnvironment, withdrawViaBank } from "../harness/he
|
||||
export async function runDepositTest(t: GlobalTestState) {
|
||||
// Set up test environment
|
||||
|
||||
const {
|
||||
wallet,
|
||||
bank,
|
||||
exchange,
|
||||
merchant,
|
||||
} = await createSimpleTestkudosEnvironment(t);
|
||||
const { wallet, bank, exchange, merchant } =
|
||||
await createSimpleTestkudosEnvironment(t);
|
||||
|
||||
// Withdraw digital cash into the wallet.
|
||||
|
||||
|
@ -119,26 +119,26 @@ export async function createKycTestkudosEnvironment(
|
||||
"kyc_oauth2_info_url",
|
||||
"http://localhost:6666/oauth/v2/login",
|
||||
);
|
||||
config.setString(
|
||||
myprov,
|
||||
"kyc_oauth2_client_id",
|
||||
"taler-exchange",
|
||||
);
|
||||
config.setString(
|
||||
myprov,
|
||||
"kyc_oauth2_client_secret",
|
||||
"exchange-secret",
|
||||
);
|
||||
config.setString(
|
||||
myprov,
|
||||
"kyc_oauth2_post_url",
|
||||
"https://taler.com",
|
||||
);
|
||||
config.setString(myprov, "kyc_oauth2_client_id", "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("kyc-legitimization-withdraw1", "required_checks", "dummy1");
|
||||
config.setString(
|
||||
"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", "threshold", "TESTKUDOS:5");
|
||||
config.setString(
|
||||
"kyc-legitimization-withdraw1",
|
||||
"threshold",
|
||||
"TESTKUDOS:5",
|
||||
);
|
||||
});
|
||||
|
||||
await exchange.start();
|
||||
|
@ -53,7 +53,7 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
|
||||
"mock",
|
||||
"password-unused",
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
"DE71500105179674997361"
|
||||
"DE71500105179674997361",
|
||||
);
|
||||
await LibeufinSandboxApi.createDemobankEbicsSubscriber(
|
||||
{
|
||||
@ -62,7 +62,7 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
|
||||
userID: "mock",
|
||||
},
|
||||
"mock",
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/" }
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/" },
|
||||
);
|
||||
await LibeufinNexusApi.createEbicsBankConnection(nexus, {
|
||||
name: "bankaccount-api-test-connection",
|
||||
|
@ -37,12 +37,12 @@ export async function runLibeufinApiSandboxCamtTest(t: GlobalTestState) {
|
||||
await LibeufinSandboxApi.createDemobankAccount(
|
||||
"mock-account-0",
|
||||
"password-unused",
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" }
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
);
|
||||
await LibeufinSandboxApi.createDemobankAccount(
|
||||
"mock-account-1",
|
||||
"password-unused",
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" }
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
);
|
||||
await sandbox.makeTransaction(
|
||||
"mock-account-0",
|
||||
|
@ -36,7 +36,7 @@ export async function runLibeufinApiSandboxTransactionsTest(
|
||||
"mock-account",
|
||||
"password-unused",
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
"DE71500105179674997361"
|
||||
"DE71500105179674997361",
|
||||
);
|
||||
await LibeufinSandboxApi.simulateIncomingTransaction(
|
||||
sandbox,
|
||||
@ -46,7 +46,7 @@ export async function runLibeufinApiSandboxTransactionsTest(
|
||||
debtorBic: "BELADEBEXXX",
|
||||
debtorName: "mock2",
|
||||
subject: "mock subject",
|
||||
amount: "EUR:1"
|
||||
amount: "EUR:1",
|
||||
},
|
||||
);
|
||||
await LibeufinSandboxApi.simulateIncomingTransaction(
|
||||
@ -57,7 +57,7 @@ export async function runLibeufinApiSandboxTransactionsTest(
|
||||
debtorBic: "BELADEBEXXX",
|
||||
debtorName: "mock2",
|
||||
subject: "mock subject 2",
|
||||
amount: "EUR:1.1"
|
||||
amount: "EUR:1.1",
|
||||
},
|
||||
);
|
||||
let ret = await LibeufinSandboxApi.getAccountInfoWithBalance(
|
||||
|
@ -34,7 +34,8 @@ export async function runLibeufinBadGatewayTest(t: GlobalTestState) {
|
||||
* User saltetd "01"
|
||||
*/
|
||||
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
|
||||
@ -56,7 +57,7 @@ export async function runLibeufinBadGatewayTest(t: GlobalTestState) {
|
||||
// Connecting to a non-existent Sandbox endpoint.
|
||||
await LibeufinNexusApi.createEbicsBankConnection(
|
||||
libeufinNexus,
|
||||
user01nexus.connReq
|
||||
user01nexus.connReq,
|
||||
);
|
||||
|
||||
// 502 Bad Gateway expected.
|
||||
@ -65,7 +66,7 @@ export async function runLibeufinBadGatewayTest(t: GlobalTestState) {
|
||||
libeufinNexus,
|
||||
user01nexus.connReq.name,
|
||||
);
|
||||
} catch(e: any) {
|
||||
} catch (e: any) {
|
||||
t.assertTrue(e.response.status == 502);
|
||||
return;
|
||||
}
|
||||
|
@ -17,7 +17,11 @@
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { AbsoluteTime, MerchantContractTerms, Duration } from "@gnu-taler/taler-util";
|
||||
import {
|
||||
AbsoluteTime,
|
||||
MerchantContractTerms,
|
||||
Duration,
|
||||
} from "@gnu-taler/taler-util";
|
||||
import {
|
||||
WalletApiOperation,
|
||||
HarnessExchangeBankAccount,
|
||||
@ -85,7 +89,7 @@ export async function createLibeufinTestEnvironment(
|
||||
"exchangeacct",
|
||||
"password-unused",
|
||||
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
exchangeIban
|
||||
exchangeIban,
|
||||
);
|
||||
await LibeufinSandboxApi.createDemobankEbicsSubscriber(
|
||||
{
|
||||
@ -94,14 +98,14 @@ export async function createLibeufinTestEnvironment(
|
||||
userID: "user01",
|
||||
},
|
||||
"exchangeacct",
|
||||
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/" }
|
||||
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/" },
|
||||
);
|
||||
|
||||
await LibeufinSandboxApi.createDemobankAccount(
|
||||
"merchantacct",
|
||||
"password-unused",
|
||||
{ baseUrl: libeufinSandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
merchantIban
|
||||
merchantIban,
|
||||
);
|
||||
await LibeufinSandboxApi.createDemobankEbicsSubscriber(
|
||||
{
|
||||
|
@ -52,7 +52,9 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
|
||||
libeufinServices.libeufinNexus,
|
||||
);
|
||||
// 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"];
|
||||
t.assertTrue(typeof anastasisBaseUrl === "string");
|
||||
t.assertTrue(anastasisBaseUrl.startsWith("http://"));
|
||||
@ -63,8 +65,7 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.postPermission(
|
||||
libeufinServices.libeufinNexus, {
|
||||
await LibeufinNexusApi.postPermission(libeufinServices.libeufinNexus, {
|
||||
action: "grant",
|
||||
permission: {
|
||||
subjectId: user01nexus.userReq.username,
|
||||
@ -73,13 +74,14 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
|
||||
resourceId: user01nexus.anastasisReq.name,
|
||||
permissionName: "facade.anastasis.history",
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// check if empty.
|
||||
let txsEmpty = await LibeufinNexusApi.getAnastasisTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
anastasisBaseUrl, {delta: 5})
|
||||
anastasisBaseUrl,
|
||||
{ delta: 5 },
|
||||
);
|
||||
|
||||
t.assertTrue(txsEmpty.data.incoming_transactions.length == 0);
|
||||
|
||||
@ -93,7 +95,7 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
|
||||
subject: "Anastasis donation",
|
||||
amount: "EUR:3", // Sandbox takes currency from its 'config'
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
LibeufinSandboxApi.simulateIncomingTransaction(
|
||||
libeufinServices.libeufinSandbox,
|
||||
@ -105,7 +107,7 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
|
||||
subject: "another Anastasis donation",
|
||||
amount: "EUR:1", // Sandbox takes currency from its "config"
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
@ -115,18 +117,24 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
|
||||
let txs = await LibeufinNexusApi.getAnastasisTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
anastasisBaseUrl,
|
||||
{delta: 5},
|
||||
{ delta: 5 },
|
||||
user01nexus.userReq.username,
|
||||
user01nexus.userReq.password,
|
||||
);
|
||||
|
||||
// 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[0].subject, txsList[1].subject].includes("Anastasis donation"));
|
||||
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)
|
||||
t.assertTrue(
|
||||
[txsList[0].subject, txsList[1].subject].includes("Anastasis donation"),
|
||||
);
|
||||
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(
|
||||
libeufinServices.libeufinSandbox,
|
||||
@ -138,7 +146,7 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
|
||||
subject: "last Anastasis donation",
|
||||
amount: "EUR:10.10", // Sandbox takes currency from its "config"
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
@ -148,16 +156,18 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
|
||||
let txsLast = await LibeufinNexusApi.getAnastasisTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
anastasisBaseUrl,
|
||||
{delta: 5, start: 2},
|
||||
{ delta: 5, start: 2 },
|
||||
user01nexus.userReq.username,
|
||||
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(
|
||||
libeufinServices.libeufinNexus,
|
||||
anastasisBaseUrl,
|
||||
{delta: -5, start: 4},
|
||||
{ delta: -5, start: 4 },
|
||||
user01nexus.userReq.username,
|
||||
user01nexus.userReq.password,
|
||||
);
|
||||
|
@ -43,7 +43,9 @@ export async function runLibeufinKeyrotationTest(t: GlobalTestState) {
|
||||
* Launch Sandbox and Nexus.
|
||||
*/
|
||||
const libeufinServices = await launchLibeufinServices(
|
||||
t, [user01nexus], [user01sandbox],
|
||||
t,
|
||||
[user01nexus],
|
||||
[user01sandbox],
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
|
@ -23,7 +23,7 @@ import {
|
||||
NexusUserBundle,
|
||||
launchLibeufinServices,
|
||||
LibeufinNexusApi,
|
||||
LibeufinCli
|
||||
LibeufinCli,
|
||||
} from "../harness/libeufin.js";
|
||||
|
||||
/**
|
||||
|
@ -36,13 +36,13 @@ export async function runLibeufinSandboxWireTransferCliTest(
|
||||
"mock-account",
|
||||
"password-unused",
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
"DE71500105179674997361"
|
||||
"DE71500105179674997361",
|
||||
);
|
||||
await LibeufinSandboxApi.createDemobankAccount(
|
||||
"mock-account-2",
|
||||
"password-unused",
|
||||
{ baseUrl: sandbox.baseUrl + "/demobanks/default/access-api/" },
|
||||
"DE71500105179674997364"
|
||||
"DE71500105179674997364",
|
||||
);
|
||||
|
||||
await sandbox.makeTransaction(
|
||||
|
@ -101,8 +101,10 @@ export async function runLibeufinTutorialTest(t: GlobalTestState) {
|
||||
};
|
||||
|
||||
await libeufinCli.importBankAccount(bankAccountImportDetails);
|
||||
await libeufinSandbox.c53tick()
|
||||
await libeufinCli.fetchTransactions(bankAccountImportDetails.nexusBankAccountName);
|
||||
await libeufinSandbox.c53tick();
|
||||
await libeufinCli.fetchTransactions(
|
||||
bankAccountImportDetails.nexusBankAccountName,
|
||||
);
|
||||
await libeufinCli.transactions(bankAccountImportDetails.nexusBankAccountName);
|
||||
|
||||
const paymentDetails = {
|
||||
|
@ -26,7 +26,7 @@ import {
|
||||
MerchantApiClient,
|
||||
MerchantService,
|
||||
setupDb,
|
||||
getPayto
|
||||
getPayto,
|
||||
} from "../harness/harness.js";
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,10 @@
|
||||
* Imports.
|
||||
*/
|
||||
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
|
||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "../harness/helpers.js";
|
||||
import {
|
||||
createSimpleTestkudosEnvironment,
|
||||
withdrawViaBank,
|
||||
} from "../harness/helpers.js";
|
||||
import {
|
||||
PreparePayResultType,
|
||||
codecForMerchantOrderStatusUnpaid,
|
||||
@ -35,12 +38,8 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||
export async function runMerchantLongpollingTest(t: GlobalTestState) {
|
||||
// Set up test environment
|
||||
|
||||
const {
|
||||
wallet,
|
||||
bank,
|
||||
exchange,
|
||||
merchant,
|
||||
} = await createSimpleTestkudosEnvironment(t);
|
||||
const { wallet, bank, exchange, merchant } =
|
||||
await createSimpleTestkudosEnvironment(t);
|
||||
|
||||
// Withdraw digital cash into the wallet.
|
||||
|
||||
|
@ -22,7 +22,10 @@ import {
|
||||
withdrawViaBank,
|
||||
createFaultInjectedMerchantTestkudosEnvironment,
|
||||
} from "../harness/helpers.js";
|
||||
import { FaultInjectionRequestContext, FaultInjectionResponseContext } from "../harness/faultInjection.js";
|
||||
import {
|
||||
FaultInjectionRequestContext,
|
||||
FaultInjectionResponseContext,
|
||||
} from "../harness/faultInjection.js";
|
||||
import {
|
||||
codecForMerchantOrderStatusUnpaid,
|
||||
ConfirmPayResultType,
|
||||
@ -147,7 +150,10 @@ export async function runPaymentAbortTest(t: GlobalTestState) {
|
||||
|
||||
await wallet.runUntilDone();
|
||||
|
||||
const txns2 = await wallet.client.call(WalletApiOperation.GetTransactions, {});
|
||||
const txns2 = await wallet.client.call(
|
||||
WalletApiOperation.GetTransactions,
|
||||
{},
|
||||
);
|
||||
console.log(j2s(txns2));
|
||||
|
||||
const txTypes = txns2.transactions.map((x) => x.type);
|
||||
|
@ -30,12 +30,8 @@ import {
|
||||
export async function runPaymentForgettableTest(t: GlobalTestState) {
|
||||
// Set up test environment
|
||||
|
||||
const {
|
||||
wallet,
|
||||
bank,
|
||||
exchange,
|
||||
merchant,
|
||||
} = await createSimpleTestkudosEnvironment(t);
|
||||
const { wallet, bank, exchange, merchant } =
|
||||
await createSimpleTestkudosEnvironment(t);
|
||||
|
||||
// Withdraw digital cash into the wallet.
|
||||
|
||||
|
@ -25,15 +25,13 @@ import {
|
||||
MerchantService,
|
||||
WalletCli,
|
||||
MerchantPrivateApi,
|
||||
getPayto
|
||||
getPayto,
|
||||
} from "../harness/harness.js";
|
||||
import { withdrawViaBank } from "../harness/helpers.js";
|
||||
import { coin_ct10, coin_u1 } from "../harness/denomStructures.js";
|
||||
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||
|
||||
async function setupTest(
|
||||
t: GlobalTestState,
|
||||
): Promise<{
|
||||
async function setupTest(t: GlobalTestState): Promise<{
|
||||
merchant: MerchantService;
|
||||
exchange: ExchangeService;
|
||||
bank: BankService;
|
||||
|
@ -22,9 +22,7 @@ import {
|
||||
withdrawViaBank,
|
||||
createFaultInjectedMerchantTestkudosEnvironment,
|
||||
} from "../harness/helpers.js";
|
||||
import {
|
||||
FaultInjectionResponseContext,
|
||||
} from "../harness/faultInjection.js";
|
||||
import { FaultInjectionResponseContext } from "../harness/faultInjection.js";
|
||||
import {
|
||||
codecForMerchantOrderStatusUnpaid,
|
||||
ConfirmPayResultType,
|
||||
@ -44,12 +42,8 @@ const axios = axiosImp.default;
|
||||
export async function runPaymentTransientTest(t: GlobalTestState) {
|
||||
// Set up test environment
|
||||
|
||||
const {
|
||||
wallet,
|
||||
bank,
|
||||
exchange,
|
||||
faultyMerchant,
|
||||
} = await createFaultInjectedMerchantTestkudosEnvironment(t);
|
||||
const { wallet, bank, exchange, faultyMerchant } =
|
||||
await createFaultInjectedMerchantTestkudosEnvironment(t);
|
||||
|
||||
// Withdraw digital cash into the wallet.
|
||||
|
||||
@ -81,8 +75,6 @@ export async function runPaymentTransientTest(t: GlobalTestState) {
|
||||
});
|
||||
|
||||
if (publicOrderStatusResp.status != 402) {
|
||||
|
||||
|
||||
throw Error(
|
||||
`expected status 402 (before claiming), but got ${publicOrderStatusResp.status}`,
|
||||
);
|
||||
|
@ -32,12 +32,8 @@ import {
|
||||
export async function runPaymentZeroTest(t: GlobalTestState) {
|
||||
// Set up test environment
|
||||
|
||||
const {
|
||||
wallet,
|
||||
bank,
|
||||
exchange,
|
||||
merchant,
|
||||
} = await createSimpleTestkudosEnvironment(t);
|
||||
const { wallet, bank, exchange, merchant } =
|
||||
await createSimpleTestkudosEnvironment(t);
|
||||
|
||||
// First, make a "free" payment when we don't even have
|
||||
// any money in the
|
||||
|
@ -30,12 +30,8 @@ import {
|
||||
export async function runPaymentTest(t: GlobalTestState) {
|
||||
// Set up test environment
|
||||
|
||||
const {
|
||||
wallet,
|
||||
bank,
|
||||
exchange,
|
||||
merchant,
|
||||
} = await createSimpleTestkudosEnvironment(t);
|
||||
const { wallet, bank, exchange, merchant } =
|
||||
await createSimpleTestkudosEnvironment(t);
|
||||
|
||||
// Withdraw digital cash into the wallet.
|
||||
|
||||
|
@ -61,7 +61,7 @@ export async function runPeerToPeerPullTest(t: GlobalTestState) {
|
||||
partialContractTerms: {
|
||||
summary: "Hello World",
|
||||
amount: "TESTKUDOS:5",
|
||||
purse_expiration
|
||||
purse_expiration,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
@ -61,7 +61,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
|
||||
partialContractTerms: {
|
||||
summary: "Hello World 😁😇",
|
||||
amount: "TESTKUDOS:5",
|
||||
purse_expiration
|
||||
purse_expiration,
|
||||
},
|
||||
},
|
||||
);
|
||||
@ -74,7 +74,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
|
||||
partialContractTerms: {
|
||||
summary: "Hello World 🥺",
|
||||
amount: "TESTKUDOS:5",
|
||||
purse_expiration
|
||||
purse_expiration,
|
||||
},
|
||||
},
|
||||
);
|
||||
@ -115,16 +115,13 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
|
||||
console.log(`txn2: ${j2s(txn2)}`);
|
||||
|
||||
const ex1 = await t.assertThrowsTalerErrorAsync(async () => {
|
||||
await wallet1.client.call(
|
||||
WalletApiOperation.InitiatePeerPushPayment,
|
||||
{
|
||||
await wallet1.client.call(WalletApiOperation.InitiatePeerPushPayment, {
|
||||
partialContractTerms: {
|
||||
summary: "(this will fail)",
|
||||
amount: "TESTKUDOS:15",
|
||||
purse_expiration
|
||||
purse_expiration,
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
console.log("got expected exception detail", j2s(ex1.errorDetail));
|
||||
|
@ -103,9 +103,12 @@ export async function runRefundTest(t: GlobalTestState) {
|
||||
}
|
||||
|
||||
{
|
||||
const r3 = await wallet.client.call(WalletApiOperation.ApplyRefundFromPurchaseId, {
|
||||
purchaseId: r1.proposalId
|
||||
});
|
||||
const r3 = await wallet.client.call(
|
||||
WalletApiOperation.ApplyRefundFromPurchaseId,
|
||||
{
|
||||
purchaseId: r1.proposalId,
|
||||
},
|
||||
);
|
||||
console.log(r3);
|
||||
|
||||
await wallet.runUntilDone();
|
||||
|
@ -36,7 +36,7 @@ import {
|
||||
MerchantService,
|
||||
setupDb,
|
||||
WalletCli,
|
||||
getPayto
|
||||
getPayto,
|
||||
} from "../harness/harness.js";
|
||||
import { startWithdrawViaBank, withdrawViaBank } from "../harness/helpers.js";
|
||||
|
||||
|
@ -143,7 +143,9 @@ export async function runWalletBalanceTest(t: GlobalTestState) {
|
||||
);
|
||||
|
||||
t.assertTrue(
|
||||
Amounts.isNonZero(preparePayResult.balanceDetails.balanceMerchantAcceptable),
|
||||
Amounts.isNonZero(
|
||||
preparePayResult.balanceDetails.balanceMerchantAcceptable,
|
||||
),
|
||||
);
|
||||
|
||||
t.assertTrue(
|
||||
|
@ -43,7 +43,9 @@ export async function runWalletDblessTest(t: GlobalTestState) {
|
||||
const { bank, exchange } = await createSimpleTestkudosEnvironment(t);
|
||||
|
||||
const http = new NodeHttpLib();
|
||||
const cryptiDisp = new CryptoDispatcher(new SynchronousCryptoWorkerFactoryNode());
|
||||
const cryptiDisp = new CryptoDispatcher(
|
||||
new SynchronousCryptoWorkerFactoryNode(),
|
||||
);
|
||||
const cryptoApi = cryptiDisp.cryptoApi;
|
||||
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user