Add some test cases that stress slippageBufferAmount param
This commit is contained in:
		@@ -37,34 +37,43 @@ describe('marketUtils', () => {
 | 
				
			|||||||
            // generate remainingFillableMakerAssetAmounts that equal the makerAssetAmount
 | 
					            // generate remainingFillableMakerAssetAmounts that equal the makerAssetAmount
 | 
				
			||||||
            const remainingFillableMakerAssetAmounts = [makerAssetAmount, makerAssetAmount, makerAssetAmount];
 | 
					            const remainingFillableMakerAssetAmounts = [makerAssetAmount, makerAssetAmount, makerAssetAmount];
 | 
				
			||||||
            it('returns input orders and zero remainingFillAmount when input exactly matches requested fill amount', async () => {
 | 
					            it('returns input orders and zero remainingFillAmount when input exactly matches requested fill amount', async () => {
 | 
				
			||||||
                // try to fill 30 units of makerAsset
 | 
					                // try to fill 20 units of makerAsset
 | 
				
			||||||
                const fillAmount = new BigNumber(30);
 | 
					                // include 10 units of slippageBufferAmount
 | 
				
			||||||
 | 
					                const fillAmount = new BigNumber(20);
 | 
				
			||||||
 | 
					                const slippageBufferAmount = new BigNumber(10);
 | 
				
			||||||
                const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(
 | 
					                const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(
 | 
				
			||||||
                    inputOrders,
 | 
					                    inputOrders,
 | 
				
			||||||
                    remainingFillableMakerAssetAmounts,
 | 
					                    remainingFillableMakerAssetAmounts,
 | 
				
			||||||
                    fillAmount,
 | 
					                    fillAmount,
 | 
				
			||||||
 | 
					                    slippageBufferAmount,
 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
                expect(resultOrders).to.be.deep.equal(inputOrders);
 | 
					                expect(resultOrders).to.be.deep.equal(inputOrders);
 | 
				
			||||||
                expect(remainingFillAmount).to.be.bignumber.equal(constants.ZERO_AMOUNT);
 | 
					                expect(remainingFillAmount).to.be.bignumber.equal(constants.ZERO_AMOUNT);
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
            it('returns input orders and zero remainingFillAmount when input has more than requested fill amount', async () => {
 | 
					            it('returns input orders and zero remainingFillAmount when input has more than requested fill amount', async () => {
 | 
				
			||||||
                // try to fill 25 units of makerAsset
 | 
					                // try to fill 15 units of makerAsset
 | 
				
			||||||
                const fillAmount = new BigNumber(25);
 | 
					                // include 10 units of slippageBufferAmount
 | 
				
			||||||
 | 
					                const fillAmount = new BigNumber(15);
 | 
				
			||||||
 | 
					                const slippageBufferAmount = new BigNumber(10);
 | 
				
			||||||
                const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(
 | 
					                const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(
 | 
				
			||||||
                    inputOrders,
 | 
					                    inputOrders,
 | 
				
			||||||
                    remainingFillableMakerAssetAmounts,
 | 
					                    remainingFillableMakerAssetAmounts,
 | 
				
			||||||
                    fillAmount,
 | 
					                    fillAmount,
 | 
				
			||||||
 | 
					                    slippageBufferAmount,
 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
                expect(resultOrders).to.be.deep.equal(inputOrders);
 | 
					                expect(resultOrders).to.be.deep.equal(inputOrders);
 | 
				
			||||||
                expect(remainingFillAmount).to.be.bignumber.equal(constants.ZERO_AMOUNT);
 | 
					                expect(remainingFillAmount).to.be.bignumber.equal(constants.ZERO_AMOUNT);
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
            it('returns input orders and non-zero remainingFillAmount when input has less than requested fill amount', async () => {
 | 
					            it('returns input orders and non-zero remainingFillAmount when input has less than requested fill amount', async () => {
 | 
				
			||||||
                // try to fill 35 units of makerAsset
 | 
					                // try to fill 30 units of makerAsset
 | 
				
			||||||
                const fillAmount = new BigNumber(35);
 | 
					                // include 5 units of slippageBufferAmount
 | 
				
			||||||
 | 
					                const fillAmount = new BigNumber(30);
 | 
				
			||||||
 | 
					                const slippageBufferAmount = new BigNumber(5);
 | 
				
			||||||
                const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(
 | 
					                const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(
 | 
				
			||||||
                    inputOrders,
 | 
					                    inputOrders,
 | 
				
			||||||
                    remainingFillableMakerAssetAmounts,
 | 
					                    remainingFillableMakerAssetAmounts,
 | 
				
			||||||
                    fillAmount,
 | 
					                    fillAmount,
 | 
				
			||||||
 | 
					                    slippageBufferAmount,
 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
                expect(resultOrders).to.be.deep.equal(inputOrders);
 | 
					                expect(resultOrders).to.be.deep.equal(inputOrders);
 | 
				
			||||||
                expect(remainingFillAmount).to.be.bignumber.equal(new BigNumber(5));
 | 
					                expect(remainingFillAmount).to.be.bignumber.equal(new BigNumber(5));
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user