More scalable data storage
This commit is contained in:
+11
-2
@@ -7,6 +7,7 @@ import { tmpdir } from 'node:os';
|
||||
import { delimiter, join, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { generateKeyPairSync, sign } from 'node:crypto';
|
||||
import { DatabaseSync } from 'node:sqlite';
|
||||
import { setTimeout as delay } from 'node:timers/promises';
|
||||
import { RandomX } from '../server/testnet/randomx.ts';
|
||||
import { address, CHAIN_ID, GENESIS_HASH, MAX_TARGET, miningBlob, mintId, sha256,
|
||||
@@ -171,7 +172,15 @@ test('native RandomX HTTP: three blocks, mined transfer, peer gossip/sync and du
|
||||
assert.deepEqual(await json(base, '/api/blocks', 201, block), { accepted: true, reorg: false });
|
||||
assert.deepEqual(await json(base, '/api/blocks', 200, block), { accepted: false, reorg: false });
|
||||
}
|
||||
const persisted = (dir: string) => readFile(join(dir, 'testnet', 'ledger.json'), 'utf8');
|
||||
const persisted = (dir: string) => {
|
||||
const db = new DatabaseSync(join(dir, 'testnet', 'ledger.sqlite'));
|
||||
try {
|
||||
return JSON.stringify({
|
||||
blocks: db.prepare('SELECT hash, previous_hash, block_json FROM blocks ORDER BY sequence').all(),
|
||||
pending: db.prepare('SELECT position, id, transaction_json FROM pending_transfers ORDER BY position').all(),
|
||||
});
|
||||
} finally { db.close(); }
|
||||
};
|
||||
|
||||
try {
|
||||
engine = new RandomX({ binary }); // Always the actual reference RandomX engine, never a test double.
|
||||
@@ -209,7 +218,7 @@ test('native RandomX HTTP: three blocks, mined transfer, peer gossip/sync and du
|
||||
for (const path of ['/api/missing', '/p2p/missing', `/api/nfts/${'0'.repeat(64)}`]) {
|
||||
await (await request(first.base, path, 404)).text();
|
||||
}
|
||||
for (const offset of ['-1', '1.5', '10001', 'nope']) {
|
||||
for (const offset of ['-1', '1.5', '9007199254740992', 'nope']) {
|
||||
await (await request(first.base, `/p2p/blocks?offset=${offset}`, 400)).text();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user