diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..764a556 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,16 @@ +name: Verify +on: [push, pull_request] +permissions: + contents: read +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22' + - run: npm ci + - run: npm test + - run: npm run docs:check diff --git a/README.md b/README.md index 1c1c9f9..74d2673 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,11 @@ scripts/ test runner, documentation generator, browser parity check reviews/ dated review records ``` -The modules are copies of the Wildroot browser's. `npm run parity` compares +The modules are copies of the Wildroot browser's. `npm run parity` fails if +the browser checkout is absent, so an unchecked run cannot look successful. It compares them with a browser checkout at `../browser` (or `$WILDROOT`). The browser source is not public, so without that checkout the command reports that -nothing was checked and exits successfully. +nothing was checked and exits with a nonzero status. ## Citing diff --git a/namespaces/ens/tests/web3-protocol.test.js b/namespaces/ens/tests/web3-protocol.test.js index 2fc9aaf..246a404 100644 --- a/namespaces/ens/tests/web3-protocol.test.js +++ b/namespaces/ens/tests/web3-protocol.test.js @@ -13,6 +13,8 @@ import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' +import { createServer } from 'node:http' +import { once } from 'node:events' import createHandler, { web3Response } from '../src/web3-protocol.js' import fetchToHandler from '../src/fetch-to-handler.js' @@ -40,10 +42,21 @@ test('the CORS headers a protocol handler needs are present', async () => { assert.equal(res.headers.get('Allow-CSP-From'), '*') }) -test('a failing chain call is an error response, not a throw', async () => { +test('a failing chain call is an error response, not a throw', { timeout: 10000 }, async (t) => { // The scheme must fail closed inside its own namespace: an unreachable RPC // is a status, never an exception escaping into the protocol layer. - const { handler } = await createHandler({ chainList: CHAIN_LIST }) + // A deterministic local RPC error avoids OS/firewall-dependent timeouts on + // an assumed closed port while still exercising the real client failure path. + const rpc = createServer((req, res) => { + req.resume() + res.setHeader('Content-Type', 'application/json') + res.end(JSON.stringify({ jsonrpc: '2.0', id: 1, error: { code: -32000, message: 'fixture failure' } })) + }) + rpc.listen(0, '127.0.0.1') + await once(rpc, 'listening') + t.after(() => new Promise((resolve) => { rpc.closeAllConnections(); rpc.close(resolve) })) + const chainList = { 1: { ...CHAIN_LIST[1], rpcUrls: [`http://127.0.0.1:${rpc.address().port}/`] } } + const { handler } = await createHandler({ chainList }) const res = await handler(new Request(CONTRACT)) assert.equal(res.status, 500) }) diff --git a/scripts/parity.mjs b/scripts/parity.mjs index c9369f3..55ee870 100644 --- a/scripts/parity.mjs +++ b/scripts/parity.mjs @@ -194,7 +194,7 @@ function walk (dir, out = []) { if (!existsSync(WILDROOT)) { console.error(`parity: browser tree not found at ${WILDROOT} (set WILDROOT); nothing checked`) - process.exit(sync ? 1 : 0) + process.exit(1) } let failures = 0