diff options
author | Fabio Berger <me@fabioberger.com> | 2017-05-30 22:31:02 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-05-30 22:31:02 +0800 |
commit | 8df2926a1acf698f469deaf03a0de35e2179ddf2 (patch) | |
tree | 7da00b243eb4fe1830b96a04672511181628c13e /test/token_wrapper_test.ts | |
parent | 141d23f78afc822023f59a4b4dce175a8ba7cffd (diff) | |
download | dexon-0x-contracts-8df2926a1acf698f469deaf03a0de35e2179ddf2.tar.gz dexon-0x-contracts-8df2926a1acf698f469deaf03a0de35e2179ddf2.tar.zst dexon-0x-contracts-8df2926a1acf698f469deaf03a0de35e2179ddf2.zip |
Add test for setProxyAllowanceAsync and additional test for getProxyAllowanceAsync
Diffstat (limited to 'test/token_wrapper_test.ts')
-rw-r--r-- | test/token_wrapper_test.ts | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/test/token_wrapper_test.ts b/test/token_wrapper_test.ts index c9cd08028..3a1a3c3a5 100644 --- a/test/token_wrapper_test.ts +++ b/test/token_wrapper_test.ts @@ -53,12 +53,42 @@ describe('TokenWrapper', () => { }); }); describe('#getProxyAllowanceAsync', () => { + it('should get the proxy allowance', async () => { + const aToken = tokens[0]; + const aOwnerAddress = userAddresses[0]; + + const amountInUnits = new BigNumber('50'); + const amountInBaseUnits = ZeroEx.toBaseUnitAmount(amountInUnits, aToken.decimals); + await zeroEx.token.setProxyAllowanceAsync(aToken.address, aOwnerAddress, amountInBaseUnits); + + const allowance = await zeroEx.token.getProxyAllowanceAsync(aToken.address, aOwnerAddress); + const expectedAllowance = amountInBaseUnits; + expect(allowance).to.be.bignumber.equal(expectedAllowance); + }); it('should return 0 if no allowance set yet', async () => { const aToken = tokens[0]; - const aOwner = userAddresses[0]; - const allowance = await zeroEx.token.getProxyAllowanceAsync(aToken.address, aOwner); + const aOwnerAddress = userAddresses[0]; + const allowance = await zeroEx.token.getProxyAllowanceAsync(aToken.address, aOwnerAddress); const expectedAllowance = new BigNumber('0'); expect(allowance).to.be.bignumber.equal(expectedAllowance); }); }); + describe('#setProxyAllowanceAsync', () => { + it('should set the proxy allowance', async () => { + const aToken = tokens[0]; + const aOwnerAddress = userAddresses[0]; + + const allowanceBeforeSet = await zeroEx.token.getProxyAllowanceAsync(aToken.address, aOwnerAddress); + const expectedAllowanceBeforeAllowanceSet = new BigNumber('0'); + expect(allowanceBeforeSet).to.be.bignumber.equal(expectedAllowanceBeforeAllowanceSet); + + const amountInUnits = new BigNumber('50'); + const amountInBaseUnits = ZeroEx.toBaseUnitAmount(amountInUnits, aToken.decimals); + await zeroEx.token.setProxyAllowanceAsync(aToken.address, aOwnerAddress, amountInBaseUnits); + + const allowanceAfterSet = await zeroEx.token.getProxyAllowanceAsync(aToken.address, aOwnerAddress); + const expectedAllowanceAfterAllowanceSet = amountInBaseUnits; + expect(allowanceAfterSet).to.be.bignumber.equal(expectedAllowanceAfterAllowanceSet); + }); + }); }); |