fixed tests
This commit is contained in:
@@ -10,7 +10,7 @@ import { Agent as HttpsAgent } from 'https';
|
||||
import { constants } from '../constants';
|
||||
import { MarketOperation, RfqtMakerAssetOfferings, RfqtRequestOpts } from '../types';
|
||||
|
||||
const httpClient: AxiosInstance = Axios.create({
|
||||
export const quoteRequestorHttpClient: AxiosInstance = Axios.create({
|
||||
httpAgent: new HttpAgent({ keepAlive: true }),
|
||||
httpsAgent: new HttpsAgent({ keepAlive: true }),
|
||||
});
|
||||
@@ -337,7 +337,7 @@ export class QuoteRequestor {
|
||||
throw new Error(`Unexpected quote type ${quoteType}`);
|
||||
}
|
||||
})();
|
||||
const response = await httpClient.get<ResponseT>(`${url}/${quotePath}`, {
|
||||
const response = await quoteRequestorHttpClient.get<ResponseT>(`${url}/${quotePath}`, {
|
||||
headers: { '0x-api-key': options.apiKey },
|
||||
params: requestParams,
|
||||
timeout: options.makerEndpointMaxResponseTimeMs,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import axios from 'axios';
|
||||
import axios, { AxiosInstance } from 'axios';
|
||||
import AxiosMockAdapter from 'axios-mock-adapter';
|
||||
|
||||
import { MockedRfqtFirmQuoteResponse } from '../types';
|
||||
@@ -16,8 +16,9 @@ export const rfqtMocker = {
|
||||
withMockedRfqtFirmQuotes: async (
|
||||
mockedResponses: MockedRfqtFirmQuoteResponse[],
|
||||
performFn: () => Promise<void>,
|
||||
axiosClient: AxiosInstance = axios,
|
||||
) => {
|
||||
const mockedAxios = new AxiosMockAdapter(axios);
|
||||
const mockedAxios = new AxiosMockAdapter(axiosClient);
|
||||
try {
|
||||
// Mock out RFQT responses
|
||||
for (const mockedResponse of mockedResponses) {
|
||||
@@ -37,8 +38,9 @@ export const rfqtMocker = {
|
||||
withMockedRfqtIndicativeQuotes: async (
|
||||
mockedResponses: MockedRfqtFirmQuoteResponse[],
|
||||
performFn: () => Promise<void>,
|
||||
axiosClient: AxiosInstance = axios,
|
||||
) => {
|
||||
const mockedAxios = new AxiosMockAdapter(axios);
|
||||
const mockedAxios = new AxiosMockAdapter(axiosClient);
|
||||
try {
|
||||
// Mock out RFQT responses
|
||||
for (const mockedResponse of mockedResponses) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'mocha';
|
||||
|
||||
import { constants } from '../src/constants';
|
||||
import { MarketOperation, MockedRfqtFirmQuoteResponse, MockedRfqtIndicativeQuoteResponse } from '../src/types';
|
||||
import { QuoteRequestor } from '../src/utils/quote_requestor';
|
||||
import { QuoteRequestor, quoteRequestorHttpClient } from '../src/utils/quote_requestor';
|
||||
import { rfqtMocker } from '../src/utils/rfqt_mocker';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
@@ -22,7 +22,7 @@ function makeThreeMinuteExpiry(): BigNumber {
|
||||
return new BigNumber(Math.round(expiry.valueOf() / constants.ONE_SECOND_MS));
|
||||
}
|
||||
|
||||
describe('QuoteRequestor', async () => {
|
||||
describe.only('QuoteRequestor', async () => {
|
||||
const [makerToken, takerToken, otherToken1] = tokenUtils.getDummyERC20TokenAddresses();
|
||||
const makerAssetData = assetDataUtils.encodeERC20AssetData(makerToken);
|
||||
const takerAssetData = assetDataUtils.encodeERC20AssetData(takerToken);
|
||||
@@ -153,7 +153,9 @@ describe('QuoteRequestor', async () => {
|
||||
responseCode: StatusCodes.Success,
|
||||
});
|
||||
|
||||
return rfqtMocker.withMockedRfqtFirmQuotes(mockedRequests, async () => {
|
||||
return rfqtMocker.withMockedRfqtFirmQuotes(
|
||||
mockedRequests,
|
||||
async () => {
|
||||
const qr = new QuoteRequestor({
|
||||
'https://1337.0.0.1': [[makerToken, takerToken]],
|
||||
'https://420.0.0.1': [[makerToken, takerToken]],
|
||||
@@ -181,7 +183,9 @@ describe('QuoteRequestor', async () => {
|
||||
expect(resp.sort()).to.eql(
|
||||
[{ signedOrder: successfulOrder1 }, { signedOrder: successfulOrder2 }].sort(),
|
||||
);
|
||||
});
|
||||
},
|
||||
quoteRequestorHttpClient,
|
||||
);
|
||||
});
|
||||
});
|
||||
describe('requestRfqtIndicativeQuotesAsync for Indicative quotes', async () => {
|
||||
@@ -255,7 +259,9 @@ describe('QuoteRequestor', async () => {
|
||||
responseCode: StatusCodes.Success,
|
||||
});
|
||||
|
||||
return rfqtMocker.withMockedRfqtIndicativeQuotes(mockedRequests, async () => {
|
||||
return rfqtMocker.withMockedRfqtIndicativeQuotes(
|
||||
mockedRequests,
|
||||
async () => {
|
||||
const qr = new QuoteRequestor({
|
||||
'https://1337.0.0.1': [[makerToken, takerToken]],
|
||||
'https://420.0.0.1': [[makerToken, takerToken]],
|
||||
@@ -277,7 +283,9 @@ describe('QuoteRequestor', async () => {
|
||||
},
|
||||
);
|
||||
expect(resp.sort()).to.eql([successfulQuote1, successfulQuote1].sort());
|
||||
});
|
||||
},
|
||||
quoteRequestorHttpClient,
|
||||
);
|
||||
});
|
||||
it('should return successful RFQT indicative quote requests', async () => {
|
||||
const takerAddress = '0xd209925defc99488e3afff1174e48b4fa628302a';
|
||||
@@ -309,7 +317,9 @@ describe('QuoteRequestor', async () => {
|
||||
responseCode: StatusCodes.Success,
|
||||
});
|
||||
|
||||
return rfqtMocker.withMockedRfqtIndicativeQuotes(mockedRequests, async () => {
|
||||
return rfqtMocker.withMockedRfqtIndicativeQuotes(
|
||||
mockedRequests,
|
||||
async () => {
|
||||
const qr = new QuoteRequestor({ 'https://1337.0.0.1': [[makerToken, takerToken]] });
|
||||
const resp = await qr.requestRfqtIndicativeQuotesAsync(
|
||||
makerAssetData,
|
||||
@@ -323,7 +333,9 @@ describe('QuoteRequestor', async () => {
|
||||
},
|
||||
);
|
||||
expect(resp.sort()).to.eql([successfulQuote1].sort());
|
||||
});
|
||||
},
|
||||
quoteRequestorHttpClient,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user