Skip to content

Commit

Permalink
fix totalSupply
Browse files Browse the repository at this point in the history
  • Loading branch information
elshan-eth committed Feb 21, 2024
1 parent 68f7e1a commit adfc914
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions contracts/contracts/DevRewardDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ contract DevRewardDistributor {
}

function transfer(address to, uint256 value) external returns (bool) {
require(value > 0, "Value is 0");
require(lockedBalances[msg.sender].amount == value, "Invalid amount");
require(block.timestamp > lockedBalances[msg.sender].unlockTime, "Tokens are locked");

Expand Down
11 changes: 11 additions & 0 deletions contracts/test/DevRewardDestributor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ describe("DevRewardDistributor", () => {
it("claim reward", async () => {
let lastId = -1;
for (let i = 0; i < 2; i++) {
const initTotalSupply = await rewardDistributor.totalSupply();

const info = getRandomAccountInfo(lastId);
lastId = info.accountId;

Expand Down Expand Up @@ -220,6 +222,10 @@ describe("DevRewardDistributor", () => {
);

expect(await rewardDistributor.isClaimed(info.accountId)).to.be.true;

expect(await rewardDistributor.totalSupply()).to.eq(
initTotalSupply.add(reward)
);
}
});

Expand Down Expand Up @@ -254,11 +260,16 @@ describe("DevRewardDistributor", () => {

await ethers.provider.send("evm_increaseTime", [unlockTime.toNumber()]);

const totalSupply = await rewardDistributor.totalSupply();
const transferTx = await rewardDistributor.transfer(
developerAccount.address,
reward
);

expect(await rewardDistributor.totalSupply()).to.eq(
totalSupply.sub(reward)
);

await expect(transferTx)
.to.emit(token, "Transfer")
.withArgs(rewardDistributor.address, developerAccount.address, reward);
Expand Down

0 comments on commit adfc914

Please sign in to comment.