aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2019-01-11 05:51:02 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2019-01-11 05:51:02 +0800
commit0dade8624c0935a26bed9b9c53a94a8211dabdee (patch)
tree3b96234f3fba2831af319bb3b76a5405d606d953 /packages/asset-buyer
parenta9fad77eb4375439767f9aa1fcbfa12716f41ed3 (diff)
downloaddexon-sol-tools-0dade8624c0935a26bed9b9c53a94a8211dabdee.tar
dexon-sol-tools-0dade8624c0935a26bed9b9c53a94a8211dabdee.tar.gz
dexon-sol-tools-0dade8624c0935a26bed9b9c53a94a8211dabdee.tar.bz2
dexon-sol-tools-0dade8624c0935a26bed9b9c53a94a8211dabdee.tar.lz
dexon-sol-tools-0dade8624c0935a26bed9b9c53a94a8211dabdee.tar.xz
dexon-sol-tools-0dade8624c0935a26bed9b9c53a94a8211dabdee.tar.zst
dexon-sol-tools-0dade8624c0935a26bed9b9c53a94a8211dabdee.zip
Adding more test coverage
Diffstat (limited to 'packages/asset-buyer')
-rw-r--r--packages/asset-buyer/test/asset_buyer_test.ts41
1 files changed, 37 insertions, 4 deletions
diff --git a/packages/asset-buyer/test/asset_buyer_test.ts b/packages/asset-buyer/test/asset_buyer_test.ts
index a109d1ae8..fd31b9843 100644
--- a/packages/asset-buyer/test/asset_buyer_test.ts
+++ b/packages/asset-buyer/test/asset_buyer_test.ts
@@ -46,6 +46,7 @@ const expectLiquidityResult = async (
expect(liquidityResult).to.deep.equal(expectedLiquidityResult);
};
+// tslint:disable:custom-no-magic-numbers
describe('AssetBuyer', () => {
describe('getLiquidityForAssetDataAsync', () => {
const mockWeb3Provider = TypeMoq.Mock.ofType(Web3ProviderEngine);
@@ -92,9 +93,7 @@ describe('AssetBuyer', () => {
takerAssetAmount: baseUnitAmount(1, WETH_DECIMALS),
});
const sellTenTokensFor10Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
- // tslint:disable-next-line:custom-no-magic-numbers
makerAssetAmount: baseUnitAmount(10),
- // tslint:disable-next-line:custom-no-magic-numbers
takerAssetAmount: baseUnitAmount(10, WETH_DECIMALS),
});
@@ -149,10 +148,8 @@ describe('AssetBuyer', () => {
orders: [sellTwoTokensFor1Weth],
remainingFillableMakerAssetAmounts: [baseUnitAmount(1)],
};
-
const expectedResult = {
tokensAvailableInUnitAmount: baseUnitAmount(1).toNumber(),
- // tslint:disable-next-line:custom-no-magic-numbers
ethValueAvailableInWei: baseUnitAmount(0.5, WETH_DECIMALS).toNumber(),
};
@@ -163,6 +160,42 @@ describe('AssetBuyer', () => {
expectedResult,
);
});
+
+ it('should return correct computed value with multiple orders and fillable amounts', async () => {
+ const ordersAndFillableAmounts = {
+ orders: [sellTwoTokensFor1Weth, sellTenTokensFor10Weth],
+ remainingFillableMakerAssetAmounts: [baseUnitAmount(1), baseUnitAmount(3)],
+ };
+ const expectedResult = {
+ tokensAvailableInUnitAmount: baseUnitAmount(4).toNumber(),
+ ethValueAvailableInWei: baseUnitAmount(3.5, WETH_DECIMALS).toNumber(),
+ };
+
+ await expectLiquidityResult(
+ mockWeb3Provider.object,
+ mockOrderProvider.object,
+ ordersAndFillableAmounts,
+ expectedResult,
+ );
+ });
+
+ it('should return 0s when no amounts fillable', async () => {
+ const ordersAndFillableAmounts = {
+ orders: [sellTwoTokensFor1Weth, sellTenTokensFor10Weth],
+ remainingFillableMakerAssetAmounts: [baseUnitAmount(0), baseUnitAmount(0)],
+ };
+ const expectedResult = {
+ tokensAvailableInUnitAmount: baseUnitAmount(0).toNumber(),
+ ethValueAvailableInWei: baseUnitAmount(0, WETH_DECIMALS).toNumber(),
+ };
+
+ await expectLiquidityResult(
+ mockWeb3Provider.object,
+ mockOrderProvider.object,
+ ordersAndFillableAmounts,
+ expectedResult,
+ );
+ });
});
});
});