diff --git a/README.md b/README.md index ad8ba47..918167e 100644 --- a/README.md +++ b/README.md @@ -601,7 +601,7 @@ Everything below runs offline, with no deployed contracts, except three fork sui | Suite | Count | Command | |---|---|---| | Contracts: unit, fuzz, E2E, upgrade, deploy-script, handover and 22 invariants | 799 | `forge test` | -| Oracle | 1542 | `cd oracle && node --test` | +| Oracle | 1544 | `cd oracle && node --test` | | SDK | 392 | `cd packages/sdk && npx vitest run` | Counts are individual tests, so each of the 22 invariants counts once. The contracts were counted on 15 November 2026, the SDK on 15 November and the oracle on 15 November. Without a fork URL, 787 of the contract tests run and 12 skip. Run after `npm run build`, 383 of the SDK's 392 pass and 9 skip: the 8 integration tests, which need a live deployment, and one check that runs only in CI. Without a build, the 9 built-package tests skip too. Vitest strips types without checking them, so `npm run typecheck` in `packages/sdk` checks the tests against the SDK's types as well as the sources. [`scripts/mutation`](scripts/mutation/README.md) holds the harnesses that measure whether these tests would catch a deliberate break in the contracts or deploy scripts. diff --git a/docs/whitepaper.md b/docs/whitepaper.md index 53bf049..a5c3ee3 100644 --- a/docs/whitepaper.md +++ b/docs/whitepaper.md @@ -635,7 +635,7 @@ apply to a fresh deployment, not to the testnet. **Test coverage**, as of 15 November 2026: 799 contract tests across 36 Foundry test files including fuzz and invariant tests (the two slash drill suites fork Arc testnet themselves, and -the twelve in `SplitAuthorityFork` skip without `--fork-url`), 1542 oracle tests and 392 in the SDK (9 skip +the twelve in `SplitAuthorityFork` skip without `--fork-url`), 1544 oracle tests and 392 in the SDK (9 skip outside CI and without a live deployment; every test that runs passes). CI runs Foundry, the oracle and SDK suites, and Slither static analysis on every push, plus a documentation check that fails when the site states something the contracts do not. diff --git a/oracle/site-app.test.js b/oracle/site-app.test.js index 5ca7211..e55c3de 100644 --- a/oracle/site-app.test.js +++ b/oracle/site-app.test.js @@ -43,9 +43,10 @@ function element(id) { /** * The page, loaded. `agents` maps an address to its chain state; `hold(did)` may return a promise the - * RPC waits on before it answers a lookup of that agent, or rejects with. + * RPC waits on before it answers a lookup of that agent, or rejects with. `rpc` replaces the stub RPC's + * fetch. Every timer the page sets fires at once, and `waits` records the delay it asked for. */ -function load({ agents = {}, hold = () => null } = {}) { +function load({ agents = {}, hold = () => null, rpc = null } = {}) { const els = new Map(); const $ = (id) => { if (!els.has(id)) els.set(id, element(id)); return els.get(id); }; const byDid = new Map(Object.entries(agents).map(([addr, s]) => [didOf(addr), { addr, ...s }])); @@ -84,19 +85,27 @@ function load({ agents = {}, hold = () => null } = {}) { } return { json: async () => one(body) }; }; + const waits = []; const ctx = vm.createContext({ document: { getElementById: $, createElement: () => element(null), querySelector: () => null, querySelectorAll: () => [] }, window: { addEventListener() {}, dispatchEvent() {} }, Event: class { constructor(type) { this.type = type; } }, SigvaraDid: Did, - fetch, - setTimeout: (fn) => setImmediate(fn), + fetch: rpc ?? fetch, + setTimeout: (fn, ms) => { waits.push(ms); return setImmediate(fn); }, + clearTimeout: clearImmediate, + AbortController, console, }); vm.runInContext(SOURCE, ctx, { filename: 'app.js' }); - return { ctx, $, batches, get: (name) => vm.runInContext(name, ctx) }; + return { ctx, $, batches, waits, get: (name) => vm.runInContext(name, ctx) }; } +// A node that accepts the connection and never answers: the request ends only if the page aborts it. +const neverAnswers = (_url, init) => new Promise((_, reject) => { + init.signal?.addEventListener('abort', () => reject(new DOMException('This operation was aborted', 'AbortError'))); +}); + /** An EIP-1193 wallet. `chain` can be changed under the page, as a user switching networks does. */ function wallet({ chain = ARC, account = OPERATOR, switchError = null, addSwitches = true } = {}) { const p = { @@ -233,3 +242,16 @@ test('a Suspended agent below the minimum is not called suspended by its operato assert.match(status, /bond it back to the minimum and reactivate it/); assert.match(page.$('stakeNote').innerHTML, /then reactivate it/); }); + +test('a read the RPC never answers fails after 20 seconds with a message, rather than leaving the page waiting', async () => { + const page = load({ rpc: neverAnswers }); + await idle(); + assert.equal(page.$('feeNow').textContent, 'unavailable', 'the token reads at load are still waiting'); + assert.match(page.$('log').innerHTML, /RPC read failed: the RPC did not answer within 20 seconds/); + + page.$('agentAddr').value = B; + page.ctx.lookup(); // not awaited: a lookup with no limit never settles + await idle(); + assert.match(page.$('log').innerHTML, /lookup failed: the RPC did not answer within 20 seconds/); + assert.deepEqual(page.waits, [20000, 20000], 'one 20 s limit on each request'); +}); diff --git a/oracle/site-pages.test.js b/oracle/site-pages.test.js index ea6fdf6..9f9e3f4 100644 --- a/oracle/site-pages.test.js +++ b/oracle/site-pages.test.js @@ -85,3 +85,34 @@ test('the agents page reads the chain only for the agents it shows, 50 rows at a assert.match(html, /Rows 51 to 100 of 130\./); assert.deepEqual([...new Set(asked.slice(300))], Array.from({ length: 40 }, (_, i) => word(i + 61)), 'only the rows not read before'); }); + +test('the testnet page reports a read the RPC never answers after 20 seconds, rather than waiting for good', async () => { + const source = fs.readFileSync(path.join(__dirname, '..', 'site', 'assets', 'testnet.js'), 'utf8'); + const els = new Map(); + const $ = (id) => { + if (!els.has(id)) els.set(id, { textContent: '', value: '', href: '', setAttribute() {}, addEventListener() {} }); + return els.get(id); + }; + let ready = null; + const waits = []; + const ctx = vm.createContext({ + window: { SigvaraDid: did }, + document: { getElementById: $, querySelector: () => null, addEventListener: (type, fn) => { if (type === 'DOMContentLoaded') ready = fn; } }, + // An address in the query string starts a check when the page loads. + URLSearchParams, + location: { search: '?a=0x00000000000000000000000000000000000000a1' }, + AbortController, + // A node that accepts the connection and never answers: the request ends only if the page aborts it. + fetch: (_url, init) => new Promise((_, reject) => { + init.signal?.addEventListener('abort', () => reject(new DOMException('This operation was aborted', 'AbortError'))); + }), + // The page's timer fires at once, and the test checks the delay it asked for. + setTimeout: (fn, ms) => { waits.push(ms); return setImmediate(fn); }, + clearTimeout: clearImmediate, + }); + vm.runInContext(source, ctx); + ready(); + for (let i = 0; i < 20; i++) await new Promise(setImmediate); + assert.equal($('cardDid').textContent, 'read failed: the RPC did not answer within 20 seconds'); + assert.deepEqual(waits, [20000]); +}); diff --git a/site/app.html b/site/app.html index 5568364..a29a48d 100644 --- a/site/app.html +++ b/site/app.html @@ -140,6 +140,6 @@