Last active
August 6, 2021 11:31
-
-
Save percybolmer/85d308e202493f33e4b408d917c48d8d 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 rewards", async() => { | |
devToken = await DevToken.deployed(); | |
let owner = accounts[0]; | |
// Owner has 1 stake at this time, its the index 1 with 100 Tokens staked | |
// So lets fast forward time by 20 Hours and see if we gain 2% reward | |
const newBlock = await helper.advanceTimeAndBlock(3600*20); | |
let reward = await devToken.calculateTotalAvailableRewards(owner); | |
assert.equal(reward.toNumber(), 100*0.02, "Reward should be 2 after staking for twenty hours with 100") | |
// Make a new Stake for 1000, fast forward 20 hours again, and make sure total stake reward is 24 (20+4) | |
// Remember that the first 100 has been staked for 40 hours now, so its 4 in rewards. | |
await devToken.stake(1000, {from: owner}); | |
await helper.advanceTimeAndBlock(3600*20); | |
let stakes = await devToken.hasStake(owner); | |
let second_reward = await devToken.calculateTotalAvailableRewards(owner); | |
assert.equal(second_reward.toNumber(), (100*0.04)+(1000*0.02), "Staking reward for the two bets should sum up to 24 tokens"); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment