Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(scripts): cover JSON-RPC product target routing

Steven Enamakel7b9cbe9d5869
diff --git a/scripts/__tests__/rust-product-enumeration.test.mjs b/scripts/__tests__/rust-product-enumeration.test.mjs
index 168376d1c7..6a91837d5a 100644
--- a/scripts/__tests__/rust-product-enumeration.test.mjs
+++ b/scripts/__tests__/rust-product-enumeration.test.mjs
@@ -20,6 +20,31 @@ const end = source.indexOf("\n}\n", start);
assert.ok(start >= 0 && end > start);
const body = source.slice(start, end + 3);
+function extractFunction(name) {
+ const functionStart = source.indexOf(`${name}() {`);
+ const functionEnd = source.indexOf("\n}\n", functionStart);
+ assert.ok(functionStart >= 0 && functionEnd > functionStart, `${name} exists`);
+ return source.slice(functionStart, functionEnd + 3);
+}
+
+const fullSuite = extractFunction("run_full_suite");
+const dispatchStart = source.indexOf('if [ "$#" -eq 0 ]; then\n run_full_suite');
+assert.ok(dispatchStart >= 0, "explicit target dispatch block exists");
+const dispatch = source.slice(dispatchStart);
+
+const JSON_RPC_TARGETS = [
+ "json_rpc_threads_e2e",
+ "json_rpc_wallet_e2e",
+ "json_rpc_flows_e2e",
+ "json_rpc_mcp_e2e",
+ "json_rpc_inference_e2e",
+ "json_rpc_auth_security_e2e",
+ "json_rpc_config_e2e",
+ "json_rpc_agent_team_e2e",
+ "json_rpc_web_chat_e2e",
+ "json_rpc_misc_e2e",
+];
+
for (const [description, listing, code] of [
["failed", "", 101],
["partial", "scenario_a: test\n", 101],
@@ -150,6 +175,93 @@ printf "%s\\n" "$*" >> "$TEST_RAN"
}
});
+test("the full product runner enumerates and runs each JSON-RPC target once", () => {
+ const root = mkdtempSync(join(tmpdir(), "product-suite-routing-"));
+ try {
+ const log = join(root, "cargo.log");
+ const script = [
+ "set -euo pipefail",
+ `RUN_LOG='${log}'`,
+ 'cargo_test() {\n printf "CARGO\\t%s\\n" "$*" >> "$RUN_LOG"\n local previous= target= arg\n for arg in "$@"; do\n if [ "$previous" = "--test" ]; then target="$arg"; fi\n previous="$arg"\n done\n if [[ " $* " == *" -- --list "* ]]; then printf "%s_case: test\\n" "$target"; fi\n}',
+ 'integration_test_targets() { printf "%s\\n" ' + JSON_RPC_TARGETS.join(" ") + "; }",
+ "run_build_only_reaper_test() { :; }",
+ "run_tinychannels_linked_fixture_tests() { :; }",
+ "run_raw_coverage_modules() { :; }",
+ "run_in_process_modules() { :; }",
+ body,
+ fullSuite,
+ "run_full_suite",
+ ].join("\n");
+ const result = spawnSync("bash", ["-c", script], { encoding: "utf8" });
+ assert.equal(result.status, 0, result.stdout + result.stderr);
+ const calls = readFileSync(log, "utf8").split("\n").filter(Boolean);
+ for (const target of JSON_RPC_TARGETS) {
+ assert.equal(
+ calls.filter((line) => line.includes(`--test ${target} -- --list`)).length,
+ 1,
+ `${target} should be enumerated once`,
+ );
+ assert.equal(
+ calls.filter((line) => line.includes(`--test ${target} ${target}_case --`)).length,
+ 1,
+ `${target} case should run once`,
+ );
+ }
+ } finally {
+ rmSync(root, { recursive: true, force: true });
+ }
+});
+
+test("an explicit JSON-RPC namespace target uses isolated enumeration", () => {
+ const root = mkdtempSync(join(tmpdir(), "product-target-routing-"));
+ try {
+ const log = join(root, "dispatch.log");
+ const script = [
+ "set -euo pipefail",
+ `RUN_LOG='${log}'`,
+ 'cargo_test() { printf "CARGO\\t%s\\n" "$*" >> "$RUN_LOG"; }',
+ 'run_json_rpc_e2e() { printf "JSON_RPC\\t[%s]\\n" "$*" >> "$RUN_LOG"; }',
+ "run_full_suite() { :; }",
+ "run_raw_coverage_modules() { :; }",
+ "run_in_process_modules() { :; }",
+ dispatch,
+ ].join("\n");
+ const result = spawnSync("bash", ["-c", script, "bash", "--test", "json_rpc_threads_e2e"], {
+ encoding: "utf8",
+ });
+ assert.equal(result.status, 0, result.stdout + result.stderr);
+ assert.deepEqual(readFileSync(log, "utf8").trim().split("\n"), [
+ "JSON_RPC\t[json_rpc_threads_e2e]",
+ ]);
+ } finally {
+ rmSync(root, { recursive: true, force: true });
+ }
+});
+
+test("the legacy JSON-RPC aggregate alias still selects every namespace", () => {
+ const root = mkdtempSync(join(tmpdir(), "product-alias-routing-"));
+ try {
+ const log = join(root, "dispatch.log");
+ const script = [
+ "set -euo pipefail",
+ `RUN_LOG='${log}'`,
+ 'cargo_test() { printf "CARGO\\t%s\\n" "$*" >> "$RUN_LOG"; }',
+ 'run_json_rpc_e2e() { printf "JSON_RPC\\t[%s]\\n" "$*" >> "$RUN_LOG"; }',
+ "run_full_suite() { :; }",
+ "run_raw_coverage_modules() { :; }",
+ "run_in_process_modules() { :; }",
+ dispatch,
+ ].join("\n");
+ const result = spawnSync("bash", ["-c", script, "bash", "--test", "json_rpc_e2e"], {
+ encoding: "utf8",
+ });
+ assert.equal(result.status, 0, result.stdout + result.stderr);
+ assert.deepEqual(readFileSync(log, "utf8").trim().split("\n"), ["JSON_RPC\t[]"]);
+ } finally {
+ rmSync(root, { recursive: true, force: true });
+ }
+});
+
test("released TinyHosts contract callers match the declared libtest module", () => {
const moduleSource = readFileSync(
new URL("../../crates/openhuman-core/src/hosting/mod.rs", import.meta.url),