Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 .",
Expand Down
7 changes: 6 additions & 1 deletion test/discover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
10 changes: 8 additions & 2 deletions test/ttl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "dist", "test"]
"exclude": ["node_modules", "dist"]
}
9 changes: 9 additions & 0 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": true,
"rootDir": "."
},
"include": ["test/**/*.ts", "src/**/*.ts"],
"exclude": ["node_modules", "dist"]
}
Loading