diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a6fae81..fb978b2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,11 +48,8 @@ network — nothing in the suite makes an RPC call. Code that talks to a server structural fake, as in `test/futility.test.ts`, which stands up an object shaped like `rpc.Server` and asserts on which calls it received. -Two things worth knowing before you add a test: +One thing worth knowing before you add a test: -- **`test/` is not type-checked.** `tsconfig.json` excludes it, so `npm run build` will not catch a - type error in a test file. This is a known gap with an open issue against it; until it closes, do - not assume a green build means your test compiles under `strict`. - **Relative imports need the `.js` extension**, including in tests. The package is `"type": "module"` with `moduleResolution: "NodeNext"`, so `../src/keeper/loop.js` is correct even though the file on disk is `loop.ts`. diff --git a/package.json b/package.json index ca3ea8c..3391c42 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "dist" ], "scripts": { - "build": "tsc -p tsconfig.json", + "build": "tsc -p tsconfig.json && tsc -p tsconfig.test.json", "lint": "eslint .", "format": "prettier --write .", "format:check": "prettier --check .", diff --git a/test/discover.test.ts b/test/discover.test.ts index 3e30a2a..c1f544e 100644 --- a/test/discover.test.ts +++ b/test/discover.test.ts @@ -86,7 +86,12 @@ describe("unwrapPage", () => { }); it("throws on an Err, naming the start offset", () => { - expect(() => unwrapPage(new contractSpec.Err("LimitTooLarge"), 50)).toThrow(/start=50/); + // The SDK types `Err` as wrapping an `ErrorMessage` ({ message }), not a + // bare string; `unwrapPage` only stringifies it, so the payload is not + // asserted on here. + expect(() => unwrapPage(new contractSpec.Err({ message: "LimitTooLarge" }), 50)).toThrow( + /start=50/, + ); }); it("throws when the payload is not a list", () => { diff --git a/test/ttl.test.ts b/test/ttl.test.ts index ef1c584..a189d06 100644 --- a/test/ttl.test.ts +++ b/test/ttl.test.ts @@ -51,7 +51,10 @@ describe("classify", () => { describe("buildReadings", () => { it("pairs each requested key with its entry", () => { - const keys = [instanceLedgerKey(CONTRACT), symbolKey("Balance")]; + const keys: [xdr.LedgerKey, xdr.LedgerKey] = [ + instanceLedgerKey(CONTRACT), + symbolKey("Balance"), + ]; const entries = [ { key: keys[0], val: {}, liveUntilLedgerSeq: 600_000 }, { key: keys[1], val: {}, liveUntilLedgerSeq: 150_000 }, @@ -68,7 +71,10 @@ describe("buildReadings", () => { }); it("marks a key the RPC omitted as archived", () => { - const keys = [instanceLedgerKey(CONTRACT), symbolKey("Milestones")]; + const keys: [xdr.LedgerKey, xdr.LedgerKey] = [ + instanceLedgerKey(CONTRACT), + symbolKey("Milestones"), + ]; const entries = [{ key: keys[0], val: {}, liveUntilLedgerSeq: 600_000 }]; const readings = buildReadings(keys, entries, 100_000, 100_000); diff --git a/tsconfig.json b/tsconfig.json index 27eca11..170bd5d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,5 +18,5 @@ "forceConsistentCasingInFileNames": true }, "include": ["src/**/*.ts"], - "exclude": ["node_modules", "dist", "test"] + "exclude": ["node_modules", "dist"] } diff --git a/tsconfig.test.json b/tsconfig.test.json new file mode 100644 index 0000000..1931d3d --- /dev/null +++ b/tsconfig.test.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": true, + "rootDir": "." + }, + "include": ["test/**/*.ts", "src/**/*.ts"], + "exclude": ["node_modules", "dist"] +}