harness: wait for withdrawal, configure instance properly

This commit is contained in:
Florian Dold 2023-09-06 14:19:24 +02:00
parent 3ee3ab3ced
commit 6affe04fe6
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
6 changed files with 39 additions and 21 deletions

View File

@ -106,7 +106,7 @@ export async function runBankApiTest(t: GlobalTestState) {
// Make sure that registering twice results in a 409 Conflict
{
const e = await t.assertThrowsTalerErrorAsync(async () => {
await bankClient.registerAccount("user1", "pw1");
await bankClient.registerAccount("user1", "pw2");
});
t.assertTrue(e.errorDetail.httpStatusCode === 409);
}

View File

@ -50,13 +50,14 @@ export async function runDenomUnofferedTest(t: GlobalTestState) {
// Effectively we completely reset the exchange,
// but keep the exchange master public key.
await merchant.stop();
await exchange.stop();
await exchange.purgeDatabase();
await exchange.purgeSecmodKeys();
await exchange.start();
await exchange.pingUntilAvailable();
await merchant.stop();
await merchant.start();
await merchant.pingUntilAvailable();

View File

@ -123,13 +123,15 @@ export async function runPaymentMultipleTest(t: GlobalTestState) {
// Withdraw digital cash into the wallet.
await withdrawViaBankV2(t, {
const wres = await withdrawViaBankV2(t, {
walletClient,
bank,
exchange,
amount: "TESTKUDOS:100",
});
await wres.withdrawalFinishedCond;
// Set up order.
const orderResp = await merchantClient.createOrder({

View File

@ -44,13 +44,15 @@ export async function runRefundGoneTest(t: GlobalTestState) {
// Withdraw digital cash into the wallet.
await withdrawViaBankV2(t, {
const wres = await withdrawViaBankV2(t, {
walletClient,
bank,
exchange,
amount: "TESTKUDOS:20",
});
await wres.withdrawalFinishedCond;
// Set up order.
const orderResp = await merchantClient.createOrder({

View File

@ -19,7 +19,9 @@
*/
import {
Amounts,
Duration,
MerchantApiClient,
MerchantContractTerms,
PreparePayResultType,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
@ -41,7 +43,18 @@ export async function runWalletBalanceTest(t: GlobalTestState) {
const { merchant, walletClient, exchange, bank } =
await createSimpleTestkudosEnvironmentV2(t);
const merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl());
await merchant.addInstanceWithWireAccount({
id: "myinst",
name: "My Instance",
paytoUris: ["payto://void/foo"],
defaultWireTransferDelay: Duration.toTalerProtocolDuration(
Duration.fromSpec({ minutes: 1 }),
),
});
const merchantClient = new MerchantApiClient(
merchant.makeInstanceBaseUrl("myinst"),
);
// Withdraw digital cash into the wallet.
@ -54,7 +67,7 @@ export async function runWalletBalanceTest(t: GlobalTestState) {
await wres.withdrawalFinishedCond;
const order = {
const order: Partial<MerchantContractTerms> = {
summary: "Buy me!",
amount: "TESTKUDOS:5",
fulfillment_url: "taler://fulfillment-success/thx",

View File

@ -588,22 +588,22 @@ async function selectPayMerchantCandidates(
for (const acc of exchangeDetails.wireInfo.accounts) {
const pp = parsePaytoUri(acc.payto_uri);
checkLogicInvariant(!!pp);
if (pp.targetType === req.wireMethod) {
// also check that wire method is supported now
const wireFeeStr = exchangeDetails.wireInfo.feesForType[
req.wireMethod
]?.find((x) => {
return AbsoluteTime.isBetween(
AbsoluteTime.now(),
AbsoluteTime.fromProtocolTimestamp(x.startStamp),
AbsoluteTime.fromProtocolTimestamp(x.endStamp),
);
})?.wireFee;
if (wireFeeStr) {
wireMethodFee = wireFeeStr;
}
break;
if (pp.targetType !== req.wireMethod) {
continue;
}
const wireFeeStr = exchangeDetails.wireInfo.feesForType[
req.wireMethod
]?.find((x) => {
return AbsoluteTime.isBetween(
AbsoluteTime.now(),
AbsoluteTime.fromProtocolTimestamp(x.startStamp),
AbsoluteTime.fromProtocolTimestamp(x.endStamp),
);
})?.wireFee;
if (wireFeeStr) {
wireMethodFee = wireFeeStr;
}
break;
}
if (!wireMethodFee) {
break;