diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-05-31 08:52:37 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-05-31 08:52:37 +0800 |
commit | 79e7c44884f81f12733d555314c54d4c912f0e88 (patch) | |
tree | 5d80666f6521737879e2e700afd5ef1d1a55b0e6 /packages/contracts/test/exchange/transactions.ts | |
parent | 1382c1243a421a5ad9e53ede491782cf22de0a5e (diff) | |
download | dexon-sol-tools-79e7c44884f81f12733d555314c54d4c912f0e88.tar.gz dexon-sol-tools-79e7c44884f81f12733d555314c54d4c912f0e88.tar.zst dexon-sol-tools-79e7c44884f81f12733d555314c54d4c912f0e88.zip |
Check length before accessing indices, add awaitTransactionSuccess where needed, and rename function
Diffstat (limited to 'packages/contracts/test/exchange/transactions.ts')
-rw-r--r-- | packages/contracts/test/exchange/transactions.ts | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts index 2b2236e2e..6b3083ae5 100644 --- a/packages/contracts/test/exchange/transactions.ts +++ b/packages/contracts/test/exchange/transactions.ts @@ -220,9 +220,11 @@ describe('Exchange transactions', () => { exchange.address, ); const isApproved = true; - await exchange.approveSignatureValidator.sendTransactionAsync(whitelist.address, isApproved, { - from: takerAddress, - }); + await web3Wrapper.awaitTransactionSuccessAsync( + await exchange.approveSignatureValidator.sendTransactionAsync(whitelist.address, isApproved, { + from: takerAddress, + }), + ); const defaultOrderParams = { ...constants.STATIC_ORDER_PARAMS, senderAddress: whitelist.address, @@ -242,7 +244,9 @@ describe('Exchange transactions', () => { it('should revert if maker has not been whitelisted', async () => { const isApproved = true; - await whitelist.updateWhitelistStatus.sendTransactionAsync(takerAddress, isApproved, { from: owner }); + await web3Wrapper.awaitTransactionSuccessAsync( + await whitelist.updateWhitelistStatus.sendTransactionAsync(takerAddress, isApproved, { from: owner }), + ); const orderStruct = orderUtils.getOrderStruct(signedOrder); const takerAssetFillAmount = signedOrder.takerAssetAmount; @@ -260,7 +264,9 @@ describe('Exchange transactions', () => { it('should revert if taker has not been whitelisted', async () => { const isApproved = true; - await whitelist.updateWhitelistStatus.sendTransactionAsync(makerAddress, isApproved, { from: owner }); + await web3Wrapper.awaitTransactionSuccessAsync( + await whitelist.updateWhitelistStatus.sendTransactionAsync(makerAddress, isApproved, { from: owner }), + ); const orderStruct = orderUtils.getOrderStruct(signedOrder); const takerAssetFillAmount = signedOrder.takerAssetAmount; @@ -278,19 +284,27 @@ describe('Exchange transactions', () => { it('should fill the order if maker and taker have been whitelisted', async () => { const isApproved = true; - await whitelist.updateWhitelistStatus.sendTransactionAsync(makerAddress, isApproved, { from: owner }); - await whitelist.updateWhitelistStatus.sendTransactionAsync(takerAddress, isApproved, { from: owner }); + await web3Wrapper.awaitTransactionSuccessAsync( + await whitelist.updateWhitelistStatus.sendTransactionAsync(makerAddress, isApproved, { from: owner }), + ); + + await web3Wrapper.awaitTransactionSuccessAsync( + await whitelist.updateWhitelistStatus.sendTransactionAsync(takerAddress, isApproved, { from: owner }), + ); const orderStruct = orderUtils.getOrderStruct(signedOrder); const takerAssetFillAmount = signedOrder.takerAssetAmount; const salt = generatePseudoRandomSalt(); - await whitelist.fillOrderIfWhitelisted.sendTransactionAsync( - orderStruct, - takerAssetFillAmount, - salt, - signedOrder.signature, - { from: takerAddress }, + await web3Wrapper.awaitTransactionSuccessAsync( + await whitelist.fillOrderIfWhitelisted.sendTransactionAsync( + orderStruct, + takerAssetFillAmount, + salt, + signedOrder.signature, + { from: takerAddress }, + ), ); + const newBalances = await erc20Wrapper.getBalancesAsync(); const makerAssetFillAmount = signedOrder.makerAssetAmount; |