@@ -200,10 +200,46 @@ describe('RootDAO Contact', () => {
200
200
} )
201
201
202
202
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
+
203
239
it ( 'holders should be able to cast vote' , async ( ) => {
204
240
// cast FOR vote, system: 0 = Against, 1 = For, 2 = Abstain
205
241
const tx = await governor . connect ( holders [ 1 ] ) . castVote ( proposalId , 1 )
206
- tx . wait ( )
242
+ await tx . wait ( )
207
243
const hasVoted = await governor . hasVoted ( proposalId , holders [ 1 ] )
208
244
expect ( hasVoted ) . to . be . true
209
245
const { forVotes } = await governor . proposalVotes ( proposalId )
0 commit comments