"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../../utils/utils");
const utils_hre_1 = require("../../../utils/utils.hre");
const SpokePool_Fixture_1 = require("./fixtures/SpokePool.Fixture");
const constants_1 = require("./constants");
let spokePool, erc20;
let owner;
describe("SpokePool Admin Functions", async function () {
    beforeEach(async function () {
        [owner] = await utils_1.ethers.getSigners();
        ({ spokePool, erc20 } = await (0, SpokePool_Fixture_1.spokePoolFixture)());
    });
    it("Can set initial deposit ID", async function () {
        const spokePool = await utils_hre_1.hre.upgrades.deployProxy(await (0, utils_1.getContractFactory)("MockSpokePool", owner), [1, owner.address, owner.address], { kind: "uups", unsafeAllow: ["delegatecall"], constructorArgs: [owner.address] });
        (0, utils_1.expect)(await spokePool.numberOfDeposits()).to.equal(1);
    });
    it("Enable token path", async function () {
        await (0, utils_1.expect)(spokePool.connect(owner).setEnableRoute(erc20.address, constants_1.destinationChainId, true))
            .to.emit(spokePool, "EnabledDepositRoute")
            .withArgs(erc20.address, constants_1.destinationChainId, true);
        (0, utils_1.expect)(await spokePool.enabledDepositRoutes(erc20.address, constants_1.destinationChainId)).to.equal(true);
    });
    it("Pause deposits", async function () {
        (0, utils_1.expect)(await spokePool.pausedDeposits()).to.equal(false);
        await (0, utils_1.expect)(spokePool.connect(owner).pauseDeposits(true)).to.emit(spokePool, "PausedDeposits").withArgs(true);
        (0, utils_1.expect)(await spokePool.pausedDeposits()).to.equal(true);
        await (0, utils_1.expect)(spokePool.connect(owner).pauseDeposits(false)).to.emit(spokePool, "PausedDeposits").withArgs(false);
        (0, utils_1.expect)(await spokePool.pausedDeposits()).to.equal(false);
    });
    it("Pause fills", async function () {
        (0, utils_1.expect)(await spokePool.pausedFills()).to.equal(false);
        await (0, utils_1.expect)(spokePool.connect(owner).pauseFills(true)).to.emit(spokePool, "PausedFills").withArgs(true);
        (0, utils_1.expect)(await spokePool.pausedFills()).to.equal(true);
        await (0, utils_1.expect)(spokePool.connect(owner).pauseFills(false)).to.emit(spokePool, "PausedFills").withArgs(false);
        (0, utils_1.expect)(await spokePool.pausedFills()).to.equal(false);
    });
    it("Delete rootBundle", async function () {
        await spokePool.connect(owner).relayRootBundle(constants_1.mockRelayerRefundRoot, constants_1.mockSlowRelayRoot);
        (0, utils_1.expect)(await spokePool.rootBundles(0)).has.property("slowRelayRoot", constants_1.mockSlowRelayRoot);
        (0, utils_1.expect)(await spokePool.rootBundles(0)).has.property("relayerRefundRoot", constants_1.mockRelayerRefundRoot);
        await (0, utils_1.expect)(spokePool.connect(owner).emergencyDeleteRootBundle(0))
            .to.emit(spokePool, "EmergencyDeleteRootBundle")
            .withArgs(0);
        (0, utils_1.expect)(await spokePool.rootBundles(0)).has.property("slowRelayRoot", utils_1.ethers.utils.hexZeroPad("0x0", 32));
        (0, utils_1.expect)(await spokePool.rootBundles(0)).has.property("relayerRefundRoot", utils_1.ethers.utils.hexZeroPad("0x0", 32));
    });
});
