diff --git a/test/standing.test.ts b/test/standing.test.ts index de76be3..658ec6b 100644 --- a/test/standing.test.ts +++ b/test/standing.test.ts @@ -98,12 +98,13 @@ test("a consumer failed for minutes is announced, naming it, its machine and the const w = await world(); try { w.failing = new Error(`token request failed: 401 {"error":"invalid_grant"} for pw-a`); + // The loop stamps its own clock before it calls announce, so the test's stamp may read a few ms short: 10 ms of slack. // "Not before failingAfterMs" and "not again too soon" are read from the clock at the moment each is said, not // from a sleep: a sleep overruns under load and lets the very announcement it checks the absence of fall due. const asked = Date.now(); await w.ask([{ as: "a", node: "anchor" }]); await until(() => w.said.length === 1); - assert.ok(w.said[0].at - asked >= FAILING_AFTER, `announced after ${w.said[0].at - asked} ms, before failingAfterMs`); + assert.ok(w.said[0].at - asked >= FAILING_AFTER - 10, `announced after ${w.said[0].at - asked} ms, before failingAfterMs`); const b = w.said[0].body; assert.equal(w.said[0].event, FAILING_EVENT); assert.equal(b.consumer, "a"); @@ -118,7 +119,7 @@ test("a consumer failed for minutes is announced, naming it, its machine and the // Said again while it lasts, not every pass. await until(() => w.said.length === 2); assert.equal(events(w.said), `${FAILING_EVENT},${FAILING_EVENT}`); - assert.ok(w.said[1].at - w.said[0].at >= SAY_AGAIN, `repeated after ${w.said[1].at - w.said[0].at} ms, before sayAgainEveryMs`); + assert.ok(w.said[1].at - w.said[0].at >= SAY_AGAIN - 10, `repeated after ${w.said[1].at - w.said[0].at} ms, before sayAgainEveryMs`); // The first success takes it back. w.failing = null;