|
| 1 | +import { describe, expect, test } from "bun:test"; |
| 2 | + |
| 3 | +import { resolvedComposeEnv, serviceNameList } from "./artifacts"; |
| 4 | +import { stubState } from "./test-helpers"; |
| 5 | + |
| 6 | +describe("resolvedComposeEnv", () => { |
| 7 | + test("includes version env and COMPOSE_IGNORE_ORPHANS", () => { |
| 8 | + const env = resolvedComposeEnv(stubState()); |
| 9 | + expect(env.GATEWAY_VERSION).toBe("v0.11.0"); |
| 10 | + expect(env.CORE_VERSION).toBe("v0.13.0"); |
| 11 | + expect(env.COMPOSE_IGNORE_ORPHANS).toBe("true"); |
| 12 | + }); |
| 13 | + |
| 14 | + test("defaults FHEVM_CARGO_PROFILE to release", () => { |
| 15 | + const env = resolvedComposeEnv(stubState()); |
| 16 | + expect(env.FHEVM_CARGO_PROFILE).toBe("release"); |
| 17 | + }); |
| 18 | + |
| 19 | + test("uses override profile when present", () => { |
| 20 | + const env = resolvedComposeEnv(stubState({ overrides: [{ group: "coprocessor", profile: "debug" }] })); |
| 21 | + expect(env.FHEVM_CARGO_PROFILE).toBe("debug"); |
| 22 | + }); |
| 23 | + |
| 24 | + test("uses first override profile found", () => { |
| 25 | + const env = resolvedComposeEnv( |
| 26 | + stubState({ |
| 27 | + overrides: [ |
| 28 | + { group: "coprocessor", profile: "custom" }, |
| 29 | + { group: "test-suite", profile: "other" }, |
| 30 | + ], |
| 31 | + }), |
| 32 | + ); |
| 33 | + expect(env.FHEVM_CARGO_PROFILE).toBe("custom"); |
| 34 | + }); |
| 35 | + |
| 36 | + test("falls back to release when override has no profile", () => { |
| 37 | + const env = resolvedComposeEnv(stubState({ overrides: [{ group: "coprocessor" }] })); |
| 38 | + expect(env.FHEVM_CARGO_PROFILE).toBe("release"); |
| 39 | + }); |
| 40 | +}); |
| 41 | + |
| 42 | +describe("serviceNameList", () => { |
| 43 | + const state = stubState(); |
| 44 | + |
| 45 | + test("returns empty for non-coprocessor components", () => { |
| 46 | + expect(serviceNameList(state, "relayer")).toEqual([]); |
| 47 | + expect(serviceNameList(state, "database")).toEqual([]); |
| 48 | + expect(serviceNameList(state, "minio")).toEqual([]); |
| 49 | + }); |
| 50 | + |
| 51 | + test("returns single-instance service names for count=1", () => { |
| 52 | + const names = serviceNameList(state, "coprocessor"); |
| 53 | + expect(names).toEqual([ |
| 54 | + "coprocessor-db-migration", |
| 55 | + "coprocessor-host-listener", |
| 56 | + "coprocessor-host-listener-poller", |
| 57 | + "coprocessor-gw-listener", |
| 58 | + "coprocessor-tfhe-worker", |
| 59 | + "coprocessor-zkproof-worker", |
| 60 | + "coprocessor-sns-worker", |
| 61 | + "coprocessor-transaction-sender", |
| 62 | + ]); |
| 63 | + }); |
| 64 | + |
| 65 | + test("returns multi-instance service names for count=2", () => { |
| 66 | + const names = serviceNameList(stubState({ count: 2 }), "coprocessor"); |
| 67 | + expect(names).toContain("coprocessor-db-migration"); |
| 68 | + expect(names).toContain("coprocessor-host-listener"); |
| 69 | + expect(names).toContain("coprocessor1-db-migration"); |
| 70 | + expect(names).toContain("coprocessor1-host-listener"); |
| 71 | + expect(names).toContain("coprocessor1-tfhe-worker"); |
| 72 | + expect(names.length).toBe(16); |
| 73 | + }); |
| 74 | + |
| 75 | + test("returns multi-instance service names for count=3", () => { |
| 76 | + const names = serviceNameList(stubState({ count: 3 }), "coprocessor"); |
| 77 | + expect(names).toContain("coprocessor-db-migration"); |
| 78 | + expect(names).toContain("coprocessor1-db-migration"); |
| 79 | + expect(names).toContain("coprocessor2-db-migration"); |
| 80 | + expect(names.length).toBe(24); |
| 81 | + }); |
| 82 | +}); |
0 commit comments