Skip to content

Instantly share code, notes, and snippets.

@lakamsani
Created March 26, 2018 06:10
Show Gist options
  • Save lakamsani/f129f9b5b4e07347bd9bf95e2f0fea65 to your computer and use it in GitHub Desktop.
Save lakamsani/f129f9b5b4e07347bd9bf95e2f0fea65 to your computer and use it in GitHub Desktop.
Token transfer

With reference to OpenZeppelin/openzeppelin-contracts#584 (comment) , here is the working code. Thanks https://github.com/Shrugs

it('Token transfer', async () => {
    const fromAccount = accounts[1]
    const toAccount = accounts[4]
    const transferLimit = 4000000000000000000
    const transferAmount = 3000000000000000000
    let ecoSystemBalance = await tokenInstance.balanceOf(fromAccount)
    assert.isAtLeast(ecoSystemBalance, transferLimit, 'From account balance should be atleast 4')
    await tokenInstance.approve(toAccount, transferLimit, {from: fromAccount})
    assert.equal(await tokenInstance.allowance(fromAccount, toAccount), transferLimit, 'Allowance from->to should be 4')
    console.log(`Attempting a transfer with ecoSystem balance of ${ecoSystemBalance}`)
    await tokenInstance.transferFrom(fromAccount, toAccount, transferAmount, {from: toAccount})
    assert.equal(await tokenInstance.balanceOf(toAccount), transferAmount, 'To account should have 3')
  })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment