Reconciliation uses 32-row SQLite slices
This commit is contained in:
+12
-7
@@ -171,18 +171,23 @@ test('market reconciliation keyset progress is bounded, durable and resumes afte
|
||||
try { return JSON.parse((conn.prepare('SELECT value FROM market_meta WHERE key=?').get('canonical_reconciliation_job') as { value: string }).value); }
|
||||
finally { conn.close(); }
|
||||
};
|
||||
assert.equal(progress().stage, 'orders'); assert.equal(progress().afterId, ids[127]);
|
||||
assert.equal(progress().stage, 'orders'); assert.equal(progress().afterId, ids[31]);
|
||||
assert.equal(f.market.hasReconciliationBacklog(), true);
|
||||
await assert.rejects(f.list(), /catching up/); // second 128-order batch; no new listing is admitted.
|
||||
assert.equal(progress().stage, 'orders'); assert.equal(progress().afterId, ids[255]);
|
||||
await assert.rejects(f.list(), /catching up/); // Second 32-order batch; no new listing is admitted.
|
||||
assert.equal(progress().stage, 'orders'); assert.equal(progress().afterId, ids[63]);
|
||||
// The ledger advances while this durable multi-batch job is in flight.
|
||||
f.events.push({ sequence: 2, type: 'connect', height: 2, hash: 'f'.repeat(64), previousHash: 'd'.repeat(64),
|
||||
transactionIds: [], eventHash: '2'.repeat(64) });
|
||||
f.market.browse(); // Tip/revision changed: rewind and bind the updated event page.
|
||||
assert.equal(progress().eventPage.cursor, 2);
|
||||
assert.equal(progress().afterId, ids[127]);
|
||||
f.market.browse(); // Second order batch of the refreshed scan.
|
||||
f.market.browse(); // Remaining four orders, then at most one listing page.
|
||||
assert.equal(progress().afterId, ids[31]);
|
||||
const tailStatus = () => {
|
||||
const conn = new DatabaseSync(join(f.dir, 'testnet', 'market.sqlite'));
|
||||
try { return JSON.parse((conn.prepare('SELECT data FROM orders WHERE id=?').get(ids[259]) as { data: string }).data).status; }
|
||||
finally { conn.close(); }
|
||||
};
|
||||
for (let i = 0; i < 12 && tailStatus() !== 'review'; i++) f.market.browse();
|
||||
assert.equal(tailStatus(), 'review'); // Disconnect reached the tail order before checkpoint advancement.
|
||||
assert.equal(f.market.diagnostics().canonicalEventCursor, 0);
|
||||
assert.equal(f.market.hasReconciliationBacklog(), true, 'new events appended during job must stay behind the work fence');
|
||||
const reviewDb = new DatabaseSync(join(f.dir, 'testnet', 'market.sqlite'));
|
||||
@@ -194,7 +199,7 @@ test('market reconciliation keyset progress is bounded, durable and resumes afte
|
||||
|
||||
// Simulate process death after committed batch progress, then resume using the SQLite job cursor.
|
||||
await f.restart(); assert.equal(f.market.diagnostics().eventBacklog, true);
|
||||
for (let i = 0; i < 12 && f.market.hasReconciliationBacklog(); i++) f.market.browse();
|
||||
for (let i = 0; i < 24 && f.market.hasReconciliationBacklog(); i++) f.market.browse();
|
||||
assert.equal(f.market.hasReconciliationBacklog(), false);
|
||||
const conn = new DatabaseSync(join(f.dir, 'testnet', 'market.sqlite'));
|
||||
try { assert.equal(conn.prepare('SELECT 1 FROM market_meta WHERE key=?').get('canonical_reconciliation_job'), undefined); }
|
||||
|
||||
Reference in New Issue
Block a user