465d5198 - test(scrypt): cover the cooldown interval formula and the since hand-off - #4455
Conversation
Both properties were provably untested. Replacing `ageMs / 10` and the 30-minute cap with the flat one-minute floor left the suite green, and so did making getOrderStatus ignore its `since` argument and fetch the fixed 30-day window again — every existing cooldown test uses a freshly created order, where the interval is always the floor, and the adapter tests mock getOrderStatus away entirely. - pipeline service: a 100-minute-old order still owes its 10-minute wait after 9 minutes, and an 8-hour-old one is asked again after 31 because the cap holds it at 30 rather than the uncapped 48 - scrypt service: a caller-supplied `since` reaches the venue request as StartDate, and omitting it still yields the 30-day window
Review follow-up. Both cooldown tests asserted only the lower side of the interval, so a mutation that ENLARGES it stayed green: with `ageMs / 5` the order simply remains in cooldown and a "still waiting" assertion keeps passing, and the cap test is dominated by the cap whatever the divisor. Each test now brackets its exact threshold. For a 100-minute-old order the wait is satisfied once elapsed >= (100 min + elapsed) / 10, i.e. at 11 min 6.7 s — hence one call at 11 minutes and two at 11 min 20 s. The cap is bracketed at 29 min 59 s and 30 min 1 s, which also pins the boundary against a cap set too low.
The cap test bracketed 29 min 59 s and 30 min 1 s but never the boundary between them, which is the only place `<` and `<=` differ: at exactly 1_800_000 ms elapsed the production check admits the lookup, a `<=` variant would hold it back, and neither assertion point could tell them apart. Moving the second check onto 30 minutes exactly pins that too.
Checking at 29 min 59 s left the cap a whole second of room: any value between 1_799_001 and 1_799_999 ms produced the same two observations as the real 1_800_000, so a cap set slightly too low passed unnoticed. Checking one millisecond before the boundary closes that gap entirely. Also corrects the comment's arithmetic: 48 minutes is the uncapped wait at the first pass; by the boundary check the order has aged another 30 minutes and its uncapped wait is 51. Both are far past the cap, so the conclusion held, but the number did not.
The comment claimed the bracket leaves the cap "no room to sit anywhere else". That holds for every whole millisecond, which is every value the constant can actually take, but the test alone does not rule out a fractional one — so say whole-millisecond and mean it. Also fixes the grammar of the preceding clause.
|
Five review passes were needed to reach zero findings, across two dimensions each (conformance and logic). What changed along the way:
Verification on the final commit: One note for whoever picks this up next: neither touched file is anywhere near the coverage ratchet's bar. Measured on this branch, |
Follow-up to #4438. Two properties of that PR's behaviour were provably untested — both gaps were found by mutating the production code and observing that the suite stayed green.
The gaps, and how they were measured
ageMs / 10and both clamps replaced by the flatUNCERTAIN_RESOLVE_MIN_INTERVAL_MSMath.min(..., UNCERTAIN_RESOLVE_MAX_INTERVAL_MS)cap removedageMs / 10→ageMs / 5<→<=getOrderStatusignores itssinceargument and fetches the fixed 30-day windowEvery existing cooldown test creates its order with
created: new Date(), so the interval always lands on the one-minute floor — neither the age formula nor the 30-minute cap was ever exercised. And bothsincetests live inscrypt.adapter.spec.ts, wheregetOrderStatusis mocked away: they prove the adapter computes and passes the bound, not that it reaches the venue request.What is added
liquidity-management-pipeline.service.spec.ts, inside the existingvenue-lookup cooldownblock. Both tests bracket their threshold from both sides — a one-sided assertion would miss any mutation that enlarges the interval, since the order simply stays in cooldown and a "still waiting" assertion keeps passing:elapsed >= (100 min + elapsed) / 10, i.e. at 11 min 6.7 s — so one call at 11 minutes, two at 11 min 20 s<against<=scrypt.service.spec.ts, next to the existinggetOrderStatustests:sincereachesconnection.fetchasStartDateNo production code is touched, no existing test is modified, and both files use the helpers and fake-timer setup already present.
Verification
format:check,lintandtype-checkclean; the affected suites pass in band; each of the six mutations above turns at least one of the new tests red, and the control run returns to green.