diff options
author | Fabio Berger <me@fabioberger.com> | 2017-06-03 02:34:16 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-06-03 02:34:16 +0800 |
commit | c6ceb44682a19c9f53505803547fcb2012691b5b (patch) | |
tree | 5336a6ad855bba28caa9b7aa27ca85a2a0781c0d /test/token_wrapper_test.ts | |
parent | bae4b1ee1b991340df5bf2c5317b7af7088cedd3 (diff) | |
download | dexon-0x-contracts-c6ceb44682a19c9f53505803547fcb2012691b5b.tar dexon-0x-contracts-c6ceb44682a19c9f53505803547fcb2012691b5b.tar.gz dexon-0x-contracts-c6ceb44682a19c9f53505803547fcb2012691b5b.tar.bz2 dexon-0x-contracts-c6ceb44682a19c9f53505803547fcb2012691b5b.tar.lz dexon-0x-contracts-c6ceb44682a19c9f53505803547fcb2012691b5b.tar.xz dexon-0x-contracts-c6ceb44682a19c9f53505803547fcb2012691b5b.tar.zst dexon-0x-contracts-c6ceb44682a19c9f53505803547fcb2012691b5b.zip |
Fix bug
Diffstat (limited to 'test/token_wrapper_test.ts')
-rw-r--r-- | test/token_wrapper_test.ts | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/test/token_wrapper_test.ts b/test/token_wrapper_test.ts index 08eb8aec0..698ad5b6a 100644 --- a/test/token_wrapper_test.ts +++ b/test/token_wrapper_test.ts @@ -68,9 +68,11 @@ describe('TokenWrapper', () => { describe('#transferFromAsync', () => { let token: Token; let toAddress: string; + let senderAddress: string; before(async () => { token = tokens[0]; toAddress = addressWithoutFunds; + senderAddress = userAddresses[2]; }); it('should fail to transfer tokens if fromAddress has insufficient allowance set', async () => { const fromAddress = coinbase; @@ -83,7 +85,6 @@ describe('TokenWrapper', () => { toAddress); expect(fromAddressAllowance).to.be.bignumber.equal(0); - const senderAddress = toAddress; return expect(zeroEx.token.transferFromAsync( token.address, fromAddress, toAddress, senderAddress, transferAmount, )).to.be.rejectedWith(ZeroExError.INSUFFICIENT_ALLOWANCE_FOR_TRANSFER); @@ -95,12 +96,11 @@ describe('TokenWrapper', () => { const fromAddressBalance = await zeroEx.token.getBalanceAsync(token.address, fromAddress); expect(fromAddressBalance).to.be.bignumber.equal(0); - await zeroEx.token.setAllowanceAsync(token.address, fromAddress, toAddress, transferAmount); + await zeroEx.token.setAllowanceAsync(token.address, fromAddress, senderAddress, transferAmount); const fromAddressAllowance = await zeroEx.token.getAllowanceAsync(token.address, fromAddress, - toAddress); + senderAddress); expect(fromAddressAllowance).to.be.bignumber.equal(transferAmount); - const senderAddress = toAddress; return expect(zeroEx.token.transferFromAsync( token.address, fromAddress, toAddress, senderAddress, transferAmount, )).to.be.rejectedWith(ZeroExError.INSUFFICIENT_BALANCE_FOR_TRANSFER); @@ -112,9 +112,8 @@ describe('TokenWrapper', () => { expect(preBalance).to.be.bignumber.equal(0); const transferAmount = new BigNumber(42); - await zeroEx.token.setAllowanceAsync(token.address, fromAddress, toAddress, transferAmount); + await zeroEx.token.setAllowanceAsync(token.address, fromAddress, senderAddress, transferAmount); - const senderAddress = toAddress; await zeroEx.token.transferFromAsync(token.address, fromAddress, toAddress, senderAddress, transferAmount); const postBalance = await zeroEx.token.getBalanceAsync(token.address, toAddress); @@ -123,7 +122,6 @@ describe('TokenWrapper', () => { it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => { const fromAddress = coinbase; const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065'; - const senderAddress = fromAddress; return expect(zeroEx.token.transferFromAsync( nonExistentTokenAddress, fromAddress, toAddress, senderAddress, new BigNumber(42), )).to.be.rejectedWith(ZeroExError.CONTRACT_DOES_NOT_EXIST); |