UNPKG

@bsv/wallet-toolbox

Version:

BRC100 conforming wallet, wallet storage and wallet signer components

39 lines 2.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const knex_1 = require("knex"); const ChaintracksFs_1 = require("../../util/ChaintracksFs"); const ChaintracksStorageKnex_1 = require("../ChaintracksStorageKnex"); const blockHeaderUtilities_1 = require("../../util/blockHeaderUtilities"); describe('ChaintracksStorageKnex tests', () => { jest.setTimeout(99999999); test('0', async () => { const chain = 'main'; const fs = ChaintracksFs_1.ChaintracksFs; const rootFolder = './src/services/chaintracker/chaintracks/__tests/data'; const localSqlite = { client: 'better-sqlite3', connection: { filename: fs.pathJoin(rootFolder, `${chain}Net_chaintracks.sqlite`) }, useNullAsDefault: true }; const knexInstance = (0, knex_1.knex)(localSqlite); const knexOptions = ChaintracksStorageKnex_1.ChaintracksStorageKnex.createStorageKnexOptions(chain); knexOptions.knex = knexInstance; const storage = new ChaintracksStorageKnex_1.ChaintracksStorageKnex(knexOptions); await storage.makeAvailable(); const bfs = await storage.bulkManager.getBulkFiles(); // Test assumes synchronization has occurred and bulk files are available. if ((bfs === null || bfs === void 0 ? void 0 : bfs.length) === 0) return; expect(bfs.length).toBeGreaterThan(7); const gh = await storage.getBulkFileData(bfs[0].fileId, 0, 80); const dgh = (0, blockHeaderUtilities_1.deserializeBaseBlockHeader)(gh); const rgh = (0, blockHeaderUtilities_1.genesisHeader)(chain); expect(dgh.merkleRoot).toEqual(rgh.merkleRoot); expect(dgh.bits).toEqual(rgh.bits); expect(dgh.nonce).toEqual(rgh.nonce); const header = await storage.findHeaderForHeight(101010); expect(header.hash).toEqual('000000000001af33247fff33aae7c31baee4148d5a189e7353bf13bcee618202'); await storage.shutdown(); }); }); //# sourceMappingURL=ChaintracksStorageKnex.test.js.map