UNPKG

@bsv/wallet-toolbox

Version:

BRC100 conforming wallet, wallet storage and wallet signer components

40 lines 1.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const utilityHelpers_1 = require("../../../../../utility/utilityHelpers"); const LiveIngestorWhatsOnChainPoll_1 = require("../LiveIngestorWhatsOnChainPoll"); describe('LiveIngestorWhatsOnChainPoll tests', () => { jest.setTimeout(99999999); let logSpy, capturedLogs = []; beforeAll(async () => { logSpy = jest.spyOn(console, 'log').mockImplementation((...args) => { capturedLogs.push(args.map(String).join(' ')); }); }); test('0 listen for first new header', async () => { const liveHeaders = []; const options = LiveIngestorWhatsOnChainPoll_1.LiveIngestorWhatsOnChainPoll.createLiveIngestorWhatsOnChainOptions('main'); const ingestor = new LiveIngestorWhatsOnChainPoll_1.LiveIngestorWhatsOnChainPoll(options); const p = ingestor.startListening(liveHeaders); let log = ''; let count = 0; for (;;) { const h = liveHeaders.shift(); if (h) { log += `${h.height} ${h.hash}\n`; count++; } else { if (log) { console.log(`LiveIngestorWhatsOnChain received ${count} headers:\n${log}`); log = ''; break; } //if (count >= 11) break await (0, utilityHelpers_1.wait)(100); } } ingestor.stopListening(); await p; }); }); //# sourceMappingURL=LiveIngestorWhatsOnChainPoll.test.js.map