OZ Error: 'Governor: proposer votes below proposal threshold'

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.

:1234: 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}`);

});

:computer: Environment

Hardhat

Can you share what the console.log printed?

@JulissaDantes No worries. i solved it during the weekend. CHeers

Happy to hear that!, could you share the solution? in case someone else has this same issue in the future?

Here is my initialise() of governor contract:

function initialize(
    Membership membership,
    IVotesUpgradeable _token,
    TimelockControllerUpgradeable _timelock
) public initializer {
    __Governor_init("GovernorFIQ");
    __GovernorSettings_init(
        1, /* 1 block */
        91636, /* 2 week */
        20 /* 20 votes*/
    );
    __GovernorCountingSimple_init();
    __GovernorVotes_init(_token);
    __GovernorVotesQuorumFraction_init(4);
    __GovernorTimelockControl_init(_timelock);

    _membership = membership;
}

after generating from wizard, I didnt realise my initial proposal threshold was 20e18 which is a huge number for my governance-erc20 token. i amended it to just 20 votes to raise a proposal.

To provide some more context, the Wizard sets it as 20e18 because it assumes the contract has 18 decimals. You can configure that too!

image