Skip to content

Commit

Permalink
refactor and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinarora committed Mar 22, 2024
1 parent 60b2398 commit fa4f5ab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
3 changes: 1 addition & 2 deletions contracts/FeeBaseHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ abstract contract FeeBaseHelper is ERC20Helper, GovManager {
if(feeToPay == 0) return;
uint credits = getCredits(msg.sender);
if(credits > 0) {
IWhiteList(WhiteListAddress).Register(msg.sender, WhiteListId, credits < feeToPay ? credits : feeToPay);

Check warning on line 28 in contracts/FeeBaseHelper.sol

View check run for this annotation

Codecov / codecov/patch

contracts/FeeBaseHelper.sol#L28

Added line #L28 was not covered by tests
if(credits < feeToPay) {
feeToPay -= credits;

Check warning on line 30 in contracts/FeeBaseHelper.sol

View check run for this annotation

Codecov / codecov/patch

contracts/FeeBaseHelper.sol#L30

Added line #L30 was not covered by tests
IWhiteList(WhiteListAddress).Register(msg.sender, WhiteListId, credits);
} else {
IWhiteList(WhiteListAddress).Register(msg.sender, WhiteListId, feeToPay);
return;

Check warning on line 32 in contracts/FeeBaseHelper.sol

View check run for this annotation

Codecov / codecov/patch

contracts/FeeBaseHelper.sol#L32

Added line #L32 was not covered by tests
}
}
Expand Down
21 changes: 21 additions & 0 deletions test/3_Fee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,25 @@ describe('Fee Helper Test', function () {
expect(actualBal).to.be.equal(oldBal.add(fee));
});
});

describe("Whitelist Settings", async () => {
it("should set whitelist address", async () => {
const oldWhiteList = await feeHelper.WhiteListAddress()
const newWhiteList = (await ethers.getSigners()).at(-1) as SignerWithAddress;
await feeHelper.setWhiteListAddress(newWhiteList.address)
const whiteList = await feeHelper.WhiteListAddress()
expect(whiteList).to.be.equal(newWhiteList.address)
expect(whiteList).to.not.equal(oldWhiteList)
await feeHelper.setWhiteListAddress(oldWhiteList)
})

it("should set whitelist id", async () => {
const oldWhiteListId = await feeHelper.WhiteListId()
const newwhiteListId = 5
await feeHelper.setWhiteListId(newwhiteListId)
const whiteListId = await feeHelper.WhiteListId()
expect(whiteListId).to.be.equal(newwhiteListId)
expect(whiteListId).to.not.equal(oldWhiteListId)
})
})
});

0 comments on commit fa4f5ab

Please sign in to comment.