"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const src_1 = require("../../src");
describe("UTXO utils tests ", function () {
    let mccClient;
    //    const BtcMccConnection = {
    //       url: process.env.BTC_URL || "",
    //       username: process.env.BTC_USERNAME || "",
    //       password: process.env.BTC_PASSWORD || "",
    //    } as UtxoMccCreate;
    const BtcMccConnection = {
        url: "",
        username: "",
        password: "",
    };
    before(async function () {
        mccClient = new src_1.MCC.BTC(BtcMccConnection);
    });
    it("should return empty array if hash is empty", async () => {
        const res = await mccClient.recursive_block_hash("", 1);
        (0, chai_1.expect)(res.length).to.be.equal(0);
    });
    it("should return empty array if hash is empty 2", async () => {
        const res = await mccClient.recursive_block_tip(new src_1.BtcBlockTip({ hash: "", height: 0, branchlen: 0, status: "active" }), 1);
        (0, chai_1.expect)(res.length).to.be.equal(0);
    });
    it("should return false if no data", () => {
        const res = (0, src_1.utxo_check_expect_empty)({});
        (0, chai_1.expect)(res).to.be.false;
    });
    it("should return true if error code is -5", () => {
        const res = (0, src_1.utxo_check_expect_empty)({ error: { code: -5 } });
        (0, chai_1.expect)(res).to.be.true;
    });
    it("should return false if error code is not -5", () => {
        const res = (0, src_1.utxo_check_expect_empty)({ error: { code: -4 } });
        (0, chai_1.expect)(res).to.be.false;
    });
    it("should return false if error does not contain 'code'", () => {
        const res = (0, src_1.utxo_check_expect_empty)({ error: { message: "no data" } });
        (0, chai_1.expect)(res).to.be.false;
    });
    it("should return false if no data", () => {
        const res = (0, src_1.utxo_check_expect_block_out_of_range)({});
        (0, chai_1.expect)(res).to.be.false;
    });
    it("should return false if no data", () => {
        const res = (0, src_1.utxo_check_expect_block_out_of_range)(null);
        (0, chai_1.expect)(res).to.be.false;
    });
    it("should return true if error code is -8", () => {
        const res = (0, src_1.utxo_check_expect_block_out_of_range)({ error: { code: -8 } });
        (0, chai_1.expect)(res).to.be.true;
    });
    it("should return true if error code is -1", () => {
        const res = (0, src_1.utxo_check_expect_block_out_of_range)({ error: { code: -1 } });
        (0, chai_1.expect)(res).to.be.true;
    });
    it("should return false if error code is not -8 or -1", () => {
        const res = (0, src_1.utxo_check_expect_block_out_of_range)({ error: { code: -2 } });
        (0, chai_1.expect)(res).to.be.false;
    });
    it("should return false if error does not contain 'code'", () => {
        const res = (0, src_1.utxo_check_expect_block_out_of_range)({ error: { message: "no data" } });
        (0, chai_1.expect)(res).to.be.false;
    });
    it("should return error if 'error' exists", () => {
        const fn = () => {
            return (0, src_1.utxo_ensure_data)({ error: {} });
        };
        (0, chai_1.expect)(fn).to.throw(Error);
    });
    it("should silently run", () => {
        (0, src_1.utxo_ensure_data)(null);
    });
});
//# sourceMappingURL=utxoutils.test.js.map