"use strict"; // Regression test for the self-update caller budget fix (round 4). // // The panel's only /v1/update/install caller (index.js installNodeUpdateInternal) // must outwait the daemon's full build+verify+response budget, not just its // build. The daemon's buildAdaemonBinary runs the go build under a 10-minute // context and the --version self-check under a 15-second one (~10m15s documented // worst case), and the install handler arms a 12-minute write deadline for this // response — so a 600s caller reported the install as failed while the swap // still completed daemon-side. (A same-version retry re-runs the install // idempotently — compareVersions treats equal versions as pass — so the only // hard guard is the downgrade check against a genuinely newer node version.) // // index.js cannot be required in-process (it boots servers on require), so — // same technique as node-relay-timeout-parity.test.js — this is a source-level // assertion. This endpoint has no nodes.js relay and no nodeFsPost parity row, // so it lives in its own file rather than the parity suite. const test = require("node:test"); const assert = require("node:assert"); const fs = require("node:fs"); const path = require("node:path"); const ROOT = path.join(__dirname, ".."); const INDEX_JS = path.join(ROOT, "index.js"); // Strip full-line comments so prose mentioning the budget cannot satisfy the // assertion. function stripFullLineComments(src) { return src .split("\n") .filter((line) => !/^\s*\/\//.test(line)) .join("\n"); } test("the /v1/update/install caller outwaits the daemon's build+verify budget", () => { const src = stripFullLineComments(fs.readFileSync(INDEX_JS, "utf8")); const at = src.indexOf('"/v1/update/install"'); assert.notStrictEqual(at, -1, "expected the /v1/update/install caller in index.js"); const window = src.slice(at, at + 600); assert.match( window, /timeoutMs:\s*13\s*\*\s*60\s*\*\s*1000/, "the /v1/update/install caller must wait 13m — the daemon's documented worst case (10m build + 15s verify under a 12m write deadline) plus margin; 600s reported installs as failed while the daemon still completed them" ); });