Skip to content

Commit

Permalink
chore: additional setRewardsDistribution tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xApotheosis committed Sep 16, 2024
1 parent ba7d96f commit c0095da
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/StakingRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ describe('StakingRewards', function () {
await expect(stakingRewards.write.notifyRewardAmount([rewardAmount], { account: rewardsDistribution.account }))
.to.not.be.rejected;
});

it('only owner can call setRewardDistribution', async () => {
const { stakingRewards, stakingAccount2, owner } = await loadFixture(deployStakingRewardsFixture);

await expect(stakingRewards.write.setRewardsDistribution([getAddress('0x0000000000000000000000000000000000000000')], { account: stakingAccount2.account }))
.to.be.rejectedWith('Only the contract owner may perform this action');

await expect(stakingRewards.write.setRewardsDistribution([getAddress('0x0000000000000000000000000000000000000000')], { account: owner.account }))
.to.not.be.rejected;
});
});

describe('Pausable', () => {
Expand Down Expand Up @@ -162,6 +172,17 @@ describe('StakingRewards', function () {
const earnedRewards2 = await stakingRewards.read.earned([stakingAccount2.account.address]);
expect(earnedRewards2 as bigint === ((timeStaked2 / rewardsDuration) * rewardAmount) / stakeAmount2);
});

it('Should allow owner changing the rewards distribution address', async () => {
const { stakingRewards, rewardsDistribution, owner } = await loadFixture(deployStakingRewardsFixture);
const newRewardsDistribution = getAddress('0x0000000000000000000000000000000000000001');

const initialAddress = getAddress(rewardsDistribution.account.address);
expect(await stakingRewards.read.rewardsDistribution()).to.equal(initialAddress);

await stakingRewards.write.setRewardsDistribution([newRewardsDistribution], { account: owner.account });
expect(await stakingRewards.read.rewardsDistribution()).to.equal(newRewardsDistribution);
});
});

describe('Withdrawals', function () {
Expand Down

0 comments on commit c0095da

Please sign in to comment.