do normal back-off when reserve isn't ready yet, run retry-loop in integration test

This commit is contained in:
Florian Dold 2019-12-19 21:22:29 +01:00
parent 0c9358c1b2
commit aa37ef082d
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
3 changed files with 18 additions and 4 deletions

View File

@ -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");

View File

@ -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(

View File

@ -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",