"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const cli_progress_1 = require("cli-progress");
const index_1 = require("../../src/index");
const testUtils_1 = require("../testUtils");
const BtcMccConnection = {
    url: process.env.BTC_URL || "",
    username: process.env.BTC_USERNAME || "",
    password: process.env.BTC_PASSWORD || "",
    apiTokenKey: process.env.FLARE_API_PORTAL_KEY || "",
};
describe(`BTC transactions in full block vs transactions from getTransaction (${(0, testUtils_1.getTestFile)(__filename)})`, () => {
    const blockNumbersToCheck = [(0, testUtils_1.getRandomNumber)(100000, 787000)];
    for (const blockNumber of blockNumbersToCheck) {
        describe(`Testing transactions in block ${blockNumber} (transitions from full block vs )`, () => {
            let client;
            let block;
            let fullBlock;
            before(async () => {
                client = new index_1.MCC.BTC(BtcMccConnection);
                block = await client.getBlock(blockNumber);
                fullBlock = (await client.getFullBlock(blockNumber));
                index_1.traceManager.displayStateOnException = false;
                index_1.traceManager.displayRuntimeTrace = false;
            });
            it("Block and Full block transaction count should be equal", () => {
                (0, chai_1.expect)(block.transactionCount).to.eq(fullBlock.transactionCount);
            });
            it("Block and Full block transaction ids should be equal", () => {
                (0, chai_1.expect)(block.transactionIds.sort()).to.deep.eq(fullBlock.transactionIds.sort());
            });
            it("Iterating over transactions", async () => {
                const transactions = fullBlock.transactions;
                (0, chai_1.expect)(transactions.length).to.be.greaterThan(0);
                const b1 = new cli_progress_1.SingleBar({
                    format: `|| {bar} || Checking block || {percentage}% || {value}/{total} Transactions`,
                    barCompleteChar: "\u2588",
                    barIncompleteChar: "\u2591",
                    hideCursor: true,
                });
                b1.start(Math.min(transactions.length, 500), 0);
                let i = 0;
                for (const transaction of transactions) {
                    i++;
                    if (i == 500) {
                        break;
                    }
                    b1.increment();
                    const transObject = await client.getTransaction(transaction.txid);
                    for (const getter of testUtils_1.GETTERS_BASIC) {
                        (0, testUtils_1.throwOrReturnSameGetter)(transaction, transObject, getter);
                    }
                    for (const getter of testUtils_1.GETTERS_LISTS) {
                        (0, testUtils_1.throwOrReturnSameGetterList)(transaction, transObject, getter);
                    }
                    //Find why the error is logged
                    for (const getter of testUtils_1.GETTERS_BN) {
                        (0, testUtils_1.throwOrReturnSameGetterBN)(transaction, transObject, getter);
                    }
                    for (const getter of testUtils_1.GETTERS_AMOUNTS) {
                        (0, testUtils_1.throwOrReturnSameGetterAmounts)(transaction, transObject, getter);
                    }
                }
                b1.stop();
            });
        });
    }
});
//# sourceMappingURL=transactionsVsTransactionsInBlock.test.js.map