Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

workbenchthis machine

jam-stream.test.ts judges 'jams within 500 ms' on the readings' own clock, not the test machine's wall clock, so a loaded full run no longer fails it #556

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

smith/arm:smith/555-jam-stream-test-ts-judges-jams-within-50 → main 1 commit fork 1 thread · 1 unresolved

  • Merged. smith/555-jam-stream-test-ts-judges-jams-within-50 was merged into main as e8891c6.

Review

Sign in to review this change.
1 file changed +6 −3
Software/so101/src/jam-stream.test.ts +6 −3
@@ -5,6 +5,7 @@ import { join } from "node:path";
55 import WebSocket from "ws";
66 import { FeetechBus } from "./bus.ts";
77 import { FakeBus } from "./fake-bus.ts";
8 import { JAM_WINDOW_MS } from "./jam-watch.ts";
89 import { startServer, type RunningServer } from "./server.ts";
910
1011 // The jam watch on the stream, against servos that move like the real ones (FakeBus dynamics: 70 % load while
@@ -58,11 +59,13 @@ describe("a jam is load without progress", () => {
5859 const asked = performance.now();
5960 const push = setInterval(() => ws.send(JSON.stringify({ 1: START + 300, 2: START + 300 })), 20);
6061 let s = await get<Status>("/status");
61 while (!s.jammed.length && performance.now() - asked < 1500) s = await get<Status>((await sleep(10), "/status"));
62 const took = performance.now() - asked;
62 while (!s.jammed.length && performance.now() - asked < 3000) s = await get<Status>((await sleep(10), "/status")); // a deadline for the loop only
6363 clearInterval(push);
6464 expect(s.jammed).toEqual([2]);
65 expect(took).toBeLessThan(500);
65 // The rule decides on the readings' own clock, so that is what is judged; the test machine's load is not.
66 const ms = Number(/ for (\d+) ms /.exec(s.jams[0]!.why)?.[1]);
67 expect(ms).toBeGreaterThanOrEqual(JAM_WINDOW_MS);
68 expect(ms).toBeLessThanOrEqual(500);

Parsing ms out of the why text couples the test to the wording; if it changes, Number(undefined) gives NaN and the failure message will be confusing. Adding ms to the /status jam entry would be the fix.

6669 expect(s.jams).toEqual([{ id: 2, joint: "shoulder_lift", position: START, target: START + 300, load: 90, why: expect.stringContaining("pushed at 90%+ load") }]);
6770 expect(s.jams[0]!.why).toContain("moved 0 of the 300 ticks");
6871 expect(Math.abs(fake.position(1) - (START + 300))).toBeLessThanOrEqual(12); // the free joint kept going

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs