Skip to content

Commit

Permalink
test: vote weighting initial testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kupermind committed Apr 9, 2024
1 parent c802cb9 commit 9e6c8ee
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 170 deletions.
12 changes: 6 additions & 6 deletions test/Deployment.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ describe("Deployment", function () {
const fs = require("fs");
let gnosisSafeL2;
let gnosisSafeProxyFactory;
const _1kOLABalance = "1000" + "0".repeat(18);
const _2kOLABalance = "2000" + "0".repeat(18);
const _3kOLABalance = "3000" + "0".repeat(18);
const _4kOLABalance = "4000" + "0".repeat(18);
const _1kOLASBalance = "1000" + "0".repeat(18);
const _2kOLASBalance = "2000" + "0".repeat(18);
const _3kOLASBalance = "3000" + "0".repeat(18);
const _4kOLASBalance = "4000" + "0".repeat(18);
const oneYear = 365 * 86400;
let veOLASSigners;
let buOLASSigners;
Expand Down Expand Up @@ -78,12 +78,12 @@ describe("Deployment", function () {
let claimableBalancesJSON = {
"veOLAS": {
"addresses": [veOLASSigners[0].address, veOLASSigners[1].address, veOLASSigners[2].address],
"amounts": [_1kOLABalance, _2kOLABalance, _3kOLABalance],
"amounts": [_1kOLASBalance, _2kOLASBalance, _3kOLASBalance],
"lockTimes": [oneYear, 2 * oneYear, 3 * oneYear]
},
"buOLAS": {
"addresses": [buOLASSigners[0].address, buOLASSigners[1].address, buOLASSigners[2].address, buOLASSigners[3].address],
"amounts": [_1kOLABalance, _2kOLABalance, _3kOLABalance, _4kOLABalance],
"amounts": [_1kOLASBalance, _2kOLASBalance, _3kOLASBalance, _4kOLASBalance],
"numSteps": [1, 2, 3, 4]
}
};
Expand Down
42 changes: 21 additions & 21 deletions test/GovernanceOLAS.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ describe("Governance OLAS", function () {
let ve;
let signers;
const oneWeek = 7 * 86400;
const oneOLABalance = ethers.utils.parseEther("1");
const twoOLABalance = ethers.utils.parseEther("2");
const fiveOLABalance = ethers.utils.parseEther("5");
const tenOLABalance = ethers.utils.parseEther("10");
const oneOLASBalance = ethers.utils.parseEther("1");
const twoOLASBalance = ethers.utils.parseEther("2");
const fiveOLASBalance = ethers.utils.parseEther("5");
const tenOLASBalance = ethers.utils.parseEther("10");
const AddressZero = "0x" + "0".repeat(40);
const bytes32Zero = "0x" + "0".repeat(64);
const safeThreshold = 7;
const nonce = 0;
const minDelay = 1; // blocks
const initialVotingDelay = 0; // blocks
const initialVotingPeriod = 1; // blocks
const initialProposalThreshold = fiveOLABalance; // required voting power
const initialProposalThreshold = fiveOLASBalance; // required voting power
const quorum = 1; // quorum factor
const proposalDescription = "Proposal 0";
beforeEach(async function () {
Expand All @@ -44,7 +44,7 @@ describe("Governance OLAS", function () {
signers = await ethers.getSigners();

// Mint 10 OLAS worth of OLAS tokens by default
await token.mint(signers[0].address, tenOLABalance);
await token.mint(signers[0].address, tenOLASBalance);
const balance = await token.balanceOf(signers[0].address);
expect(ethers.utils.formatEther(balance) == 10).to.be.true;
});
Expand Down Expand Up @@ -106,14 +106,14 @@ describe("Governance OLAS", function () {
it("Changes the ownership of a governance contract and a timelock", async function () {
const deployer = signers[0];
// Approve signers[0] for 10 OLAS by voting ve
await token.approve(ve.address, tenOLABalance);
await token.approve(ve.address, tenOLASBalance);
// Define 4 years for the lock duration in Voting Escrow.
// This will result in voting power being almost exactly as OLAS amount locked:
// voting power = amount * t_left_before_unlock / t_max
const lockDuration = 4 * 365 * 86400;

// Lock 10 OLAS, which is enough to cover the 5 OLAS of initial proposal threshold voting power
await ve.createLock(tenOLABalance, lockDuration);
await ve.createLock(tenOLASBalance, lockDuration);

// Deploy first timelock
const executors = [deployer.address];
Expand Down Expand Up @@ -198,7 +198,7 @@ describe("Governance OLAS", function () {
expect(ethers.utils.formatEther(balance) == 10).to.be.true;

// Approve signers[0] for 10 OLA by voting ve
await token.connect(deployer).approve(ve.address, tenOLABalance);
await token.connect(deployer).approve(ve.address, tenOLASBalance);

// Define 4 years for the lock duration.
// This will result in voting power being almost exactly as OLA amount locked:
Expand All @@ -207,9 +207,9 @@ describe("Governance OLAS", function () {
const lockDuration = fourYears;

// Lock 5 OLA, which is lower than the initial proposal threshold by a bit
await ve.connect(deployer).createLock(fiveOLABalance, lockDuration);
await ve.connect(deployer).createLock(fiveOLASBalance, lockDuration);
// Add a bit more
await ve.connect(deployer).increaseAmount(oneOLABalance);
await ve.connect(deployer).increaseAmount(oneOLASBalance);

// Deploy Timelock
const executors = [];
Expand Down Expand Up @@ -267,23 +267,23 @@ describe("Governance OLAS", function () {

// Transfer initial balances to all the gelegators: 1 OLAS to each
for (let i = 1; i <= numDelegators; i++) {
await token.transfer(signers[i].address, oneOLABalance);
await token.transfer(signers[i].address, oneOLASBalance);
const balance = await token.balanceOf(signers[i].address);
expect(ethers.utils.formatEther(balance) == 1).to.be.true;
}

// Approve signers[1]-signers[10] for 1 OLAS by voting ve
for (let i = 1; i <= numDelegators; i++) {
await token.connect(signers[i]).approve(ve.address, oneOLABalance);
await token.connect(signers[i]).approve(ve.address, oneOLASBalance);
}

// Define 1 week for the lock duration
const lockDuration = oneWeek;

// Deposit tokens as a voting power to a chosen delegatee
await ve.connect(signers[1]).createLock(oneOLABalance, lockDuration);
await ve.connect(signers[1]).createLock(oneOLASBalance, lockDuration);
for (let i = 2; i <= numDelegators; i++) {
await ve.connect(signers[i]).depositFor(delegatee, oneOLABalance);
await ve.connect(signers[i]).depositFor(delegatee, oneOLASBalance);
}

// Given 1 OLAS worth of voting power from every address, the cumulative voting power must be 10
Expand All @@ -301,7 +301,7 @@ describe("Governance OLAS", function () {
expect(ethers.utils.formatEther(balance) == 10).to.be.true;

// Approve signers[0] for 10 OLAS by voting ve
await token.connect(signers[0]).approve(ve.address, tenOLABalance);
await token.connect(signers[0]).approve(ve.address, tenOLASBalance);

// Define 4 years for the lock duration.
// This will result in voting power being almost exactly as OLAS amount locked:
Expand All @@ -310,7 +310,7 @@ describe("Governance OLAS", function () {
const lockDuration = fourYears;

// Lock 5 OLAS, which is lower than the initial proposal threshold by a bit
await ve.connect(signers[0]).createLock(fiveOLABalance, lockDuration);
await ve.connect(signers[0]).createLock(fiveOLASBalance, lockDuration);

// Deploy simple version of a timelock
const executors = [];
Expand All @@ -333,7 +333,7 @@ describe("Governance OLAS", function () {
).to.be.revertedWith("Governor: proposer votes below proposal threshold");

// Adding voting power, and the proposal must go through, 4 + 2 of OLAS in voting power is almost 6 > 5 required
await ve.connect(signers[0]).increaseAmount(twoOLABalance);
await ve.connect(signers[0]).increaseAmount(twoOLASBalance);
await governor.connect(signers[0])["propose(address[],uint256[],bytes[],string)"]([AddressZero], [0],
["0x"], proposalDescription);
});
Expand All @@ -344,7 +344,7 @@ describe("Governance OLAS", function () {
expect(ethers.utils.formatEther(balance) == 10).to.be.true;

// Approve signers[0] for 10 OLA by voting ve
await token.connect(deployer).approve(ve.address, tenOLABalance);
await token.connect(deployer).approve(ve.address, tenOLASBalance);

// Define 4 years for the lock duration.
// This will result in voting power being almost exactly as OLA amount locked:
Expand All @@ -353,9 +353,9 @@ describe("Governance OLAS", function () {
const lockDuration = fourYears;

// Lock 5 OLA, which is lower than the initial proposal threshold by a bit
await ve.connect(deployer).createLock(fiveOLABalance, lockDuration);
await ve.connect(deployer).createLock(fiveOLASBalance, lockDuration);
// Add a bit more
await ve.connect(deployer).increaseAmount(oneOLABalance);
await ve.connect(deployer).increaseAmount(oneOLASBalance);

// Deploy Timelock
const proposers = [deployer.address];
Expand Down
42 changes: 21 additions & 21 deletions test/GovernanceTwoOLAS.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ describe("Governance OLAS on wveOLAS", function () {
let wve;
let signers;
const oneWeek = 7 * 86400;
const oneOLABalance = ethers.utils.parseEther("1");
const twoOLABalance = ethers.utils.parseEther("2");
const fiveOLABalance = ethers.utils.parseEther("5");
const tenOLABalance = ethers.utils.parseEther("10");
const oneOLASBalance = ethers.utils.parseEther("1");
const twoOLASBalance = ethers.utils.parseEther("2");
const fiveOLASBalance = ethers.utils.parseEther("5");
const tenOLASBalance = ethers.utils.parseEther("10");
const AddressZero = "0x" + "0".repeat(40);
const bytes32Zero = "0x" + "0".repeat(64);
const safeThreshold = 7;
const nonce = 0;
const minDelay = 1; // blocks
const initialVotingDelay = 0; // blocks
const initialVotingPeriod = 1; // blocks
const initialProposalThreshold = fiveOLABalance; // required voting power
const initialProposalThreshold = fiveOLASBalance; // required voting power
const quorum = 1; // quorum factor
const proposalDescription = "Proposal 0";
beforeEach(async function () {
Expand All @@ -49,7 +49,7 @@ describe("Governance OLAS on wveOLAS", function () {
signers = await ethers.getSigners();

// Mint 10 OLAS worth of OLAS tokens by default
await token.mint(signers[0].address, tenOLABalance);
await token.mint(signers[0].address, tenOLASBalance);
const balance = await token.balanceOf(signers[0].address);
expect(ethers.utils.formatEther(balance) == 10).to.be.true;
});
Expand Down Expand Up @@ -111,14 +111,14 @@ describe("Governance OLAS on wveOLAS", function () {
it("Changes the ownership of a governance contract and a timelock", async function () {
const deployer = signers[0];
// Approve signers[0] for 10 OLAS by voting ve
await token.approve(ve.address, tenOLABalance);
await token.approve(ve.address, tenOLASBalance);
// Define 4 years for the lock duration in Voting Escrow.
// This will result in voting power being almost exactly as OLAS amount locked:
// voting power = amount * t_left_before_unlock / t_max
const lockDuration = 4 * 365 * 86400;

// Lock 10 OLAS, which is enough to cover the 5 OLAS of initial proposal threshold voting power
await ve.createLock(tenOLABalance, lockDuration);
await ve.createLock(tenOLASBalance, lockDuration);

// Deploy first timelock
const executors = [deployer.address];
Expand Down Expand Up @@ -203,7 +203,7 @@ describe("Governance OLAS on wveOLAS", function () {
expect(ethers.utils.formatEther(balance) == 10).to.be.true;

// Approve signers[0] for 10 OLA by voting ve
await token.connect(deployer).approve(ve.address, tenOLABalance);
await token.connect(deployer).approve(ve.address, tenOLASBalance);

// Define 4 years for the lock duration.
// This will result in voting power being almost exactly as OLA amount locked:
Expand All @@ -212,9 +212,9 @@ describe("Governance OLAS on wveOLAS", function () {
const lockDuration = fourYears;

// Lock 5 OLA, which is lower than the initial proposal threshold by a bit
await ve.connect(deployer).createLock(fiveOLABalance, lockDuration);
await ve.connect(deployer).createLock(fiveOLASBalance, lockDuration);
// Add a bit more
await ve.connect(deployer).increaseAmount(oneOLABalance);
await ve.connect(deployer).increaseAmount(oneOLASBalance);

// Deploy Timelock
const executors = [];
Expand Down Expand Up @@ -272,23 +272,23 @@ describe("Governance OLAS on wveOLAS", function () {

// Transfer initial balances to all the gelegators: 1 OLAS to each
for (let i = 1; i <= numDelegators; i++) {
await token.transfer(signers[i].address, oneOLABalance);
await token.transfer(signers[i].address, oneOLASBalance);
const balance = await token.balanceOf(signers[i].address);
expect(ethers.utils.formatEther(balance) == 1).to.be.true;
}

// Approve signers[1]-signers[10] for 1 OLAS by voting ve
for (let i = 1; i <= numDelegators; i++) {
await token.connect(signers[i]).approve(ve.address, oneOLABalance);
await token.connect(signers[i]).approve(ve.address, oneOLASBalance);
}

// Define 1 week for the lock duration
const lockDuration = oneWeek;

// Deposit tokens as a voting power to a chosen delegatee
await ve.connect(signers[1]).createLock(oneOLABalance, lockDuration);
await ve.connect(signers[1]).createLock(oneOLASBalance, lockDuration);
for (let i = 2; i <= numDelegators; i++) {
await ve.connect(signers[i]).depositFor(delegatee, oneOLABalance);
await ve.connect(signers[i]).depositFor(delegatee, oneOLASBalance);
}

// Given 1 OLAS worth of voting power from every address, the cumulative voting power must be 10
Expand All @@ -306,7 +306,7 @@ describe("Governance OLAS on wveOLAS", function () {
expect(ethers.utils.formatEther(balance) == 10).to.be.true;

// Approve signers[0] for 10 OLAS by voting ve
await token.connect(signers[0]).approve(ve.address, tenOLABalance);
await token.connect(signers[0]).approve(ve.address, tenOLASBalance);

// Define 4 years for the lock duration.
// This will result in voting power being almost exactly as OLAS amount locked:
Expand All @@ -315,7 +315,7 @@ describe("Governance OLAS on wveOLAS", function () {
const lockDuration = fourYears;

// Lock 5 OLAS, which is lower than the initial proposal threshold by a bit
await ve.connect(signers[0]).createLock(fiveOLABalance, lockDuration);
await ve.connect(signers[0]).createLock(fiveOLASBalance, lockDuration);

// Deploy simple version of a timelock
const executors = [];
Expand All @@ -338,7 +338,7 @@ describe("Governance OLAS on wveOLAS", function () {
).to.be.revertedWith("Governor: proposer votes below proposal threshold");

// Adding voting power, and the proposal must go through, 4 + 2 of OLAS in voting power is almost 6 > 5 required
await ve.connect(signers[0]).increaseAmount(twoOLABalance);
await ve.connect(signers[0]).increaseAmount(twoOLASBalance);
await governor.connect(signers[0])["propose(address[],uint256[],bytes[],string)"]([AddressZero], [0],
["0x"], proposalDescription);
});
Expand All @@ -349,7 +349,7 @@ describe("Governance OLAS on wveOLAS", function () {
expect(ethers.utils.formatEther(balance) == 10).to.be.true;

// Approve signers[0] for 10 OLA by voting ve
await token.connect(deployer).approve(ve.address, tenOLABalance);
await token.connect(deployer).approve(ve.address, tenOLASBalance);

// Define 4 years for the lock duration.
// This will result in voting power being almost exactly as OLA amount locked:
Expand All @@ -358,9 +358,9 @@ describe("Governance OLAS on wveOLAS", function () {
const lockDuration = fourYears;

// Lock 5 OLA, which is lower than the initial proposal threshold by a bit
await ve.connect(deployer).createLock(fiveOLABalance, lockDuration);
await ve.connect(deployer).createLock(fiveOLASBalance, lockDuration);
// Add a bit more
await ve.connect(deployer).increaseAmount(oneOLABalance);
await ve.connect(deployer).increaseAmount(oneOLASBalance);

// Deploy Timelock
const proposers = [deployer.address];
Expand Down
Loading

0 comments on commit 9e6c8ee

Please sign in to comment.