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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/whitepaper.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 27 additions & 5 deletions oracle/site-app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }]));
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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');
});
31 changes: 31 additions & 0 deletions oracle/site-pages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
});
2 changes: 1 addition & 1 deletion site/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,6 @@ <h2>Activity</h2>



<script src="assets/app.js?v=sm1"></script>
<script src="assets/app.js?v=timeout1"></script>
</body>
</html>
32 changes: 24 additions & 8 deletions site/assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,31 @@ function decodeString(hex) {
}

// ---- chain io ----
// Every RPC read goes through here. A node that accepts the connection and never answers would leave
// the page waiting with no message, so a request that has not finished in 20 s, body included, is
// aborted and fails like any other read. The epochs page uses the same limit (epochs.js).
async function rpcPost(body) {
const ctl = new AbortController();
const t = setTimeout(() => ctl.abort(), 20000);
try {
const res = await fetch(RPC, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
signal: ctl.signal,
});
return await res.json();
} catch (e) {
if (e.name === "AbortError") throw new Error("the RPC did not answer within 20 seconds");
throw e;
} finally {
clearTimeout(t);
}
}

async function rpcRead(to, data) {
const body = { jsonrpc: "2.0", id: 1, method: "eth_call", params: [{ to, data }, "latest"] };
const res = await fetch(RPC, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
const j = await res.json();
const j = await rpcPost(body);
if (j.error) throw new Error(j.error.message);
return j.result;
}
Expand All @@ -150,12 +171,7 @@ async function rpcBatch(calls) {
jsonrpc: "2.0", id: i, method: "eth_call",
params: [{ to: c.to, data: c.data }, "latest"],
}));
const res = await fetch(RPC, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
const arr = await res.json();
const arr = await rpcPost(body);
if (!Array.isArray(arr)) throw new Error(arr?.error?.message ?? "batch call failed");
const byId = new Map(arr.map(r => [r.id, r]));
return calls.map((c, i) => {
Expand Down
26 changes: 20 additions & 6 deletions site/assets/testnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,26 @@
params: c.params || [{ to: c.to, data: c.data }, "latest"],
};
});
var res = await fetch(RPC, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
var arr = await res.json();
// A node that accepts the connection and never answers would leave the card reading the
// chain with no message, so a request that has not finished in 20 s, body included, is
// aborted and reported like any other failed read. The epochs page uses the same limit.
var ctl = new AbortController();
var timer = setTimeout(function () { ctl.abort(); }, 20000);
var arr;
try {
var res = await fetch(RPC, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
signal: ctl.signal,
});
arr = await res.json();
} catch (e) {
if (e.name === "AbortError") throw new Error("the RPC did not answer within 20 seconds");
throw e;
} finally {
clearTimeout(timer);
}
if (!Array.isArray(arr)) throw new Error((arr && arr.error && arr.error.message) || "RPC batch failed");
var byId = {};
arr.forEach(function (r) { byId[r.id] = r; });
Expand Down
2 changes: 1 addition & 1 deletion site/testnet.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,6 @@ <h1>Five steps to a <span class="gradient">live agent.</span></h1>
</footer>

<script src="assets/did.js?v=testnet1"></script>
<script src="assets/testnet.js?v=sm1"></script>
<script src="assets/testnet.js?v=timeout1"></script>
</body>
</html>
Loading