x402 payment probe: the mock node serves only recorded code (a missing field is a JSON-RPC error, never '0x'); EOA recordings carry code 0x explicitly; control 14 states the empty code explicitly

This commit is contained in:
Aere Network committed 2026-10-12 00:04:04 +03:00
1 parent 54028e07f4
commit 092ea48988
3 files changed
+6 -2

No files matched your search

+4 -2
View File
@@ -31,7 +31,9 @@ async function rpcDin(rec) {
if (q.method === 'eth_chainId') result = rec.chainId;
else if (q.method === 'eth_getTransactionReceipt') result = rec.receipts[String(q.params[0]).toLowerCase()] || null;
else if (q.method === 'eth_getLogs') result = rec.transfersOut;
else if (q.method === 'eth_getCode') result = rec.code || '0x';
// 2026-10-11 (D-FAZA2-04b, R2): macheta serveste numai ce e INREGISTRAT; o inregistrare fara `code` nu devine "fara cod",
// ci o eroare JSON-RPC, pe care verificatorul trebuie sa o trateze ca necunoscut (inregistrarile EOA poarta explicit "0x")
else if (q.method === 'eth_getCode') { if (rec.code === undefined) { res.writeHead(200, { 'content-type': 'application/json' }); res.end(JSON.stringify({ jsonrpc: '2.0', id: q.id, error: { code: -32000, message: 'World state unavailable' } })); return; } result = rec.code; }
res.writeHead(200, { 'content-type': 'application/json' }); res.end(JSON.stringify({ jsonrpc: '2.0', id: q.id, result }));
}); });
await new Promise((r) => srv.listen(0, '127.0.0.1', r));
@@ -74,7 +76,7 @@ try {
cer(pica(await judeca(dovada2, r12), e2), '12. CONTROL: un singur octet schimbat in codul de pe lant -> INVALID');
const d13 = copie(dovada2); d13.walletContract.agentSigner = '0x' + '22'.repeat(20);
cer(pica(await judeca(d13, inreg2), e2), '13. CONTROL: dosarul numeste alt semnatar al agentului decat cel din codul de pe lant -> INVALID');
const r14 = copie(inreg2); delete r14.code;
const r14 = copie(inreg2); r14.code = '0x'; // 2026-10-11: controlul spune EXPLICIT "cont fara cod"; o inregistrare fara camp e tacere, nu absenta (R2)
cer(pica(await judeca(dovada2, r14), e2), '14. CONTROL: la adresa portofelului nu e niciun cod (un cont cu o cheie), dar dosarul spune 2-din-2 -> INVALID');
} catch (e) { cer(false, `proba s-a oprit: ${String(e.message || e).slice(0, 160)}`); }
console.log(`\nverifica-plati: ${ok}/${ok + rau} ${rau ? 'CU ESECURI' : 'cum trebuia'}`);