UNPKG

@vechain/vebetterdao-contracts

Version:

Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.

80 lines (79 loc) 4.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const ethers_1 = require("ethers"); const mocha_1 = require("mocha"); const helpers_1 = require("../helpers"); const fixture_test_1 = require("./fixture.test"); (0, mocha_1.describe)("Governance - Proposer requirement - @shard4d", function () { let governor; let vot3; let b3tr; let minterAccount; let proposer; let owner; let galaxyMember; let emissions; (0, mocha_1.beforeEach)(async function () { const fixture = await (0, fixture_test_1.setupGovernanceFixtureWithEmissions)(); governor = fixture.governor; vot3 = fixture.vot3; b3tr = fixture.b3tr; minterAccount = fixture.minterAccount; proposer = fixture.proposer; owner = fixture.owner; galaxyMember = fixture.galaxyMember; emissions = fixture.emissions; // Setup proposer for all tests await emissions.connect(minterAccount).start(); await (0, fixture_test_1.setupProposer)(proposer, b3tr, vot3, minterAccount); }); (0, mocha_1.describe)("Proposer requirement", function () { (0, mocha_1.it)("Should correctly set the GM for the standard governance proposal", async function () { await governor.connect(owner).setRequiredGMLevelByProposalType(0, 1); // 0 = standard proposal with earth required const requiredGMLevel = await governor.getRequiredGMLevelByProposalType(0); (0, chai_1.expect)(requiredGMLevel).to.equal(1); }); (0, mocha_1.it)("Should correctly set the GM for the grant proposal", async function () { await governor.connect(owner).setRequiredGMLevelByProposalType(1, 1); // 1 = grant proposal with earth required const requiredGMLevel = await governor.getRequiredGMLevelByProposalType(1); (0, chai_1.expect)(requiredGMLevel).to.equal(1); }); (0, mocha_1.it)("Should not create a proposal (0 or 1) if the proposer does not have the correct GM", async function () { // set max GM level to 2 await galaxyMember.connect(owner).setMaxLevel(2); await governor.connect(owner).setRequiredGMLevelByProposalType(0, 2); // 0 = standard proposal with earth required const requiredGMLevel = await governor.getRequiredGMLevelByProposalType(0); (0, chai_1.expect)(requiredGMLevel).to.equal(2); await (0, helpers_1.getVot3Tokens)(proposer, "1000"); // grant approval to the governor contract await vot3.connect(proposer).approve(await governor.getAddress(), ethers_1.ethers.parseEther("1000")); // get the roundId const roundId = await (0, helpers_1.getRoundId)(); // GM level of the proposer = 1 (earth) const tokenId = await galaxyMember.getSelectedTokenId(proposer.address); const gmLevel = await galaxyMember.levelOf(tokenId); (0, chai_1.expect)(gmLevel).to.equal(1); await (0, chai_1.expect)(governor.connect(proposer).propose([], [], [], "", roundId, 0)).to.be.revertedWithCustomError(governor, "GovernorInvalidProposer"); }); (0, mocha_1.it)("Should not set the required GM level above the max level", async function () { const maxGMWeight = await galaxyMember.MAX_LEVEL(); await (0, chai_1.expect)(governor.connect(owner).setRequiredGMLevelByProposalType(0, Number(maxGMWeight) + 1)).to.be.revertedWithCustomError(governor, "GMLevelAboveMaxLevel"); }); (0, mocha_1.it)("Should not set the required GM level if the proposal type is invalid", async function () { await (0, chai_1.expect)(governor.connect(owner).setRequiredGMLevelByProposalType(2, 1)).to.be.reverted; }); (0, mocha_1.it)("Should not get the required GM level if the proposal type is invalid", async function () { await (0, chai_1.expect)(governor.getRequiredGMLevelByProposalType(2)).to.be.reverted; }); (0, mocha_1.it)("Should emit the RequiredGMLevelSet event when the required GM level is set", async function () { const tx = await governor.connect(owner).setRequiredGMLevelByProposalType(0, 1); await (0, chai_1.expect)(tx).to.emit(governor, "RequiredGMLevelSet").withArgs(0, 0, 1); }); }); (0, mocha_1.describe)("Permissions", function () { (0, mocha_1.it)("Should not be able set the required GM level if not admin", async function () { await (0, chai_1.expect)(governor.connect(minterAccount).setRequiredGMLevelByProposalType(0, 1)).to.be.revertedWithCustomError(governor, "GovernorOnlyExecutor"); }); }); });