Skip to content

Commit

Permalink
Merge pull request #96 from RootstockCollective/dao-850
Browse files Browse the repository at this point in the history
test: A delegates to B, B delegates to C, A withdraws
  • Loading branch information
jessgusclark authored Nov 19, 2024
2 parents 5a4a6fc + 7e681e6 commit e5da04f
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion test/Governor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,43 @@ describe('Governor Contact', () => {
await mine(2)

const balanceHolder2After = await stRIF.getVotes(holders[2])
console.log('balanceHolder2After', balanceHolder2After)
expect(balanceHolder2After).to.equal(balanceHolder1 + balanceHolder2 + balanceHolder3)
})

it('A delegates to B, B delegates to C, A withdraws', async () => {
const testedHolders = holders.slice(4, 7)

const tx = await stRIF.connect(testedHolders[0]).delegate(testedHolders[1])
await tx.wait()
expect(await stRIF.delegates(testedHolders[0])).to.equal(testedHolders[1])

const tx2 = await stRIF.connect(testedHolders[1]).delegate(testedHolders[2])
await tx2.wait()
expect(await stRIF.delegates(testedHolders[1])).to.equal(testedHolders[2])

const votingPowers = testedHolders.map(async holder => {
return await stRIF.getVotes(holder)
})

const balances = testedHolders.map(async holder => {
return await stRIF.balanceOf(holder)
})

// because delegated to B
expect(await votingPowers[0]).to.equal(0n)
// because received from A and delegated own votes to C
expect(await votingPowers[1]).to.equal(await balances[0])
// because received from B and has own votes
expect(await votingPowers[2]).to.equal((await balances[1]) + (await balances[2]))

const value = dispenseValue / 5n
const withdrawFrom1 = await stRIF.connect(testedHolders[0]).withdrawTo(testedHolders[0], value)
await withdrawFrom1.wait()

const newVotingPowerOf2 = await stRIF.getVotes(testedHolders[1])
expect(newVotingPowerOf2).to.equal((await balances[0]) - value)
})

it('should be possible to claim back votes', async () => {
const balance1 = await stRIF.balanceOf(holders[1])

Expand Down

0 comments on commit e5da04f

Please sign in to comment.