Last active
August 6, 2021 11:27
-
-
Save percybolmer/d879040c603102be146c750c594f1478 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 summary = await devToken.hasStake(owner); | |
let stake = summary.stakes[1]; | |
assert.equal(stake.claimable, 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); | |
summary = await devToken.hasStake(owner); | |
stake = summary.stakes[1]; | |
let newstake = summary.stakes[2]; | |
assert.equal(stake.claimable, (100*0.04), "Reward should be 4 after staking for 40 hours") | |
assert.equal(newstake.claimable, (1000*0.02), "Reward should be 20 after staking 20 hours"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment