All checks were successful
check / check (push) Successful in 18s
build.js records which emitted bundles contain src/shared/constants.js, and constants.js carries a marker constant-folded from DEBUG itself. script/verify-build cross-checks the two and fails on every way of not knowing, so deleting the __BUILD_DEBUG__ define now breaks the build instead of shipping a live debug branch.
50 lines
1.7 KiB
JavaScript
50 lines
1.7 KiB
JavaScript
const {
|
|
DEBUG,
|
|
BUILD_DEBUG_MARKER,
|
|
ETHEREUM_MAINNET_CHAIN_ID,
|
|
DEFAULT_RPC_URL,
|
|
BIP44_ETH_PATH,
|
|
ERC20_ABI,
|
|
} = require("../src/shared/constants");
|
|
|
|
describe("constants", () => {
|
|
test("exports expected chain ID", () => {
|
|
expect(ETHEREUM_MAINNET_CHAIN_ID).toBe("0x1");
|
|
});
|
|
|
|
test("exports a default RPC URL", () => {
|
|
expect(typeof DEFAULT_RPC_URL).toBe("string");
|
|
expect(DEFAULT_RPC_URL.startsWith("https://")).toBe(true);
|
|
});
|
|
|
|
test("exports BIP-44 Ethereum derivation path", () => {
|
|
expect(BIP44_ETH_PATH).toBe("m/44'/60'/0'/0");
|
|
});
|
|
|
|
// This does not replace script/verify-build, which is the only thing that
|
|
// can see the compiled DEBUG state of a real bundle. It pins the source
|
|
// invariant that the marker tracks DEBUG, so the two cannot be edited
|
|
// apart and leave verify-build asserting something that is no longer the
|
|
// flag the code branches on.
|
|
test("build debug marker is derived from DEBUG", () => {
|
|
expect(BUILD_DEBUG_MARKER).toBe(
|
|
DEBUG ? "autistmask-build-debug=on" : "autistmask-build-debug=off",
|
|
);
|
|
});
|
|
|
|
// Outside a bundle there is no __BUILD_DEBUG__ define, and the fallback
|
|
// must be the safe one.
|
|
test("DEBUG is off when loaded outside a bundle", () => {
|
|
expect(DEBUG).toBe(false);
|
|
expect(BUILD_DEBUG_MARKER).toBe("autistmask-build-debug=off");
|
|
});
|
|
|
|
test("exports ERC-20 ABI with expected functions", () => {
|
|
expect(Array.isArray(ERC20_ABI)).toBe(true);
|
|
expect(ERC20_ABI.length).toBeGreaterThan(0);
|
|
const joined = ERC20_ABI.join(" ");
|
|
expect(joined).toContain("balanceOf");
|
|
expect(joined).toContain("transfer");
|
|
});
|
|
});
|