diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-08-10 06:59:29 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-08-10 07:12:42 +0800 |
commit | af52598d320462357d3ce40d37cf7de9a4f054ee (patch) | |
tree | c3d20ac2dd492167604a68828b0f75295ae6e801 /packages/order-utils | |
parent | cbe639866ec9d6088cc7aa133033d2735524c5a0 (diff) | |
download | dexon-sol-tools-af52598d320462357d3ce40d37cf7de9a4f054ee.tar dexon-sol-tools-af52598d320462357d3ce40d37cf7de9a4f054ee.tar.gz dexon-sol-tools-af52598d320462357d3ce40d37cf7de9a4f054ee.tar.bz2 dexon-sol-tools-af52598d320462357d3ce40d37cf7de9a4f054ee.tar.lz dexon-sol-tools-af52598d320462357d3ce40d37cf7de9a4f054ee.tar.xz dexon-sol-tools-af52598d320462357d3ce40d37cf7de9a4f054ee.tar.zst dexon-sol-tools-af52598d320462357d3ce40d37cf7de9a4f054ee.zip |
Update tests for optional feeRate
Diffstat (limited to 'packages/order-utils')
-rw-r--r-- | packages/order-utils/test/rate_utils_test.ts | 8 | ||||
-rw-r--r-- | packages/order-utils/test/sorting_utils_test.ts | 9 |
2 files changed, 14 insertions, 3 deletions
diff --git a/packages/order-utils/test/rate_utils_test.ts b/packages/order-utils/test/rate_utils_test.ts index 167a40465..b23a6467a 100644 --- a/packages/order-utils/test/rate_utils_test.ts +++ b/packages/order-utils/test/rate_utils_test.ts @@ -23,12 +23,18 @@ describe('rateUtils', () => { 'Expected feeRate: -1 to be greater than or equal to 0', ); }); - it('correctly calculates fee adjusted rate', async () => { + it('correctly calculates fee adjusted rate when feeRate is provided', async () => { const feeRate = new BigNumber(2); // ZRX costs 2 units of takerAsset per 1 unit of ZRX const feeAdjustedRate = rateUtils.getFeeAdjustedRateOfOrder(testOrder, feeRate); // the order actually takes 100 + (2 * 20) takerAsset units to fill 100 units of makerAsset expect(feeAdjustedRate).to.bignumber.equal(new BigNumber(1.4)); }); + it('correctly calculates fee adjusted rate when no feeRate is provided', async () => { + const feeAdjustedRate = rateUtils.getFeeAdjustedRateOfOrder(testOrder); + // because no feeRate was provided we just assume 0 fees + // the order actually takes 100 takerAsset units to fill 100 units of makerAsset + expect(feeAdjustedRate).to.bignumber.equal(new BigNumber(1)); + }); }); describe('#getFeeAdjustedRateOfFeeOrder', () => { it('throws when takerFee exceeds makerAssetAmount', async () => { diff --git a/packages/order-utils/test/sorting_utils_test.ts b/packages/order-utils/test/sorting_utils_test.ts index efce13d3f..5a33cb2ca 100644 --- a/packages/order-utils/test/sorting_utils_test.ts +++ b/packages/order-utils/test/sorting_utils_test.ts @@ -13,6 +13,7 @@ const expect = chai.expect; describe('sortingUtils', () => { describe('#sortOrdersByFeeAdjustedRate', () => { + const feeRate = new BigNumber(1); // ZRX costs 1 unit of takerAsset per 1 unit of ZRX // rate: 2 takerAsset / makerAsset const testOrder1 = testOrderFactory.generateTestSignedOrder({ makerAssetAmount: new BigNumber(100), @@ -29,8 +30,7 @@ describe('sortingUtils', () => { takerAssetAmount: new BigNumber(200), takerFee: new BigNumber(50), }); - it('correctly sorts by fee adjusted rate', async () => { - const feeRate = new BigNumber(1); // ZRX costs 1 unit of takerAsset per 1 unit of ZRX + it('correctly sorts by fee adjusted rate when feeRate is Provided', async () => { const orders = [testOrder1, testOrder2, testOrder3]; const sortedOrders = sortingUtils.sortOrdersByFeeAdjustedRate( [testOrder1, testOrder2, testOrder3], @@ -38,6 +38,11 @@ describe('sortingUtils', () => { ); expect(sortedOrders).to.deep.equal([testOrder2, testOrder1, testOrder3]); }); + it('correctly sorts by fee adjusted rate when no feeRate is Provided', async () => { + const orders = [testOrder1, testOrder2, testOrder3]; + const sortedOrders = sortingUtils.sortOrdersByFeeAdjustedRate([testOrder1, testOrder2, testOrder3]); + expect(sortedOrders).to.deep.equal([testOrder2, testOrder1, testOrder3]); + }); }); describe('#sortFeeOrdersByFeeAdjustedRate', () => { // rate: 200 takerAsset / makerAsset |