aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-19 21:22:29 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-19 21:22:29 +0100
commitaa37ef082d0e4aaedeb219d0a3f726da146edba7 (patch)
tree2d5ebc419cf9e261cfa025340ca01f37d568fdc1
parent0c9358c1b2bd80e25940022e86bd8daef8184ad7 (diff)
do normal back-off when reserve isn't ready yet, run retry-loop in integration test
-rw-r--r--src/headless/integrationtest.ts5
-rw-r--r--src/operations/pending.ts3
-rw-r--r--src/operations/reserves.ts14
3 files changed, 18 insertions, 4 deletions
diff --git a/src/headless/integrationtest.ts b/src/headless/integrationtest.ts
index 7c513e70e..494f7c024 100644
--- a/src/headless/integrationtest.ts
+++ b/src/headless/integrationtest.ts
@@ -40,6 +40,11 @@ export async function runIntegrationTest(args: {
const myWallet = await getDefaultNodeWallet({ httpLib: myHttpLib });
+
+ myWallet.runRetryLoop().catch((e) => {
+ console.error("exception during retry loop:", e);
+ });
+
logger.info("withdrawing test balance");
await withdrawTestBalance(myWallet, args.amountToWithdraw, args.bankBaseUrl, args.exchangeBaseUrl);
logger.info("done withdrawing test balance");
diff --git a/src/operations/pending.ts b/src/operations/pending.ts
index ed3b59d71..f3cca9f24 100644
--- a/src/operations/pending.ts
+++ b/src/operations/pending.ts
@@ -37,7 +37,8 @@ function updateRetryDelay(
retryTimestamp: Timestamp,
): Duration {
const remaining = getDurationRemaining(retryTimestamp, now);
- return durationMin(oldDelay, remaining);
+ const nextDelay = durationMin(oldDelay, remaining);
+ return nextDelay;
}
async function gatherExchangePending(
diff --git a/src/operations/reserves.ts b/src/operations/reserves.ts
index 2dedf17de..7f5c7d05f 100644
--- a/src/operations/reserves.ts
+++ b/src/operations/reserves.ts
@@ -53,6 +53,7 @@ import {
import {
guardOperationException,
OperationFailedAndReportedError,
+ OperationFailedError,
} from "./errors";
import { NotificationType } from "../types/notifications";
import { codecForReserveStatus } from "../types/ReserveStatus";
@@ -351,8 +352,11 @@ async function incrementReserveRetry(
if (!r.retryInfo) {
return;
}
+ console.log("updating retry info");
+ console.log("before", r.retryInfo);
r.retryInfo.retryCounter++;
updateRetryInfoTimeout(r.retryInfo);
+ console.log("after", r.retryInfo);
r.lastError = err;
await tx.put(Stores.reserves, r);
});
@@ -392,14 +396,18 @@ async function updateReserve(
resp = await ws.http.get(reqUrl.href);
console.log("got reserve/status response", await resp.json());
if (resp.status === 404) {
- const m = "The exchange does not know about this reserve (yet).";
- await incrementReserveRetry(ws, reservePub, undefined);
- return;
+ const m = "reserve not known to the exchange yet"
+ throw new OperationFailedError(m, {
+ type: "waiting",
+ message: m,
+ details: {},
+ });
}
if (resp.status !== 200) {
throw Error(`unexpected status code ${resp.status} for reserve/status`);
}
} catch (e) {
+ logger.trace("caught exception for reserve/status");
const m = e.message;
await incrementReserveRetry(ws, reservePub, {
type: "network",