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
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 15 additions & 2 deletions namespaces/ens/tests/web3-protocol.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion scripts/parity.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading