diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2019-01-12 00:14:57 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2019-01-12 00:14:57 +0800 |
commit | 742e5e039dd4e821209b5511fb6a194d11c6291c (patch) | |
tree | e7a5babe944632f4ec6c0d60fc39ace6d985ce4f /packages/asset-buyer/test | |
parent | 119231451013b37059327a676963a0931d7ed093 (diff) | |
download | dexon-sol-tools-742e5e039dd4e821209b5511fb6a194d11c6291c.tar.gz dexon-sol-tools-742e5e039dd4e821209b5511fb6a194d11c6291c.tar.zst dexon-sol-tools-742e5e039dd4e821209b5511fb6a194d11c6291c.zip |
getLiquidityForAssetDataAsync helper method, and fix to assetBuyer to check for eth token in asset pairs
Diffstat (limited to 'packages/asset-buyer/test')
-rw-r--r-- | packages/asset-buyer/test/asset_buyer_test.ts | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/packages/asset-buyer/test/asset_buyer_test.ts b/packages/asset-buyer/test/asset_buyer_test.ts index 5e05d5564..9ed51f5e5 100644 --- a/packages/asset-buyer/test/asset_buyer_test.ts +++ b/packages/asset-buyer/test/asset_buyer_test.ts @@ -24,6 +24,8 @@ const expect = chai.expect; const FAKE_SRA_URL = 'https://fakeurl.com'; const FAKE_ASSET_DATA = '0xf47261b00000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c48'; const TOKEN_DECIMALS = 18; +const DAI_ASSET_DATA = '0xf47261b000000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359"'; +const WETH_ASSET_DATA = '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; const WETH_DECIMALS = constants.ETHER_TOKEN_DECIMALS; const baseUnitAmount = (unitAmount: number, decimals = TOKEN_DECIMALS): BigNumber => { @@ -75,14 +77,26 @@ describe('AssetBuyer', () => { }); }); - it('should return 0s when asset pair not supported', async () => { - mockAvailableAssetDatas(mockOrderProvider, FAKE_ASSET_DATA, []); + describe('asset pair not supported', () => { + it('should return 0s when no asset pair not supported', async () => { + mockAvailableAssetDatas(mockOrderProvider, FAKE_ASSET_DATA, []); - const assetBuyer = new AssetBuyer(mockWeb3Provider.object, mockOrderProvider.object); - const liquidityResult = await assetBuyer.getLiquidityForAssetDataAsync(FAKE_ASSET_DATA); - expect(liquidityResult).to.deep.equal({ - tokensAvailableInBaseUnits: 0, - ethValueAvailableInWei: 0, + const assetBuyer = new AssetBuyer(mockWeb3Provider.object, mockOrderProvider.object); + const liquidityResult = await assetBuyer.getLiquidityForAssetDataAsync(FAKE_ASSET_DATA); + expect(liquidityResult).to.deep.equal({ + tokensAvailableInBaseUnits: 0, + ethValueAvailableInWei: 0, + }); + }); + it('should return 0s when only other asset pair supported', async () => { + mockAvailableAssetDatas(mockOrderProvider, FAKE_ASSET_DATA, [DAI_ASSET_DATA]); + + const assetBuyer = new AssetBuyer(mockWeb3Provider.object, mockOrderProvider.object); + const liquidityResult = await assetBuyer.getLiquidityForAssetDataAsync(FAKE_ASSET_DATA); + expect(liquidityResult).to.deep.equal({ + tokensAvailableInBaseUnits: 0, + ethValueAvailableInWei: 0, + }); }); }); @@ -98,7 +112,7 @@ describe('AssetBuyer', () => { }); beforeEach(() => { - mockAvailableAssetDatas(mockOrderProvider, FAKE_ASSET_DATA, [FAKE_ASSET_DATA]); + mockAvailableAssetDatas(mockOrderProvider, FAKE_ASSET_DATA, [WETH_ASSET_DATA]); }); it('should return 0s when no orders available', async () => { |