---
title: "Vamsee (@vamsee) | Hashnode"
description: "Vamsee (@vamsee) writes on Hashnode. Read their latest articles and follow their work."
url: "https://hashnode.com/@vamsee"
---

@vamsee

# Vamsee

@vamsee · Joined January 2018

## Comments

[Here is the fixed/working code, thanks to advice from https://github.com/OpenZeppelin/zeppelin-solidity/issues/584#issuecomment-376042522 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') })](https://hashnode.com/posts/the-2018-guide-to-writing-and-testing-real-world-crowdsale-contracts/5a67bb65357c012503a334c9/comment/5a9f1e750430f87244d401be#reply-5ab886bc17ffdb9314085414)

Reply · Article · Mar 26, 2018 · [The 2018 guide to writing (and testing) real world crowdsale contracts](https://hashnode.com/posts/the-2018-guide-to-writing-and-testing-real-world-crowdsale-contracts/5a67bb65357c012503a334c9)

[Hi, trying to add a transfer test like this but it is failing. it('Token transfer', async () => { const contractInstance = await HashnodeCrowdsale.deployed() let ecoSystemBalance = await web3.eth.getBalance(accounts\[9\]) const tokenAddress = await contractInstance.token.call() const hashToken = HashnodeToken.at(tokenAddress) const owner = await hashToken.owner.call() console.log(owner) await hashToken.approve(accounts\[4\], 4) console.log(await hashToken.allowance(owner, accounts\[4\])) await hashToken.transferFrom(owner, accounts\[4\], 3) let receiverBalance = await web3.eth.getBalance(accounts\[4\]) receiverBalance = receiverBalance.toNumber() assert.equal(receiverBalance, 3, 'Transfer failed') }) getting this error. Any idea how to get that working? Tried with other from addresses like accounts\[9\] but getting the same error. == output of the test run === 0x85d22c38d2b791a5803fc3f15267fda1b0473c3b BigNumber { s: 1, e: 0, c: \[ 0 \] } Events emitted during test: --------------------------- Approval(owner: <indexed>, spender: <indexed>, value: 4) --------------------------- Error: VM Exception while processing transaction: revert at Object.InvalidResponse (node\_modules/truffle-contract/node\_modules/web3/lib/web3/errors.js:38:16) at node\_modules/truffle-contract/node\_modules/web3/lib/web3/requestmanager.js:86:36 at node\_modules/truffle-provider/wrapper.js:134:9 at XMLHttpRequest.request.onreadystatechange (node\_modules/truffle-provider/node\_modules/web3/lib/web3/httpprovider.js:128:7) at XMLHttpRequestEventTarget.dispatchEvent (node\_modules/xhr2/lib/xhr2.js:64:18) at XMLHttpRequest.\_setReadyState (node\_modules/xhr2/lib/xhr2.js:354:12) at XMLHttpRequest.\_onHttpResponseEnd (node\_modules/xhr2/lib/xhr2.js:509:12) at IncomingMessage.<anonymous> (node\_modules/xhr2/lib/xhr2.js:469:24) at endReadableNT (\_stream\_readable.js:1055:12) at \_combinedTickCallback (internal/process/next\_tick.js:138:11) at process.\_tickCallback (internal/process/next\_tick.js:180:9)](https://hashnode.com/posts/the-2018-guide-to-writing-and-testing-real-world-crowdsale-contracts/5a67bb65357c012503a334c9/comment/5a9f1e750430f87244d401be#reply-5ab7f80a17ffdb93140852ed)

Reply · Article · Mar 25, 2018 · [The 2018 guide to writing (and testing) real world crowdsale contracts](https://hashnode.com/posts/the-2018-guide-to-writing-and-testing-real-world-crowdsale-contracts/5a67bb65357c012503a334c9)

[Hi Sandeep, thanks for publishing this. Just FYI you can simplify the tests like this: it('should deploy the token and store the address', async () => { const instance = await HashnodeCrowdsale.deployed() const token = await instance.token.call() assert(token, 'Token address couldn\\'t be stored') });](https://hashnode.com/posts/the-2018-guide-to-writing-and-testing-real-world-crowdsale-contracts/5a67bb65357c012503a334c9/comment/5a70e6eed3e3e6ca6266621f#reply-5a964977e96b06960604ffb8)

Reply · Article · Feb 28, 2018 · [The 2018 guide to writing (and testing) real world crowdsale contracts](https://hashnode.com/posts/the-2018-guide-to-writing-and-testing-real-world-crowdsale-contracts/5a67bb65357c012503a334c9)
