@@ -21,8 +21,8 @@ describe("TradingRewardsDistributor", () => {
21
21
let admin : SignerWithAddress ;
22
22
let accounts : SignerWithAddress [ ] ;
23
23
24
- let tree : any ;
25
- let hexRoot : any ;
24
+ let tree : MerkleTree ;
25
+ let hexRoot : string ;
26
26
27
27
beforeEach ( async ( ) => {
28
28
accounts = await ethers . getSigners ( ) ;
@@ -73,7 +73,7 @@ describe("TradingRewardsDistributor", () => {
73
73
break ;
74
74
}
75
75
// Compute the proof for the user
76
- const hexProof = tree . getHexProof ( computeHash ( user , value ) , index ) ;
76
+ const hexProof = tree . getHexProof ( computeHash ( user , value ) , Number ( index ) ) ;
77
77
78
78
// Verify leaf is matched in the tree with the computed root
79
79
assert . isTrue ( tree . verify ( hexProof , computeHash ( user , value ) , hexRoot ) ) ;
@@ -130,7 +130,7 @@ describe("TradingRewardsDistributor", () => {
130
130
}
131
131
132
132
// Compute the proof for the user
133
- const hexProof = tree . getHexProof ( computeHash ( user , value ) , index ) ;
133
+ const hexProof = tree . getHexProof ( computeHash ( user , value ) , Number ( index ) ) ;
134
134
135
135
// Verify leaf is matched in the tree with the computed root
136
136
assert . isTrue ( tree . verify ( hexProof , computeHash ( user , value ) , hexRoot ) ) ;
@@ -164,12 +164,12 @@ describe("TradingRewardsDistributor", () => {
164
164
const expectedAmountToReceive = parseEther ( "3000" ) ;
165
165
166
166
// Compute the proof for the user4
167
- const hexProof = tree . getHexProof ( computeHash ( lateClaimer . address , expectedAmountToReceive . toString ( ) ) , "3" ) ;
167
+ const hexProof = tree . getHexProof ( computeHash ( lateClaimer . address , expectedAmountToReceive . toString ( ) ) , 2 ) ;
168
168
169
169
// Verify leaf is matched in the tree with the computed root
170
- assert . equal (
171
- tree . verify ( hexProof , computeHash ( lateClaimer . address , expectedAmountToReceive . toString ( ) ) , hexRoot ) ,
172
- true
170
+
171
+ assert . isTrue (
172
+ tree . verify ( hexProof , computeHash ( lateClaimer . address , expectedAmountToReceive . toString ( ) ) , hexRoot )
173
173
) ;
174
174
175
175
tx = await tradingRewardsDistributor . connect ( lateClaimer ) . claim ( expectedAmountToReceive , hexProof ) ;
@@ -205,8 +205,8 @@ describe("TradingRewardsDistributor", () => {
205
205
const expectedAmountToReceiveForUser2 = parseEther ( "3000" ) ;
206
206
207
207
// Compute the proof for user1/user2
208
- const hexProof1 = tree . getHexProof ( computeHash ( user1 . address , expectedAmountToReceiveForUser1 . toString ( ) ) , "0" ) ;
209
- const hexProof2 = tree . getHexProof ( computeHash ( user2 . address , expectedAmountToReceiveForUser2 . toString ( ) ) , "1" ) ;
208
+ const hexProof1 = tree . getHexProof ( computeHash ( user1 . address , expectedAmountToReceiveForUser1 . toString ( ) ) , 0 ) ;
209
+ const hexProof2 = tree . getHexProof ( computeHash ( user2 . address , expectedAmountToReceiveForUser2 . toString ( ) ) , 1 ) ;
210
210
211
211
// Owner adds trading rewards and unpause distribution
212
212
await tradingRewardsDistributor . connect ( admin ) . updateTradingRewards ( hexRoot , parseEther ( "5000" ) ) ;
@@ -293,20 +293,18 @@ describe("TradingRewardsDistributor", () => {
293
293
) . to . be . revertedWith ( "Rewards: Invalid proof" ) ;
294
294
295
295
// 7. Non-eligible user cannot claim with proof/amount of user1
296
- assert . equal (
296
+ assert . isFalse (
297
297
tree . verify (
298
298
hexProof2 ,
299
299
computeHash ( notEligibleUser . address , expectedAmountToReceiveForUser2 . toString ( ) ) ,
300
300
hexRoot
301
- ) ,
302
- false
301
+ )
303
302
) ;
304
303
305
- assert . equal (
304
+ assert . isFalse (
306
305
(
307
306
await tradingRewardsDistributor . canClaim ( notEligibleUser . address , expectedAmountToReceiveForUser2 , hexProof2 )
308
- ) [ 0 ] ,
309
- false
307
+ ) [ 0 ]
310
308
) ;
311
309
312
310
await expect (
@@ -337,7 +335,7 @@ describe("TradingRewardsDistributor", () => {
337
335
const expectedAmountToReceiveForUser1 = parseEther ( "5000" ) ;
338
336
339
337
// Compute the proof for user1/user2
340
- const hexProof1 = tree . getHexProof ( computeHash ( user1 . address , expectedAmountToReceiveForUser1 . toString ( ) ) , "0" ) ;
338
+ const hexProof1 = tree . getHexProof ( computeHash ( user1 . address , expectedAmountToReceiveForUser1 . toString ( ) ) , 0 ) ;
341
339
342
340
// Owner adds trading rewards and unpause distribution
343
341
await tradingRewardsDistributor . connect ( admin ) . updateTradingRewards ( hexRoot , parseEther ( "4999.9999" ) ) ;
0 commit comments