Last active
April 10, 2018 22:43
-
-
Save MrCrambo/5f042883121c8a70bd449a4eb3521f40 to your computer and use it in GitHub Desktop.
This file contains 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
describe('transfer', function () { | |
const this.to = accounts[4] | |
const amount = 100 | |
it('transfers the requested amount', async function () { | |
await this.token.transfer(this.to, amount, { from: this.owner }) | |
const senderBalance = await this.token.balanceOf(this.owner) | |
assert.equal(senderBalance, 0); | |
const recipientBalance = await this.token.balanceOf(this.to) | |
assert.equal(recipientBalance, amount) | |
}); | |
it('reverts', async function () { | |
const revertAmount = 101 | |
await assertRevert(this.token.transfer(this.to, revertAmount, { from: this.owner })) | |
}); | |
it('reverts', async function () { | |
const toContract = '0x0000000000000000000000000000000000000000' | |
await assertRevert(this.token.transfer(toContract, 1, { from: this.owner })) | |
}); | |
it('emits a transfer event', async function () { | |
const { logs } = await this.token.transfer(this.to, amount, { from: this.owner }) | |
assert.equal(logs.length, 1) | |
assert.equal(logs[0].event, 'Transfer') | |
assert.equal(logs[0].args.from, this.owner) | |
assert.equal(logs[0].args.to, this.to) | |
assert(logs[0].args.value.eq(amount)) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment