"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const api_1 = require("@polkadot/api");
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const factory_1 = require("../../../../src/factory");
const chai_1 = require("../../../chai");
const config_1 = require("../../../config");
const helpers_1 = require("../../../utils/helpers");
const src_1 = require("../../../../src");
describe("systemAPI", () => {
    let api;
    let sudoAccount;
    let interBtcAPI;
    let keyring;
    before(() => __awaiter(void 0, void 0, void 0, function* () {
        api = yield factory_1.createSubstrateAPI(config_1.PARACHAIN_ENDPOINT);
        keyring = new api_1.Keyring({ type: "sr25519" });
        sudoAccount = keyring.addFromUri(config_1.SUDO_URI);
        interBtcAPI = new src_1.DefaultInterBtcApi(api, "regtest", sudoAccount, config_1.ESPLORA_BASE_PATH);
    }));
    after(() => __awaiter(void 0, void 0, void 0, function* () {
        api.disconnect();
    }));
    it("should getCurrentBlockNumber", () => __awaiter(void 0, void 0, void 0, function* () {
        const currentBlockNumber = yield interBtcAPI.system.getCurrentBlockNumber();
        chai_1.assert.isDefined(currentBlockNumber);
    }));
    it("should getStatusCode", () => __awaiter(void 0, void 0, void 0, function* () {
        const statusCode = yield interBtcAPI.system.getStatusCode();
        chai_1.assert.isDefined(statusCode);
    }));
    // TODO: Unskip once differences between rococo-local and standalone are fixed
    it.skip("should setCode", () => __awaiter(void 0, void 0, void 0, function* () {
        const code = fs.readFileSync(path.join(__dirname, "../../../mock/rococo_runtime.compact.wasm")).toString("hex");
        yield helpers_1.sudo(interBtcAPI, () => interBtcAPI.system.setCode(code));
    }));
});
//# sourceMappingURL=system.test.js.map