(path, body)
| 27 | const saveReport = () => writeFile(join(OUT, `${proofPrefix}errors-e2e.json`), JSON.stringify(report, null, 2) + '\n'); |
| 28 | |
| 29 | async function json(path, body) { |
| 30 | const response = await fetch(ORIGIN + path, { method: body ? 'POST' : 'GET', ...(body ? { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) } : {}) }); |
| 31 | const text = await response.text(); |
| 32 | let payload; |
| 33 | try { payload = JSON.parse(text); } catch { payload = { raw: text }; } |
| 34 | report.directRequests.push({ at: new Date().toISOString(), method: body ? 'POST' : 'GET', path, status: response.status }); |
| 35 | if (!response.ok) throw new Error(`${path}: HTTP ${response.status}: ${text.slice(0, 300)}`); |
| 36 | return payload; |
| 37 | } |
| 38 | |
| 39 | async function rpc(name, args) { |
| 40 | const response = await json('/rpc', { jsonrpc: '2.0', id: ++rpcId, method: 'tools/call', params: { name, arguments: { ...args, format: 'json' } } }); |
no test coverage detected