Skip to content

Instantly share code, notes, and snippets.

@MrCrambo
Last active April 10, 2018 22:43
Show Gist options
  • Save MrCrambo/5f042883121c8a70bd449a4eb3521f40 to your computer and use it in GitHub Desktop.
Save MrCrambo/5f042883121c8a70bd449a4eb3521f40 to your computer and use it in GitHub Desktop.
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