Created
June 30, 2017 19:03
-
-
Save sogoiii/c72d64180cf6d05b445d028d699feab9 to your computer and use it in GitHub Desktop.
Large async await test in Truffle
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("should send coin correctly", async function () { | |
// Get initial balances of first and second account. | |
var account_one = accounts[0]; | |
var account_two = accounts[1]; | |
var amount = 10; | |
let meta = await MetaCoin.deployed(); | |
let balance1 = await meta.getBalance.call(account_one); | |
let balance2 = await meta.getBalance.call(account_two); | |
let account_one_starting_balance = balance1.toNumber(); | |
let account_two_starting_balance = balance2.toNumber(); | |
await meta.sendCoin(account_two, amount, {from: account_one}); | |
let balance3 = await meta.getBalance.call(account_one); | |
let balance4 = await meta.getBalance.call(account_two); | |
let account_one_ending_balance = balance3.toNumber(); | |
let account_two_ending_balance = balance4.toNumber(); | |
assert.equal(account_one_ending_balance, account_one_starting_balance - 10, "Amount wasn't correctly taken from the sender"); | |
assert.equal(account_two_ending_balance, account_two_starting_balance + 10, "Amount wasn't correctly sent to the receiver"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment