Setup my Governor contract with a threshold of 20 votes, in order to create a proposal.
In my unit test, i minted and transferred 999 tokens to another address, addr1. I consoled-out and confirmed the votes of addr1 is 999.
When the governor executes the propose(),
Error: VM Exception while processing transaction: reverted with reason string 'Governor: proposer votes below proposal threshold'
I'm not sure how i get addr1 to have enough votes over the threshold, even after delegation.
Code to reproduce
it("should delegate votes to addr1", async () => {
const votesToBeDelegated = 999;
await gov.mint(owner.address, votesToBeDelegated);
const tx = await gov.connect(owner).delegate(addr1.address);
await tx.wait(1);
const votesAddr1 = await gov.getVotes(addr1.address);
const numCheckpoints = await gov.numCheckpoints(addr1.address);
console.log(`votesAddr1: ${votesAddr1} numCheckpoints: ${numCheckpoints}`);
expect(votesAddr1).to.equal(votesToBeDelegated);
expect(numCheckpoints).to.equal(1);
});
it("should make a proposal", async () => {
const encodedFunctionCall = fiqToken.interface.encodeFunctionData("mint", [
addr3.address,
999,
]);
const threshold = await governor.proposalThreshold();
const votesGovernor = await gov.getVotes(governor.address);
const voteAddr1 = await gov.getVotes(addr1.address);
const voteOwner = await gov.getVotes(owner.address);
console.log(`threshold: ${threshold / Math.pow(10, 18)}`);
console.log(`votesGovernor: ${votesGovernor}`);
console.log(`voteAddr1: ${voteAddr1}`);
console.log(`voteOwner: ${voteOwner}`);
const proposeTx = await governor
.connect(addr1)
.propose(
[fiqToken.address],
[0],
[encodedFunctionCall],
"Testing proposal"
);
const proposeReceipt = await proposeTx.wait(1);
const proposalId = proposeReceipt.events[0].args.proposalId;
let proposalState = await governor.state(proposalId);
console.log(`Current Proposal State: ${proposalState}`);
});
Environment
Hardhat