@@ -326,10 +326,43 @@ describe('Governor Contact', () => {
326
326
await mine ( 2 )
327
327
328
328
const balanceHolder2After = await stRIF . getVotes ( holders [ 2 ] )
329
- console . log ( 'balanceHolder2After' , balanceHolder2After )
330
329
expect ( balanceHolder2After ) . to . equal ( balanceHolder1 + balanceHolder2 + balanceHolder3 )
331
330
} )
332
331
332
+ it ( 'A delegates to B, B delegates to C, A withdraws' , async ( ) => {
333
+ const testedHolders = holders . slice ( 4 , 7 )
334
+
335
+ const tx = await stRIF . connect ( testedHolders [ 0 ] ) . delegate ( testedHolders [ 1 ] )
336
+ await tx . wait ( )
337
+ expect ( await stRIF . delegates ( testedHolders [ 0 ] ) ) . to . equal ( testedHolders [ 1 ] )
338
+
339
+ const tx2 = await stRIF . connect ( testedHolders [ 1 ] ) . delegate ( testedHolders [ 2 ] )
340
+ await tx2 . wait ( )
341
+ expect ( await stRIF . delegates ( testedHolders [ 1 ] ) ) . to . equal ( testedHolders [ 2 ] )
342
+
343
+ const votingPowers = testedHolders . map ( async holder => {
344
+ return await stRIF . getVotes ( holder )
345
+ } )
346
+
347
+ const balances = testedHolders . map ( async holder => {
348
+ return await stRIF . balanceOf ( holder )
349
+ } )
350
+
351
+ // because delegated to B
352
+ expect ( await votingPowers [ 0 ] ) . to . equal ( 0n )
353
+ // because received from A and delegated own votes to C
354
+ expect ( await votingPowers [ 1 ] ) . to . equal ( await balances [ 0 ] )
355
+ // because received from B and has own votes
356
+ expect ( await votingPowers [ 2 ] ) . to . equal ( ( await balances [ 1 ] ) + ( await balances [ 2 ] ) )
357
+
358
+ const value = dispenseValue / 5n
359
+ const withdrawFrom1 = await stRIF . connect ( testedHolders [ 0 ] ) . withdrawTo ( testedHolders [ 0 ] , value )
360
+ await withdrawFrom1 . wait ( )
361
+
362
+ const newVotingPowerOf2 = await stRIF . getVotes ( testedHolders [ 1 ] )
363
+ expect ( newVotingPowerOf2 ) . to . equal ( ( await balances [ 0 ] ) - value )
364
+ } )
365
+
333
366
it ( 'should be possible to claim back votes' , async ( ) => {
334
367
const balance1 = await stRIF . balanceOf ( holders [ 1 ] )
335
368
0 commit comments