do normal back-off when reserve isn't ready yet, run retry-loop in integration test
This commit is contained in:
parent
0c9358c1b2
commit
aa37ef082d
@ -40,6 +40,11 @@ export async function runIntegrationTest(args: {
|
|||||||
|
|
||||||
const myWallet = await getDefaultNodeWallet({ httpLib: myHttpLib });
|
const myWallet = await getDefaultNodeWallet({ httpLib: myHttpLib });
|
||||||
|
|
||||||
|
|
||||||
|
myWallet.runRetryLoop().catch((e) => {
|
||||||
|
console.error("exception during retry loop:", e);
|
||||||
|
});
|
||||||
|
|
||||||
logger.info("withdrawing test balance");
|
logger.info("withdrawing test balance");
|
||||||
await withdrawTestBalance(myWallet, args.amountToWithdraw, args.bankBaseUrl, args.exchangeBaseUrl);
|
await withdrawTestBalance(myWallet, args.amountToWithdraw, args.bankBaseUrl, args.exchangeBaseUrl);
|
||||||
logger.info("done withdrawing test balance");
|
logger.info("done withdrawing test balance");
|
||||||
|
@ -37,7 +37,8 @@ function updateRetryDelay(
|
|||||||
retryTimestamp: Timestamp,
|
retryTimestamp: Timestamp,
|
||||||
): Duration {
|
): Duration {
|
||||||
const remaining = getDurationRemaining(retryTimestamp, now);
|
const remaining = getDurationRemaining(retryTimestamp, now);
|
||||||
return durationMin(oldDelay, remaining);
|
const nextDelay = durationMin(oldDelay, remaining);
|
||||||
|
return nextDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function gatherExchangePending(
|
async function gatherExchangePending(
|
||||||
|
@ -53,6 +53,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
guardOperationException,
|
guardOperationException,
|
||||||
OperationFailedAndReportedError,
|
OperationFailedAndReportedError,
|
||||||
|
OperationFailedError,
|
||||||
} from "./errors";
|
} from "./errors";
|
||||||
import { NotificationType } from "../types/notifications";
|
import { NotificationType } from "../types/notifications";
|
||||||
import { codecForReserveStatus } from "../types/ReserveStatus";
|
import { codecForReserveStatus } from "../types/ReserveStatus";
|
||||||
@ -351,8 +352,11 @@ async function incrementReserveRetry(
|
|||||||
if (!r.retryInfo) {
|
if (!r.retryInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log("updating retry info");
|
||||||
|
console.log("before", r.retryInfo);
|
||||||
r.retryInfo.retryCounter++;
|
r.retryInfo.retryCounter++;
|
||||||
updateRetryInfoTimeout(r.retryInfo);
|
updateRetryInfoTimeout(r.retryInfo);
|
||||||
|
console.log("after", r.retryInfo);
|
||||||
r.lastError = err;
|
r.lastError = err;
|
||||||
await tx.put(Stores.reserves, r);
|
await tx.put(Stores.reserves, r);
|
||||||
});
|
});
|
||||||
@ -392,14 +396,18 @@ async function updateReserve(
|
|||||||
resp = await ws.http.get(reqUrl.href);
|
resp = await ws.http.get(reqUrl.href);
|
||||||
console.log("got reserve/status response", await resp.json());
|
console.log("got reserve/status response", await resp.json());
|
||||||
if (resp.status === 404) {
|
if (resp.status === 404) {
|
||||||
const m = "The exchange does not know about this reserve (yet).";
|
const m = "reserve not known to the exchange yet"
|
||||||
await incrementReserveRetry(ws, reservePub, undefined);
|
throw new OperationFailedError(m, {
|
||||||
return;
|
type: "waiting",
|
||||||
|
message: m,
|
||||||
|
details: {},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (resp.status !== 200) {
|
if (resp.status !== 200) {
|
||||||
throw Error(`unexpected status code ${resp.status} for reserve/status`);
|
throw Error(`unexpected status code ${resp.status} for reserve/status`);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
logger.trace("caught exception for reserve/status");
|
||||||
const m = e.message;
|
const m = e.message;
|
||||||
await incrementReserveRetry(ws, reservePub, {
|
await incrementReserveRetry(ws, reservePub, {
|
||||||
type: "network",
|
type: "network",
|
||||||
|
Loading…
Reference in New Issue
Block a user