Created
May 8, 2021 04:44
-
-
Save percybolmer/1a4638db945de8cb122a3db732ce3dcb 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("removeStake overflow", async () => { | |
// Transfer tokens to account 2 and use for testing | |
let staker = accounts[2]; | |
let stake_amount = 100; | |
await devToken.transfer(staker, stake_amount + 1); | |
try { | |
// Stake our Tokens | |
await devToken.stake(stake_amount, { from: staker }); | |
amount = await devToken.hasStake(staker); | |
assert.equal(amount, stake_amount, "Stake should have passed through when staking") | |
// Unstake more than we staked | |
await devToken.removeStake(stake_amount * 2, { from: staker }); | |
} catch (error) { | |
assert.equal(error.reason, UNSTAKING_TO_MUCH_MSG, "Unstaking too much should result in an revert and error") | |
} | |
}) | |
it("removeStake should return tokens", async () => { | |
// Transfer tokens to account 3 and use for testing | |
let staker = accounts[3]; | |
let stake_amount = 100; | |
await devToken.transfer(staker, stake_amount + 1); | |
// Stake our Tokens | |
await devToken.stake(stake_amount, { from: staker }); | |
amount = await devToken.hasStake(staker); | |
balance = await devToken.balanceOf(staker); | |
assert.equal(amount, stake_amount, "Stake should have passed through when staking") | |
// Unstake what was staked | |
await devToken.removeStake(stake_amount, { from: staker }); | |
// Check if is staker, and check balance | |
amount = await devToken.hasStake(staker); | |
assert.equal(amount, 0, "Stake should have been reduced"); | |
new_balance = await devToken.balanceOf(staker); | |
assert.equal(101, new_balance.toNumber(), "Tokens should have returned to balance") | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment