change around pings, fix main.js so the actual real fucking number shows instead of it freaking out.

This commit is contained in:
KingKDot
2026-07-09 13:55:36 -05:00
parent f96b3d0721
commit 43ee5a7d4b
12 changed files with 293 additions and 32 deletions
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { getHeartbeatBatchSize } from "./maintenance-loops";
import { getHeartbeatBatchSize, shouldSendHeartbeatPing } from "./maintenance-loops";
describe("maintenance heartbeat batching", () => {
test("spreads large fleets across the heartbeat interval", () => {
@@ -13,4 +13,11 @@ describe("maintenance heartbeat batching", () => {
test("handles empty fleets", () => {
expect(getHeartbeatBatchSize(0, 30_000)).toBe(0);
});
test("only sends heartbeat pings after the per-client interval", () => {
const now = Date.now();
expect(shouldSendHeartbeatPing({}, now, 30_000)).toBe(true);
expect(shouldSendHeartbeatPing({ lastPingSent: now - 29_999 }, now, 30_000)).toBe(false);
expect(shouldSendHeartbeatPing({ lastPingSent: now - 30_000 }, now, 30_000)).toBe(true);
});
});