Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save percybolmer/f40ae38c2e3dda5d1354da9399298d9c to your computer and use it in GitHub Desktop.
Save percybolmer/f40ae38c2e3dda5d1354da9399298d9c to your computer and use it in GitHub Desktop.
const DevToken = artifacts.require("DevToken");
contract("DevToken", async accounts => {
it("Stake 100 x2", async () => {
// Deploy the DevToken and await it, store the results inside devToken
devToken = await DevToken.deployed();
// Stake 100 is used to stake 100 tokens twice and see that stake is added correctly and money burned
let owner = accounts[0];
// Set owner, user and a stake_amount
let stake_amount = 100
// Get init balance of user
balance = await devToken.balanceOf(owner)
// Stake the amount, notice the FROM parameter which specifes what the msg.sender address will be
try{
stakeID = await devToken.stake(stake_amount, { from: owner });
}catch(error){
assert.equal(error.reason, "", "Stakeing should have worked");
}
console.log("STAKE ID: ", stakeID);
assert.equal(stakeID.toNumber(), 1, "The stakeID should be 1");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment