diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-12-08 10:01:16 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-12-19 05:36:05 +0800 |
commit | 1883f4d2726e1a879be42b7bb6168f30afd486d9 (patch) | |
tree | cdd18457f922c8fbcd9f43d030b73bdcc369c137 | |
parent | 93b9c251ed735905d30a0daa4d90fc27c8625aa6 (diff) | |
download | dexon-sol-tools-1883f4d2726e1a879be42b7bb6168f30afd486d9.tar dexon-sol-tools-1883f4d2726e1a879be42b7bb6168f30afd486d9.tar.gz dexon-sol-tools-1883f4d2726e1a879be42b7bb6168f30afd486d9.tar.bz2 dexon-sol-tools-1883f4d2726e1a879be42b7bb6168f30afd486d9.tar.lz dexon-sol-tools-1883f4d2726e1a879be42b7bb6168f30afd486d9.tar.xz dexon-sol-tools-1883f4d2726e1a879be42b7bb6168f30afd486d9.tar.zst dexon-sol-tools-1883f4d2726e1a879be42b7bb6168f30afd486d9.zip |
matchOrders test cases for balance threshold filter contract
-rw-r--r-- | packages/contracts/contracts/extensions/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol | 4 | ||||
-rw-r--r-- | packages/contracts/test/extensions/balance_threshold_filter.ts | 44 |
2 files changed, 45 insertions, 3 deletions
diff --git a/packages/contracts/contracts/extensions/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol b/packages/contracts/contracts/extensions/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol index 303e1d9c2..0ad8ccddf 100644 --- a/packages/contracts/contracts/extensions/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol +++ b/packages/contracts/contracts/extensions/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol @@ -258,7 +258,7 @@ contract MixinBalanceThresholdFilterCore is MBalanceThresholdFilterCore { // This is to avoid corruption when making calls in the loop below. let freeMemPtr := addressesToValidateElementEndPtr mstore(0x40, freeMemPtr) -/* + // Validate addresses let thresholdAssetAddress := sload(THRESHOLD_ASSET_slot) let thresholdBalance := sload(THRESHOLD_BALANCE_slot) @@ -307,7 +307,7 @@ contract MixinBalanceThresholdFilterCore is MBalanceThresholdFilterCore { // 64 -- strlen(AT_LEAST_ONE_ADDRESS_DOES_NOT_MEET_BALANCE_THRESHOLD) rounded up to nearest 32-byte word. revert(0, 132) } - }*/ + } // Record validated addresses validatedAddresses := addressesToValidate diff --git a/packages/contracts/test/extensions/balance_threshold_filter.ts b/packages/contracts/test/extensions/balance_threshold_filter.ts index 7ca8a8e98..0a03678b1 100644 --- a/packages/contracts/test/extensions/balance_threshold_filter.ts +++ b/packages/contracts/test/extensions/balance_threshold_filter.ts @@ -1225,7 +1225,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => { compliantSignedOrder = await orderFactory.newSignedOrderAsync(); compliantSignedOrder2 = await orderFactory2.newSignedOrderAsync(); }); - it.only('Should transfer correct amounts when both makers and taker meet the balance threshold', async () => { + it('Should transfer correct amounts when both makers and taker meet the balance threshold', async () => { // Test values/results taken from Match Orders test: // 'Should transfer correct amounts when right order is fully filled and values pass isRoundingErrorFloor but fail isRoundingErrorCeil' // Create orders to match @@ -1309,6 +1309,48 @@ describe.only(ContractName.BalanceThresholdFilter, () => { erc20Balances[feeRecipientAddress][zrxToken.address].add(expectedTransferAmounts.feePaidByLeftMaker).add(expectedTransferAmounts.feePaidByRightMaker).add(expectedTransferAmounts.feePaidByTakerLeft).add(expectedTransferAmounts.feePaidByTakerRight), ); }); + it('should revert if left maker does not meet the balance threshold', async () => { + // Create signed order with non-compliant maker address + const signedOrderWithBadMakerAddress = await orderFactory.newSignedOrderAsync({ + senderAddress: compliantForwarderInstance.address, + makerAddress: nonCompliantAddress + }); + // Execute transaction + return expectTransactionFailedAsync( + balanceThresholdWrapper.matchOrdersAsync( + compliantSignedOrder, + signedOrderWithBadMakerAddress, + compliantTakerAddress, + ), + RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold + ); + }); + it('should revert if right maker does not meet the balance threshold', async () => { + // Create signed order with non-compliant maker address + const signedOrderWithBadMakerAddress = await orderFactory.newSignedOrderAsync({ + senderAddress: compliantForwarderInstance.address, + makerAddress: nonCompliantAddress + }); + // Execute transaction + return expectTransactionFailedAsync( + balanceThresholdWrapper.matchOrdersAsync( + signedOrderWithBadMakerAddress, + compliantSignedOrder, + compliantTakerAddress, + ), + RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold + ); + }); + it('should revert if taker does not meet the balance threshold', async () => { + return expectTransactionFailedAsync( + nonCompliantBalanceThresholdWrapper.matchOrdersAsync( + compliantSignedOrder, + compliantSignedOrder, + nonCompliantAddress, + ), + RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold + ); + }); }); describe('cancelOrder', () => { |