Skip to content

Commit 36560b2

Browse files
test: Adjusted tests for any typing
1 parent 92ca3cf commit 36560b2

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

test/tradingRewardsDistributor.test.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ describe("TradingRewardsDistributor", () => {
2121
let admin: SignerWithAddress;
2222
let accounts: SignerWithAddress[];
2323

24-
let tree: any;
25-
let hexRoot: any;
24+
let tree: MerkleTree;
25+
let hexRoot: string;
2626

2727
beforeEach(async () => {
2828
accounts = await ethers.getSigners();
@@ -73,7 +73,7 @@ describe("TradingRewardsDistributor", () => {
7373
break;
7474
}
7575
// 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));
7777

7878
// Verify leaf is matched in the tree with the computed root
7979
assert.isTrue(tree.verify(hexProof, computeHash(user, value), hexRoot));
@@ -130,7 +130,7 @@ describe("TradingRewardsDistributor", () => {
130130
}
131131

132132
// 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));
134134

135135
// Verify leaf is matched in the tree with the computed root
136136
assert.isTrue(tree.verify(hexProof, computeHash(user, value), hexRoot));
@@ -164,12 +164,12 @@ describe("TradingRewardsDistributor", () => {
164164
const expectedAmountToReceive = parseEther("3000");
165165

166166
// 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);
168168

169169
// 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)
173173
);
174174

175175
tx = await tradingRewardsDistributor.connect(lateClaimer).claim(expectedAmountToReceive, hexProof);
@@ -205,8 +205,8 @@ describe("TradingRewardsDistributor", () => {
205205
const expectedAmountToReceiveForUser2 = parseEther("3000");
206206

207207
// 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);
210210

211211
// Owner adds trading rewards and unpause distribution
212212
await tradingRewardsDistributor.connect(admin).updateTradingRewards(hexRoot, parseEther("5000"));
@@ -293,20 +293,18 @@ describe("TradingRewardsDistributor", () => {
293293
).to.be.revertedWith("Rewards: Invalid proof");
294294

295295
// 7. Non-eligible user cannot claim with proof/amount of user1
296-
assert.equal(
296+
assert.isFalse(
297297
tree.verify(
298298
hexProof2,
299299
computeHash(notEligibleUser.address, expectedAmountToReceiveForUser2.toString()),
300300
hexRoot
301-
),
302-
false
301+
)
303302
);
304303

305-
assert.equal(
304+
assert.isFalse(
306305
(
307306
await tradingRewardsDistributor.canClaim(notEligibleUser.address, expectedAmountToReceiveForUser2, hexProof2)
308-
)[0],
309-
false
307+
)[0]
310308
);
311309

312310
await expect(
@@ -337,7 +335,7 @@ describe("TradingRewardsDistributor", () => {
337335
const expectedAmountToReceiveForUser1 = parseEther("5000");
338336

339337
// 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);
341339

342340
// Owner adds trading rewards and unpause distribution
343341
await tradingRewardsDistributor.connect(admin).updateTradingRewards(hexRoot, parseEther("4999.9999"));

0 commit comments

Comments
 (0)