Skip to content

Commit f51eecf

Browse files
test: votingPower of holder fixed at proposal creation when casting votes
1 parent 0aef6ec commit f51eecf

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

test/Governor.test.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,46 @@ describe('RootDAO Contact', () => {
200200
})
201201

202202
describe('Voting', () => {
203+
it('voting power of holders should be locked at the proposal creation stage', async () => {
204+
const votesAtTheProposalSnapshot = await governor.getVotes(holders[0].address, proposalSnapshot)
205+
const dispenseValue = await rif.tokenFaucet.dispenseValue()
206+
207+
const { abstainVotes: beforeAbstainVotes } = await governor.proposalVotes(proposalId)
208+
expect(beforeAbstainVotes).to.equal(0n)
209+
210+
const dispenseTx = await rif.tokenFaucet.connect(holders[0]).dispense(holders[0].address)
211+
await dispenseTx.wait()
212+
const currentBalance = await rif.rifToken.balanceOf(holders[0].address)
213+
expect(currentBalance).to.equal(dispenseValue)
214+
215+
const approvalTx = await rif.rifToken
216+
.connect(holders[0])
217+
.approve(await stRIF.getAddress(), currentBalance)
218+
await approvalTx.wait()
219+
const depositTx = await stRIF.connect(holders[0]).depositAndDelegate(holders[0], currentBalance)
220+
await depositTx.wait()
221+
await mine(2)
222+
223+
const currentVotes = await governor.getVotes(
224+
holders[0].address,
225+
BigInt((await ethers.provider.getBlockNumber()) - 1),
226+
)
227+
expect(currentVotes).to.equal(dispenseValue * 2n)
228+
229+
// cast Abstain Vote
230+
const tx = await governor.connect(holders[0]).castVote(proposalId, 2)
231+
await tx.wait()
232+
233+
const { abstainVotes } = await governor.proposalVotes(proposalId)
234+
console.log('abstainVotes', abstainVotes)
235+
236+
expect(abstainVotes).to.be.equal(votesAtTheProposalSnapshot)
237+
})
238+
203239
it('holders should be able to cast vote', async () => {
204240
// cast FOR vote, system: 0 = Against, 1 = For, 2 = Abstain
205241
const tx = await governor.connect(holders[1]).castVote(proposalId, 1)
206-
tx.wait()
242+
await tx.wait()
207243
const hasVoted = await governor.hasVoted(proposalId, holders[1])
208244
expect(hasVoted).to.be.true
209245
const { forVotes } = await governor.proposalVotes(proposalId)

0 commit comments

Comments
 (0)