aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-06-02 22:29:12 +0800
committerFabio Berger <me@fabioberger.com>2017-06-02 22:29:12 +0800
commit21292ad15ec9490acb8d3089286f3d81e83967b7 (patch)
tree1f08ab21da3f38b4573c623a87cb44c21c3fcbfc /test
parentaed96d593d2658f022a257d00124c244bb73bf92 (diff)
downloaddexon-sol-tools-21292ad15ec9490acb8d3089286f3d81e83967b7.tar
dexon-sol-tools-21292ad15ec9490acb8d3089286f3d81e83967b7.tar.gz
dexon-sol-tools-21292ad15ec9490acb8d3089286f3d81e83967b7.tar.bz2
dexon-sol-tools-21292ad15ec9490acb8d3089286f3d81e83967b7.tar.lz
dexon-sol-tools-21292ad15ec9490acb8d3089286f3d81e83967b7.tar.xz
dexon-sol-tools-21292ad15ec9490acb8d3089286f3d81e83967b7.tar.zst
dexon-sol-tools-21292ad15ec9490acb8d3089286f3d81e83967b7.zip
Add balance check to `transferAsync` and related test
Diffstat (limited to 'test')
-rw-r--r--test/token_wrapper_test.ts17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/token_wrapper_test.ts b/test/token_wrapper_test.ts
index e8d2199e9..3b9071bde 100644
--- a/test/token_wrapper_test.ts
+++ b/test/token_wrapper_test.ts
@@ -33,23 +33,34 @@ describe('TokenWrapper', () => {
await blockchainLifecycle.revertAsync();
});
describe('#transferAsync', () => {
+ let token: Token;
+ let transferAmount: BigNumber.BigNumber;
+ before(() => {
+ token = tokens[0];
+ transferAmount = new BigNumber(42);
+ });
it('should successfully transfer tokens', async () => {
- const token = tokens[0];
const fromAddress = coinbase;
const toAddress = addressWithoutFunds;
const preBalance = await zeroEx.token.getBalanceAsync(token.address, toAddress);
expect(preBalance).to.be.bignumber.equal(0);
- const transferAmount = new BigNumber(42);
await zeroEx.token.transferAsync(token.address, fromAddress, toAddress, transferAmount);
const postBalance = await zeroEx.token.getBalanceAsync(token.address, toAddress);
return expect(postBalance).to.be.bignumber.equal(transferAmount);
});
+ it('should fail to transfer tokens if fromAddress has an insufficient balance', async () => {
+ const fromAddress = addressWithoutFunds;
+ const toAddress = coinbase;
+ return expect(zeroEx.token.transferAsync(
+ token.address, fromAddress, toAddress, transferAmount,
+ )).to.be.rejectedWith(ZeroExError.INSUFFICIENT_BALANCE_FOR_TRANSFER);
+ });
it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => {
const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065';
const fromAddress = coinbase;
const toAddress = coinbase;
return expect(zeroEx.token.transferAsync(
- nonExistentTokenAddress, fromAddress, toAddress, new BigNumber(42),
+ nonExistentTokenAddress, fromAddress, toAddress, transferAmount,
)).to.be.rejectedWith(ZeroExError.CONTRACT_DOES_NOT_EXIST);
});
});