aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/test
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2019-01-11 06:00:16 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2019-01-11 06:00:16 +0800
commit2360b8282fe40e1c1b1336b17872b5699bde610e (patch)
treeb5965d3ef0fe24645e7e9beaae71e71d2999f8b4 /packages/asset-buyer/test
parent0dade8624c0935a26bed9b9c53a94a8211dabdee (diff)
downloaddexon-sol-tools-2360b8282fe40e1c1b1336b17872b5699bde610e.tar.gz
dexon-sol-tools-2360b8282fe40e1c1b1336b17872b5699bde610e.tar.zst
dexon-sol-tools-2360b8282fe40e1c1b1336b17872b5699bde610e.zip
rename tokensAvailableInUnitAmount to tokensAvailableInBaseUnits and use test helpers
Diffstat (limited to 'packages/asset-buyer/test')
-rw-r--r--packages/asset-buyer/test/asset_buyer_test.ts51
1 files changed, 24 insertions, 27 deletions
diff --git a/packages/asset-buyer/test/asset_buyer_test.ts b/packages/asset-buyer/test/asset_buyer_test.ts
index fd31b9843..5e05d5564 100644
--- a/packages/asset-buyer/test/asset_buyer_test.ts
+++ b/packages/asset-buyer/test/asset_buyer_test.ts
@@ -81,7 +81,7 @@ describe('AssetBuyer', () => {
const assetBuyer = new AssetBuyer(mockWeb3Provider.object, mockOrderProvider.object);
const liquidityResult = await assetBuyer.getLiquidityForAssetDataAsync(FAKE_ASSET_DATA);
expect(liquidityResult).to.deep.equal({
- tokensAvailableInUnitAmount: 0,
+ tokensAvailableInBaseUnits: 0,
ethValueAvailableInWei: 0,
});
});
@@ -106,41 +106,38 @@ describe('AssetBuyer', () => {
orders: [],
remainingFillableMakerAssetAmounts: [],
};
- const mockedAssetBuyer = mockedAssetBuyerWithOrdersAndFillableAmounts(
+ const expectedResult = {
+ tokensAvailableInBaseUnits: 0,
+ ethValueAvailableInWei: 0,
+ };
+ await expectLiquidityResult(
mockWeb3Provider.object,
mockOrderProvider.object,
- FAKE_ASSET_DATA,
ordersAndFillableAmounts,
+ expectedResult,
);
-
- const liquidityResult = await mockedAssetBuyer.object.getLiquidityForAssetDataAsync(FAKE_ASSET_DATA);
- expect(liquidityResult).to.deep.equal({
- tokensAvailableInUnitAmount: 0,
- ethValueAvailableInWei: 0,
- });
});
it('should return correct computed value when orders provided with full fillableAmounts', async () => {
const orders: SignedOrder[] = [sellTwoTokensFor1Weth, sellTenTokensFor10Weth];
- const remainingFillableMakerAssetAmounts: BigNumber[] = orders.map(o => o.makerAssetAmount);
- const mockedAssetBuyer = mockedAssetBuyerWithOrdersAndFillableAmounts(
- mockWeb3Provider.object,
- mockOrderProvider.object,
- FAKE_ASSET_DATA,
- {
- orders,
- remainingFillableMakerAssetAmounts,
- },
- );
+ const ordersAndFillableAmounts = {
+ orders: [sellTwoTokensFor1Weth, sellTenTokensFor10Weth],
+ remainingFillableMakerAssetAmounts: orders.map(o => o.makerAssetAmount),
+ };
const expectedTokensAvailable = orders[0].makerAssetAmount.plus(orders[1].makerAssetAmount);
const expectedEthValueAvailable = orders[0].takerAssetAmount.plus(orders[1].takerAssetAmount);
-
- const liquidityResult = await mockedAssetBuyer.object.getLiquidityForAssetDataAsync(FAKE_ASSET_DATA);
- expect(liquidityResult).to.deep.equal({
- tokensAvailableInUnitAmount: expectedTokensAvailable.toNumber(),
+ const expectedResult = {
+ tokensAvailableInBaseUnits: expectedTokensAvailable.toNumber(),
ethValueAvailableInWei: expectedEthValueAvailable.toNumber(),
- });
+ };
+
+ await expectLiquidityResult(
+ mockWeb3Provider.object,
+ mockOrderProvider.object,
+ ordersAndFillableAmounts,
+ expectedResult,
+ );
});
it('should return correct computed value with one partial fillableAmounts', async () => {
@@ -149,7 +146,7 @@ describe('AssetBuyer', () => {
remainingFillableMakerAssetAmounts: [baseUnitAmount(1)],
};
const expectedResult = {
- tokensAvailableInUnitAmount: baseUnitAmount(1).toNumber(),
+ tokensAvailableInBaseUnits: baseUnitAmount(1).toNumber(),
ethValueAvailableInWei: baseUnitAmount(0.5, WETH_DECIMALS).toNumber(),
};
@@ -167,7 +164,7 @@ describe('AssetBuyer', () => {
remainingFillableMakerAssetAmounts: [baseUnitAmount(1), baseUnitAmount(3)],
};
const expectedResult = {
- tokensAvailableInUnitAmount: baseUnitAmount(4).toNumber(),
+ tokensAvailableInBaseUnits: baseUnitAmount(4).toNumber(),
ethValueAvailableInWei: baseUnitAmount(3.5, WETH_DECIMALS).toNumber(),
};
@@ -185,7 +182,7 @@ describe('AssetBuyer', () => {
remainingFillableMakerAssetAmounts: [baseUnitAmount(0), baseUnitAmount(0)],
};
const expectedResult = {
- tokensAvailableInUnitAmount: baseUnitAmount(0).toNumber(),
+ tokensAvailableInBaseUnits: baseUnitAmount(0).toNumber(),
ethValueAvailableInWei: baseUnitAmount(0, WETH_DECIMALS).toNumber(),
};