diff options
Diffstat (limited to 'packages')
6 files changed, 19 insertions, 41 deletions
diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts index 7783af876..e8b82f0b2 100644 --- a/packages/connect/src/http_client.ts +++ b/packages/connect/src/http_client.ts @@ -11,6 +11,7 @@ import { AssetPairsRequestOpts, AssetPairsResponse, Client, + FeeRecipientsResponse, HttpRequestOptions, HttpRequestType, OrderbookRequest, @@ -20,8 +21,6 @@ import { OrdersRequestOpts, OrdersResponse, PagedRequestOpts, - PaginatedCollection, - FeeRecipientsResponse, } from './types'; import { relayerResponseJsonParsers } from './utils/relayer_response_json_parsers'; diff --git a/packages/connect/test/fixtures/standard_relayer_api/asset_pairs.ts b/packages/connect/test/fixtures/standard_relayer_api/asset_pairs.ts index 8fc6435ec..5ce703317 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/asset_pairs.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/asset_pairs.ts @@ -22,4 +22,4 @@ export const assetDataPairsResponse: AssetPairsResponse = { }, }, ], -};
\ No newline at end of file +}; diff --git a/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts b/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts index 84ea4cd6c..9da2703df 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts @@ -1,4 +1,3 @@ -import { BigNumber } from '@0xproject/utils'; import { FeeRecipientsResponse } from '../../../src/types'; @@ -11,4 +10,4 @@ export const feeRecipientsResponse: FeeRecipientsResponse = { '0x9e56625509c2f60af937f23b7b532600390e8c8b', '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', ], -};
\ No newline at end of file +}; diff --git a/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts b/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts index d4f056d3e..c8a669b3b 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts @@ -1,6 +1,6 @@ import { BigNumber } from '@0xproject/utils'; -export const apiOrderResponse = { +export const orderResponse = { order: { makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b', takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts index 866cf7b2f..fc5d01706 100644 --- a/packages/connect/test/http_client_test.ts +++ b/packages/connect/test/http_client_test.ts @@ -7,12 +7,12 @@ import 'mocha'; import { HttpClient } from '../src/index'; -import { assetDataPairsResponse } from './fixtures/standard_relayer_api/assetData_pairs'; -import * as assetDataPairsResponseJSON from './fixtures/standard_relayer_api/assetData_pairs.json'; -import { feesResponse } from './fixtures/standard_relayer_api/fees'; -import * as feesResponseJSON from './fixtures/standard_relayer_api/fees.json'; +import { assetDataPairsResponse } from './fixtures/standard_relayer_api/asset_pairs'; +import * as assetDataPairsResponseJSON from './fixtures/standard_relayer_api/asset_pairs.json'; import { orderResponse } from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f'; import * as orderResponseJSON from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json'; +import { orderConfigResponse } from './fixtures/standard_relayer_api/order_config'; +import * as orderConfigResponseJSON from './fixtures/standard_relayer_api/order_config.json'; import { orderbookResponse } from './fixtures/standard_relayer_api/orderbook'; import * as orderbookJSON from './fixtures/standard_relayer_api/orderbook.json'; import { ordersResponse } from './fixtures/standard_relayer_api/orders'; @@ -39,7 +39,7 @@ describe('HttpClient', () => { }); }); describe('#getAssetPairsAsync', () => { - const url = `${relayUrl}/assetData_pairs`; + const url = `${relayUrl}/asset_pairs`; it('gets assetData pairs with default options when none are provided', async () => { const urlWithQuery = `${url}?page=1&per_page=100`; fetchMock.get(urlWithQuery, assetDataPairsResponseJSON); @@ -134,32 +134,29 @@ describe('HttpClient', () => { }); describe('#getOrderConfigAsync', () => { const request = { + makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b', + takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', + makerAssetAmount: '10000000000000000', + takerAssetAmount: '20000000000000000', + expirationTimeSeconds: '1532560590', + makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', + takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990', exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', - maker: '0x9e56625509c2f60af937f23b7b532600390e8c8b', - taker: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', - makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', - makerAssetAmount: new BigNumber('10000000000000000000'), - takerAssetAmount: new BigNumber('30000000000000000000'), - salt: new BigNumber('256'), - expirationTimeSeconds: new BigNumber('42'), }; const url = `${relayUrl}/fees`; it('gets fees', async () => { - fetchMock.post(url, feesResponseJSON); + fetchMock.post(url, orderConfigResponseJSON); const fees = await relayerClient.getOrderConfigAsync(request); - expect(fees).to.be.deep.equal(feesResponse); + expect(fees).to.be.deep.equal(orderConfigResponse); }); it('does not mutate input', async () => { - fetchMock.post(url, feesResponseJSON); + fetchMock.post(url, orderConfigResponseJSON); const makerAssetAmountBefore = new BigNumber(request.makerAssetAmount); const takerAssetAmountBefore = new BigNumber(request.takerAssetAmount); - const saltBefore = new BigNumber(request.salt); const expirationTimeSecondsBefore = new BigNumber(request.expirationTimeSeconds); await relayerClient.getOrderConfigAsync(request); expect(makerAssetAmountBefore).to.be.deep.equal(request.makerAssetAmount); expect(takerAssetAmountBefore).to.be.deep.equal(request.takerAssetAmount); - expect(saltBefore).to.be.deep.equal(request.salt); expect(expirationTimeSecondsBefore).to.be.deep.equal(request.expirationTimeSeconds); }); it('throws an error for invalid JSON response', async () => { diff --git a/packages/connect/test/orderbook_channel_message_parsers_test.ts b/packages/connect/test/orderbook_channel_message_parsers_test.ts index 9960ad1df..b5a91330d 100644 --- a/packages/connect/test/orderbook_channel_message_parsers_test.ts +++ b/packages/connect/test/orderbook_channel_message_parsers_test.ts @@ -5,11 +5,6 @@ import 'mocha'; import { ordersChannelMessageParser } from '../src/utils/orderbook_channel_message_parser'; import { orderResponse } from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f'; -import { orderbookResponse } from './fixtures/standard_relayer_api/orderbook'; -import { - malformedSnapshotOrdersChannelMessage, - snapshotOrdersChannelMessage, -} from './fixtures/standard_relayer_api/snapshot_orderbook_channel_message'; import { unknownOrdersChannelMessage } from './fixtures/standard_relayer_api/unknown_orderbook_channel_message'; import { malformedUpdateOrdersChannelMessage, @@ -22,11 +17,6 @@ const expect = chai.expect; describe('ordersChannelMessageParser', () => { describe('#parser', () => { - it('parses snapshot messages', () => { - const snapshotMessage = ordersChannelMessageParser.parse(snapshotOrdersChannelMessage); - expect(snapshotMessage.type).to.be.equal('snapshot'); - expect(snapshotMessage.payload).to.be.deep.equal(orderbookResponse); - }); it('parses update messages', () => { const updateMessage = ordersChannelMessageParser.parse(updateOrdersChannelMessage); expect(updateMessage.type).to.be.equal('update'); @@ -56,13 +46,6 @@ describe('ordersChannelMessageParser', () => { const badCall = () => ordersChannelMessageParser.parse(messageWithBadType); expect(badCall).throws('Expected type to be of type string, encountered: 1'); }); - it('throws when snapshot message has malformed payload', () => { - const badCall = () => ordersChannelMessageParser.parse(malformedSnapshotOrdersChannelMessage); - // tslint:disable-next-line:max-line-length - const errMsg = - 'Validation errors: instance.payload requires property "bids", instance.payload requires property "asks"'; - expect(badCall).throws(errMsg); - }); it('throws when update message has malformed payload', () => { const badCall = () => ordersChannelMessageParser.parse(malformedUpdateOrdersChannelMessage); expect(badCall).throws(/^Expected message to conform to schema/); |