Created
May 8, 2021 11:45
-
-
Save percybolmer/af59de384e9b33cff992d716530ac5b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it("calculate stakerholder rewards", async () => { | |
// Transfer tokens to account 4 and use for testing | |
let staker = accounts[4]; | |
let stake_amount = 100; | |
await devToken.transfer(staker, stake_amount + 1); | |
// See what rewards we get before staking | |
let amount = await devToken.calculateStakeReward(staker); | |
assert.equal(amount.toNumber(), 0, "Reward calculation not working as expected"); | |
// Stake some tokens and then calculate reward | |
await devToken.stake(100, { from: staker}); | |
let has_staked = await devToken.hasStake(staker); | |
assert.equal(has_staked.toNumber(), stake_amount, "Staker should have 100 tokens staked") | |
let reward = await devToken.calculateStakeReward(staker); | |
assert.equal(reward.toNumber(), stake_amount * 0.05, "Reward calculation not working as expected"); | |
}); | |
it("reward stakeholder", async() => { | |
// We know account 4 and 3 has 100 Stakes, so lets reward them and see if it works | |
// There should be 1 Token in their balance, make sure first | |
let initial_balance = await devToken.balanceOf(accounts[4]); | |
assert.equal(initial_balance.toNumber(), 1, "The staker should have a balance of 1"); | |
// Lets reward stakeholders and make sure the new balance is 6 | |
await devToken.rewardStakeHolder({from: accounts[4]}); | |
let after_reward_balance = await devToken.balanceOf(accounts[4]); | |
assert.equal(after_reward_balance.toNumber(), 6, "The new balance should be 6"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment