[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: allow fault injection callbac
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: allow fault injection callbacks to run async code |
Date: |
Mon, 08 Feb 2021 13:02:59 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new 883637d3 allow fault injection callbacks to run async code
883637d3 is described below
commit 883637d3f287e5026de5bcafb559ff3e6ba1f3bb
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Feb 8 13:02:12 2021 +0100
allow fault injection callbacks to run async code
---
.../src/integrationtests/faultInjection.ts | 19 ++++++-------------
.../src/integrationtests/test-exchange-management.ts | 4 ++--
.../src/integrationtests/test-pay-abort.ts | 6 +++---
.../src/integrationtests/test-pay-paid.ts | 2 +-
.../src/integrationtests/test-payment-fault.ts | 6 +++---
.../src/integrationtests/test-payment-transient.ts | 2 +-
6 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/packages/taler-wallet-cli/src/integrationtests/faultInjection.ts
b/packages/taler-wallet-cli/src/integrationtests/faultInjection.ts
index a2d4836d..60549154 100644
--- a/packages/taler-wallet-cli/src/integrationtests/faultInjection.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/faultInjection.ts
@@ -28,17 +28,10 @@ import { URL } from "url";
import {
GlobalTestState,
ExchangeService,
- BankService,
ExchangeServiceInterface,
MerchantServiceInterface,
MerchantService,
- PrivateOrderStatusQuery,
} from "./harness";
-import {
- PostOrderRequest,
- PostOrderResponse,
- MerchantOrderPrivateStatusResponse,
-} from "./merchantApiTypes";
export interface FaultProxyConfig {
inboundPort: number;
@@ -65,8 +58,8 @@ export interface FaultInjectionResponseContext {
}
export interface FaultSpec {
- modifyRequest?: (ctx: FaultInjectionRequestContext) => void;
- modifyResponse?: (ctx: FaultInjectionResponseContext) => void;
+ modifyRequest?: (ctx: FaultInjectionRequestContext) => Promise<void>;
+ modifyResponse?: (ctx: FaultInjectionResponseContext) => Promise<void>;
}
export class FaultProxy {
@@ -85,7 +78,7 @@ export class FaultProxy {
req.on("data", (chunk) => {
requestChunks.push(chunk);
});
- req.on("end", () => {
+ req.on("end", async () => {
console.log("end of data");
let requestBuffer: Buffer | undefined;
if (requestChunks.length > 0) {
@@ -103,7 +96,7 @@ export class FaultProxy {
for (const faultSpec of this.currentFaultSpecs) {
if (faultSpec.modifyRequest) {
- faultSpec.modifyRequest(faultReqContext);
+ await faultSpec.modifyRequest(faultReqContext);
}
}
@@ -138,7 +131,7 @@ export class FaultProxy {
proxyResp.on("data", (proxyRespData) => {
respChunks.push(proxyRespData);
});
- proxyResp.on("end", () => {
+ proxyResp.on("end", async () => {
console.log("end of target response");
let responseBuffer: Buffer | undefined;
if (respChunks.length > 0) {
@@ -154,7 +147,7 @@ export class FaultProxy {
for (const faultSpec of this.currentFaultSpecs) {
const modResponse = faultSpec.modifyResponse;
if (modResponse) {
- modResponse(faultRespContext);
+ await modResponse(faultRespContext);
}
}
if (faultRespContext.dropResponse) {
diff --git
a/packages/taler-wallet-cli/src/integrationtests/test-exchange-management.ts
b/packages/taler-wallet-cli/src/integrationtests/test-exchange-management.ts
index 6fc8bf3c..1b7deefc 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-exchange-management.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-exchange-management.ts
@@ -155,7 +155,7 @@ export async function runExchangeManagementTest(t:
GlobalTestState) {
t.assertTrue(exchangesList.exchanges.length === 0);
faultyExchange.faultProxy.addFault({
- modifyResponse(ctx: FaultInjectionResponseContext) {
+ async modifyResponse(ctx: FaultInjectionResponseContext) {
const url = new URL(ctx.request.requestUrl);
if (url.pathname === "/keys") {
const body = {
@@ -193,7 +193,7 @@ export async function runExchangeManagementTest(t:
GlobalTestState) {
faultyExchange.faultProxy.clearAllFaults();
faultyExchange.faultProxy.addFault({
- modifyResponse(ctx: FaultInjectionResponseContext) {
+ async modifyResponse(ctx: FaultInjectionResponseContext) {
const url = new URL(ctx.request.requestUrl);
if (url.pathname === "/keys") {
const keys = ctx.responseBody?.toString("utf-8");
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-pay-abort.ts
b/packages/taler-wallet-cli/src/integrationtests/test-pay-abort.ts
index 90a0edf0..44a81b51 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-pay-abort.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-pay-abort.ts
@@ -91,7 +91,7 @@ export async function runPayAbortTest(t: GlobalTestState) {
let firstDepositUrl: string | undefined;
faultyExchange.faultProxy.addFault({
- modifyRequest(ctx: FaultInjectionRequestContext) {
+ async modifyRequest(ctx: FaultInjectionRequestContext) {
const url = new URL(ctx.requestUrl);
if (url.pathname.endsWith("/deposit")) {
if (!firstDepositUrl) {
@@ -104,7 +104,7 @@ export async function runPayAbortTest(t: GlobalTestState) {
}
}
},
- modifyResponse(ctx: FaultInjectionResponseContext) {
+ async modifyResponse(ctx: FaultInjectionResponseContext) {
const url = new URL(ctx.request.requestUrl);
if (url.pathname.endsWith("/deposit") && url.href != firstDepositUrl) {
ctx.responseBody = Buffer.from("{}");
@@ -114,7 +114,7 @@ export async function runPayAbortTest(t: GlobalTestState) {
});
faultyMerchant.faultProxy.addFault({
- modifyResponse(ctx: FaultInjectionResponseContext) {
+ async modifyResponse(ctx: FaultInjectionResponseContext) {
const url = new URL(ctx.request.requestUrl);
if (url.pathname.endsWith("/pay") && url.href != firstDepositUrl) {
ctx.responseBody = Buffer.from("{}");
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-pay-paid.ts
b/packages/taler-wallet-cli/src/integrationtests/test-pay-paid.ts
index b0253b44..f826bdc6 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-pay-paid.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-pay-paid.ts
@@ -167,7 +167,7 @@ export async function runPayPaidTest(t: GlobalTestState) {
let numPaidRequested = 0;
faultyMerchant.faultProxy.addFault({
- modifyRequest(ctx: FaultInjectionRequestContext) {
+ async modifyRequest(ctx: FaultInjectionRequestContext) {
const url = new URL(ctx.requestUrl);
if (url.pathname.endsWith("/pay")) {
numPayRequested++;
diff --git
a/packages/taler-wallet-cli/src/integrationtests/test-payment-fault.ts
b/packages/taler-wallet-cli/src/integrationtests/test-payment-fault.ts
index 4462b4ff..713f7162 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-payment-fault.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-payment-fault.ts
@@ -83,10 +83,10 @@ export async function runPaymentFaultTest(t:
GlobalTestState) {
// Print all requests to the exchange
faultyExchange.faultProxy.addFault({
- modifyRequest(ctx: FaultInjectionRequestContext) {
+ async modifyRequest(ctx: FaultInjectionRequestContext) {
console.log("got request", ctx);
},
- modifyResponse(ctx: FaultInjectionResponseContext) {
+ async modifyResponse(ctx: FaultInjectionResponseContext) {
console.log("got response", ctx);
},
});
@@ -180,7 +180,7 @@ export async function runPaymentFaultTest(t:
GlobalTestState) {
// Drop 3 responses from the exchange.
let faultCount = 0;
faultyExchange.faultProxy.addFault({
- modifyResponse(ctx: FaultInjectionResponseContext) {
+ async modifyResponse(ctx: FaultInjectionResponseContext) {
if (!ctx.request.requestUrl.endsWith("/deposit")) {
return;
}
diff --git
a/packages/taler-wallet-cli/src/integrationtests/test-payment-transient.ts
b/packages/taler-wallet-cli/src/integrationtests/test-payment-transient.ts
index b059625a..b9e5670d 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-payment-transient.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-payment-transient.ts
@@ -116,7 +116,7 @@ export async function runPaymentTransientTest(t:
GlobalTestState) {
let faultInjected = false;
faultyMerchant.faultProxy.addFault({
- modifyResponse(ctx: FaultInjectionResponseContext) {
+ async modifyResponse(ctx: FaultInjectionResponseContext) {
console.log("in modifyResponse");
const url = new URL(ctx.request.requestUrl);
console.log("pathname is", url.pathname);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: allow fault injection callbacks to run async code,
gnunet <=