UNPKG

@dydxfoundation/governance

Version:
82 lines (81 loc) 4.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const deploy_upgradeable_1 = require("../../src/migrations/helpers/deploy-upgradeable"); const types_1 = require("../../types"); const describe_contract_1 = require("../helpers/describe-contract"); const evm_1 = require("../helpers/evm"); let staker; let safetyModuleBeforeEpochZero; async function init(ctx) { [staker] = ctx.users; const distributionStart2 = await (0, evm_1.latestBlockTimestamp)() + 500; [safetyModuleBeforeEpochZero] = await (0, deploy_upgradeable_1.deployUpgradeable)(types_1.SafetyModuleV11__factory, ctx.deployer, [ ctx.dydxToken.address, ctx.dydxToken.address, ctx.rewardsTreasury.address, distributionStart2, ctx.config.SM_DISTRIBUTION_END, ], [ ctx.config.EPOCH_LENGTH, distributionStart2, ctx.config.BLACKOUT_WINDOW, ]); } (0, describe_contract_1.describeContract)('SafetyModuleV1 initializer', init, (ctx) => { it('Cannot deploy with distribution end before the distribution start', async () => { const pastTimestamp = await (0, evm_1.latestBlockTimestamp)() - 1; await (0, chai_1.expect)((0, deploy_upgradeable_1.deployUpgradeable)(types_1.SafetyModuleV11__factory, ctx.deployer, [ ctx.dydxToken.address, ctx.dydxToken.address, ctx.rewardsTreasury.address, ctx.config.SM_DISTRIBUTION_START, ctx.config.SM_DISTRIBUTION_START - 1, ], [ ctx.config.EPOCH_LENGTH, pastTimestamp, ctx.config.BLACKOUT_WINDOW, ])).to.be.reverted(); }); it('Cannot initialize with epoch zero in the past', async () => { const pastTimestamp = await (0, evm_1.latestBlockTimestamp)() - 1; // Note: Since this reverts within InitializableUpgradeabilityProxy, there is no reason string. await (0, chai_1.expect)((0, deploy_upgradeable_1.deployUpgradeable)(types_1.SafetyModuleV11__factory, ctx.deployer, [ ctx.dydxToken.address, ctx.dydxToken.address, ctx.rewardsTreasury.address, ctx.config.SM_DISTRIBUTION_START, ctx.config.SM_DISTRIBUTION_END, ], [ ctx.config.EPOCH_LENGTH, pastTimestamp, ctx.config.BLACKOUT_WINDOW, ])).to.be.reverted(); }); describe('Before epoch zero has started', () => { it('Total active current balance is zero', async () => { (0, chai_1.expect)(await safetyModuleBeforeEpochZero.getTotalActiveBalanceCurrentEpoch()).to.equal(0); }); it('Total active next balance is zero', async () => { (0, chai_1.expect)(await safetyModuleBeforeEpochZero.getTotalActiveBalanceNextEpoch()).to.equal(0); }); it('Total inactive current balance is zero', async () => { (0, chai_1.expect)(await safetyModuleBeforeEpochZero.getTotalInactiveBalanceCurrentEpoch()).to.equal(0); }); it('Total inactive next balance is zero', async () => { (0, chai_1.expect)(await safetyModuleBeforeEpochZero.getTotalInactiveBalanceNextEpoch()).to.equal(0); }); it('User active current balance is zero', async () => { (0, chai_1.expect)(await safetyModuleBeforeEpochZero.getActiveBalanceCurrentEpoch(staker.address)).to.equal(0); }); it('User active next balance is zero', async () => { (0, chai_1.expect)(await safetyModuleBeforeEpochZero.getActiveBalanceNextEpoch(staker.address)).to.equal(0); }); it('User inactive current balance is zero', async () => { (0, chai_1.expect)(await safetyModuleBeforeEpochZero.getInactiveBalanceCurrentEpoch(staker.address)).to.equal(0); }); it('User inactive next balance is zero', async () => { (0, chai_1.expect)(await safetyModuleBeforeEpochZero.getInactiveBalanceNextEpoch(staker.address)).to.equal(0); }); }); });