Consensus calibration

This commit is contained in:
2026-10-20 09:26:12 -04:00
parent 4080114085
commit 9d61c177b7
11 changed files with 259 additions and 1 deletions
+14
View File
@@ -138,6 +138,20 @@ test('testnet genesis is empty, manifest-bound, isolated and defensively copied'
assert.throws(() => ledger.inventory(0, 0));
});
test('timestamp attack boundaries reject at median and beyond future limit before proof work',async t=>{
const {ledger,engine}=await fixture(t);
const now=GENESIS_TIME+CONSENSUS.targetSeconds*20;
t.mock.method(Date,'now',()=>now*1000);
const candidate=await mine(ledger.template(alice.owner,alice.publicKey,articleFor([]),statsSnapshot()));
const calls=engine.calls;
await assert.rejects(ledger.submit({...candidate,createdAt:GENESIS_TIME}),/timestamp/);
await assert.rejects(ledger.submit({...candidate,createdAt:now+CONSENSUS.maxFutureSeconds+1}),/timestamp/);
assert.equal(engine.calls,calls);assert.equal(ledger.size,0);
// Full validation reaches commitment checks for the exact allowed future edge, not timestamp rejection.
await assert.rejects(ledger.submit({...candidate,createdAt:now+CONSENSUS.maxFutureSeconds}),/block ID/);
assert.equal(engine.calls,calls);
});
test('DAG retains equal-work branches, serializes duplicates and selects strictly greater cumulative work', async t => {
const { ledger, dir } = await fixture(t);
t.mock.method(Date, 'now', () => (GENESIS_TIME + CONSENSUS.targetSeconds * 20) * 1000);