// TEST 4 — `rev` is deterministic, monotonic, and restart-stable (never wall-clock).
// If rev were Date.now()-derived, two co-owners (or a restart) would diverge and fork the chain.
import test from 'brittle'
import { nextRev } from '../lib/rev.js'
test('rev is deterministic + monotonic + restart-stable', (t) => {
const build = () => { let r = nextRev(null); const chain = [r]; for (let i = 0; i < 5; i++) { r = nextRev(r); chain.push(r) } return chain }
const chain = build()
for (let i = 1; i < chain.length; i++) t.ok(chain[i] > chain[i - 1], `rev ${i} > rev ${i - 1} (monotonic, TID-sortable)`)
// "Restart": recompute the whole chain from scratch → byte-identical (no wall-clock).
t.alike(build(), chain, 'recomputed chain identical — deterministic, restart-stable')
// Continue from ANY restart point using only prevRev.
t.is(nextRev(chain[2]), chain[3], 'nextRev(prev) reproduces the same next rev from any restart point')
t.is(chain[0].length, 13, 'rev is a 13-char atproto TID')
})