Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.