@@ -10,7 +10,7 @@ import {
10
10
OGFoundersRootstockCollective ,
11
11
} from '../typechain-types'
12
12
import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers'
13
- import { ContractTransactionResponse , parseEther , solidityPackedKeccak256 } from 'ethers'
13
+ import { ContractTransactionResponse , parseEther , solidityPackedKeccak256 , ZeroAddress } from 'ethers'
14
14
import { Proposal , ProposalState , OperationState } from '../types'
15
15
import { deployContracts } from './deployContracts'
16
16
import ogFoundersModule from '../ignition/modules/OGFoundersModule'
@@ -153,7 +153,7 @@ describe('Governor Contact', () => {
153
153
describe ( 'Proposal Creation' , ( ) => {
154
154
it ( 'participants should gain voting power proportional to RIF tokens' , async ( ) => {
155
155
await Promise . all (
156
- holders . slice ( 0 , holders . length - 1 ) . map ( async ( voter , i ) => {
156
+ holders . slice ( 0 , holders . length ) . map ( async ( voter , i ) => {
157
157
const dispenseTx = await rif . transfer ( voter . address , dispenseValue )
158
158
await dispenseTx . wait ( )
159
159
const rifBalance = await rif . balanceOf ( voter . address )
@@ -163,11 +163,15 @@ describe('Governor Contact', () => {
163
163
await approvalTx . wait ( )
164
164
const depositTx = await stRIF . connect ( voter ) . depositFor ( voter . address , votingPower )
165
165
await depositTx . wait ( )
166
- const delegateTx = await stRIF . connect ( voter ) . delegate ( voter . address )
167
- await delegateTx . wait ( )
168
- const votes = await stRIF . getVotes ( voter . address )
169
166
170
- expect ( votes ) . to . equal ( votingPower )
167
+ // prepare for delegation tests
168
+ if ( i !== holders . length - 1 ) {
169
+ const delegateTx = await stRIF . connect ( voter ) . delegate ( voter . address )
170
+ await delegateTx . wait ( )
171
+ const votes = await stRIF . getVotes ( voter . address )
172
+
173
+ expect ( votes ) . to . equal ( votingPower )
174
+ }
171
175
} ) ,
172
176
)
173
177
} )
@@ -399,6 +403,34 @@ describe('Governor Contact', () => {
399
403
)
400
404
} )
401
405
406
+ it ( 'A transfers stRIF, B has no delegatee set, voting power is still 0' , async ( ) => {
407
+ const testedHolders = holders . slice ( holders . length - 2 )
408
+
409
+ const votingPowersBefore = testedHolders . map ( async holder => {
410
+ return await stRIF . getVotes ( holder )
411
+ } )
412
+
413
+ expect ( await votingPowersBefore [ 0 ] ) . to . equal ( dispenseValue - sendAmount )
414
+ expect ( await stRIF . delegates ( testedHolders [ 0 ] ) ) . to . equal ( testedHolders [ 0 ] . address )
415
+ expect ( await votingPowersBefore [ 1 ] ) . to . equal ( 0n )
416
+ expect ( await stRIF . delegates ( testedHolders [ 1 ] ) ) . to . equal ( ZeroAddress )
417
+
418
+ const balanceOfABefore = await stRIF . balanceOf ( testedHolders [ 0 ] )
419
+ const balanceOfBBefore = await stRIF . balanceOf ( testedHolders [ 1 ] )
420
+
421
+ const transferFromAtoB = await stRIF
422
+ . connect ( testedHolders [ 0 ] )
423
+ . transfer ( testedHolders [ 1 ] , sendAmount )
424
+
425
+ await transferFromAtoB . wait ( )
426
+
427
+ expect ( await stRIF . balanceOf ( testedHolders [ 0 ] ) ) . to . equal ( balanceOfABefore - sendAmount )
428
+ expect ( await stRIF . balanceOf ( testedHolders [ 1 ] ) ) . to . equal ( balanceOfBBefore + sendAmount )
429
+
430
+ expect ( await stRIF . getVotes ( testedHolders [ 0 ] ) ) . to . equal ( balanceOfABefore - sendAmount )
431
+ expect ( await stRIF . getVotes ( testedHolders [ 1 ] ) ) . to . equal ( 0n )
432
+ } )
433
+
402
434
it ( 'should be possible to claim back votes' , async ( ) => {
403
435
const balance1 = await stRIF . balanceOf ( holders [ 1 ] )
404
436
0 commit comments