harness: wallet must always withdraw via fault-injected exchange

Otherwise, the ports in the base URL don't match and the wallet will
complain.
This commit is contained in:
Florian Dold 2023-06-21 08:54:14 +02:00
parent 9f8faed2d1
commit ba913cd2ce
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
3 changed files with 24 additions and 13 deletions

View File

@ -43,12 +43,17 @@ const axios = axiosImp.default;
export async function runPaymentAbortTest(t: GlobalTestState) {
// Set up test environment
const { wallet, bank, exchange, faultyMerchant } =
const { wallet, bank, exchange, faultyMerchant, faultyExchange } =
await createFaultInjectedMerchantTestkudosEnvironment(t);
// Withdraw digital cash into the wallet.
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" });
await withdrawViaBank(t, {
wallet,
bank,
exchange: faultyExchange,
amount: "TESTKUDOS:20",
});
const merchant = faultyMerchant;
@ -112,8 +117,6 @@ export async function runPaymentAbortTest(t: GlobalTestState) {
publicOrderStatusResp.data,
);
let faultInjected = false;
faultyMerchant.faultProxy.addFault({
async modifyRequest(ctx: FaultInjectionRequestContext) {
const url = new URL(ctx.requestUrl);

View File

@ -71,7 +71,16 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
"x",
);
bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri);
const faultyExchange = new FaultInjectedExchangeService(t, exchange, 8091);
// Base URL must contain port that the proxy is listening on.
await exchange.modifyConfig(async (config) => {
config.setString("exchange", "base_url", "http://localhost:8091/");
});
bank.setSuggestedExchange(
faultyExchange,
exchangeBankAccount.accountPaytoUri,
);
await bank.start();
@ -83,12 +92,6 @@ export async function runPaymentFaultTest(t: GlobalTestState) {
await exchange.start();
await exchange.pingUntilAvailable();
const faultyExchange = new FaultInjectedExchangeService(t, exchange, 8091);
// Base URL must contain port that the proxy is listening on.
await exchange.modifyConfig(async (config) => {
config.setString("exchange", "base_url", "http://localhost:8091/");
});
// Print all requests to the exchange
faultyExchange.faultProxy.addFault({
async modifyRequest(ctx: FaultInjectionRequestContext) {

View File

@ -42,12 +42,17 @@ const axios = axiosImp.default;
export async function runPaymentTransientTest(t: GlobalTestState) {
// Set up test environment
const { wallet, bank, exchange, faultyMerchant } =
const { wallet, bank, exchange, faultyMerchant, faultyExchange } =
await createFaultInjectedMerchantTestkudosEnvironment(t);
// Withdraw digital cash into the wallet.
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" });
await withdrawViaBank(t, {
wallet,
bank,
exchange: faultyExchange,
amount: "TESTKUDOS:20",
});
const merchant = faultyMerchant;