chore(): route tests via proxy instead of github CI address

This commit is contained in:
tiagosiebler
2023-08-18 16:21:13 +01:00
parent 9bc1ff89c6
commit 21ac313f38
37 changed files with 581 additions and 415 deletions

View File

@@ -1,15 +1,19 @@
import { InverseFuturesClient } from '../../src/inverse-futures-client';
import { getTestProxy } from '../proxy.util';
import { successResponseList, successResponseObject } from '../response.util';
describe('Private Inverse-Futures REST API GET Endpoints', () => {
const API_KEY = process.env.API_KEY_COM;
const API_SECRET = process.env.API_SECRET_COM;
const api = new InverseFuturesClient({
key: API_KEY,
secret: API_SECRET,
testnet: false,
});
const api = new InverseFuturesClient(
{
key: API_KEY,
secret: API_SECRET,
testnet: false,
},
getTestProxy(),
);
// Warning: if some of these start to fail with 10001 params error,
// it's probably that this future expired and a newer one exists with a different symbol!
@@ -45,43 +49,43 @@ describe('Private Inverse-Futures REST API GET Endpoints', () => {
it('getWalletFundRecords()', async () => {
expect(await api.getWalletFundRecords()).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
it('getWithdrawRecords()', async () => {
expect(await api.getWithdrawRecords()).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
it('getAssetExchangeRecords()', async () => {
expect(await api.getAssetExchangeRecords()).toMatchObject(
successResponseList()
successResponseList(),
);
});
it('getActiveOrderList()', async () => {
expect(await api.getActiveOrderList({ symbol: symbol })).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
it('queryActiveOrder()', async () => {
expect(await api.queryActiveOrder({ symbol: symbol })).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
it('getConditionalOrder()', async () => {
expect(await api.getConditionalOrder({ symbol: symbol })).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
it('queryConditionalOrder()', async () => {
expect(await api.queryConditionalOrder({ symbol: symbol })).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
@@ -91,31 +95,31 @@ describe('Private Inverse-Futures REST API GET Endpoints', () => {
it('getTradeRecords()', async () => {
expect(await api.getTradeRecords({ symbol: symbol })).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
it('getClosedPnl()', async () => {
expect(await api.getClosedPnl({ symbol: symbol })).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
it('getMyLastFundingFee()', async () => {
expect(await api.getMyLastFundingFee({ symbol: symbol })).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
it('getPredictedFunding()', async () => {
expect(await api.getPredictedFunding({ symbol: 'BTCUSD' })).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
it('getLcpInfo()', async () => {
expect(await api.getLcpInfo({ symbol: symbol })).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
});

View File

@@ -1,4 +1,5 @@
import { API_ERROR_CODE, InverseFuturesClient } from '../../src';
import { getTestProxy } from '../proxy.util';
import { successResponseObject } from '../response.util';
describe('Private Inverse-Futures REST API POST Endpoints', () => {
@@ -10,11 +11,14 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
expect(API_SECRET).toStrictEqual(expect.any(String));
});
const api = new InverseFuturesClient({
key: API_KEY,
secret: API_SECRET,
testnet: false,
});
const api = new InverseFuturesClient(
{
key: API_KEY,
secret: API_SECRET,
testnet: false,
},
getTestProxy(),
);
// Warning: if some of these start to fail with 10001 params error,
// it's probably that this future expired and a newer one exists with a different symbol!
@@ -51,7 +55,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
price: 30000,
qty: 1,
time_in_force: 'GoodTillCancel',
})
}),
).toMatchObject({
ret_code: API_ERROR_CODE.POSITION_IDX_NOT_MATCH_POSITION_MODE,
});
@@ -61,7 +65,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
expect(
await api.cancelActiveOrder({
symbol,
})
}),
).toMatchObject({
ret_code: API_ERROR_CODE.ORDER_NOT_FOUND_OR_TOO_LATE,
});
@@ -71,7 +75,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
expect(
await api.cancelAllActiveOrders({
symbol,
})
}),
).toMatchObject(successResponseObject());
});
@@ -82,7 +86,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
order_id: '123123123',
p_r_qty: '1',
p_r_price: '30000',
})
}),
).toMatchObject({
ret_code: API_ERROR_CODE.ORDER_NOT_FOUND_OR_TOO_LATE,
});
@@ -100,7 +104,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
stop_px: '8150',
time_in_force: 'GoodTillCancel',
order_link_id: 'cus_order_id_1',
})
}),
).toMatchObject({
ret_code: API_ERROR_CODE.POSITION_IDX_NOT_MATCH_POSITION_MODE,
});
@@ -111,7 +115,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
await api.cancelConditionalOrder({
symbol,
order_link_id: 'lkasmdflasd',
})
}),
).toMatchObject({
ret_code: API_ERROR_CODE.ORDER_NOT_FOUND_OR_TOO_LATE,
});
@@ -121,7 +125,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
expect(
await api.cancelAllConditionalOrders({
symbol,
})
}),
).toMatchObject(successResponseObject());
});
@@ -132,11 +136,11 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
order_link_id: 'fakeOrderId',
p_r_price: '50000',
p_r_qty: 1,
})
}),
).toMatchObject({
ret_code: API_ERROR_CODE.ORDER_NOT_FOUND_OR_TOO_LATE,
ret_msg: expect.stringMatching(
/orderID or orderLinkID invalid|order not exists/gim
/orderID or orderLinkID invalid|order not exists/gim,
),
});
});
@@ -146,7 +150,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
await api.changePositionMargin({
symbol,
margin: '10',
})
}),
).toMatchObject({
ret_code: API_ERROR_CODE.POSITION_IDX_NOT_MATCH_POSITION_MODE,
});
@@ -157,7 +161,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
await api.setTradingStop({
symbol,
take_profit: 50000,
})
}),
).toMatchObject({
// seems to fluctuate between POSITION_STATUS_NOT_NORMAL and POSITION_IDX_NOT_MATCH_POSITION_MODE
ret_code: /^30013|30041$/,
@@ -170,7 +174,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
symbol,
buy_leverage: 5,
sell_leverage: 5,
})
}),
).toMatchObject({
ret_code: API_ERROR_CODE.LEVERAGE_NOT_MODIFIED,
});
@@ -181,7 +185,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
await api.setPositionMode({
symbol,
mode: 3,
})
}),
).toMatchObject({
ret_code: API_ERROR_CODE.POSITION_MODE_NOT_MODIFIED,
});
@@ -194,7 +198,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
is_isolated: false,
buy_leverage: 5,
sell_leverage: 5,
})
}),
).toMatchObject({
ret_code: API_ERROR_CODE.ISOLATED_NOT_MODIFIED,
});

View File

@@ -1,4 +1,5 @@
import { InverseFuturesClient } from '../../src/inverse-futures-client';
import { getTestProxy } from '../proxy.util';
import {
notAuthenticatedError,
successResponseList,
@@ -6,7 +7,7 @@ import {
} from '../response.util';
describe('Public Inverse-Futures REST API Endpoints', () => {
const api = new InverseFuturesClient();
const api = new InverseFuturesClient({}, getTestProxy());
const symbol = 'BTCUSD';
const interval = '15';
@@ -16,22 +17,22 @@ describe('Public Inverse-Futures REST API Endpoints', () => {
describe('Inverse-Futures only endpoints', () => {
it('should throw for unauthenticated private calls', async () => {
expect(() => api.getPosition()).rejects.toMatchObject(
notAuthenticatedError()
notAuthenticatedError(),
);
expect(() => api.getApiKeyInfo()).rejects.toMatchObject(
notAuthenticatedError()
notAuthenticatedError(),
);
});
it('getOrderBook()', async () => {
expect(await api.getOrderBook({ symbol })).toMatchObject(
successResponseList()
successResponseList(),
);
});
it('getKline()', async () => {
expect(await api.getKline({ symbol, interval, from })).toMatchObject(
successResponseList()
successResponseList(),
);
});
@@ -41,7 +42,7 @@ describe('Public Inverse-Futures REST API Endpoints', () => {
it('getTrades()', async () => {
expect(await api.getTrades({ symbol })).toMatchObject(
successResponseList()
successResponseList(),
);
});
@@ -51,25 +52,25 @@ describe('Public Inverse-Futures REST API Endpoints', () => {
it('getMarkPriceKline()', async () => {
expect(
await api.getMarkPriceKline({ symbol, interval, from })
await api.getMarkPriceKline({ symbol, interval, from }),
).toMatchObject(successResponseList());
});
it('getIndexPriceKline()', async () => {
expect(
await api.getIndexPriceKline({ symbol, interval, from })
await api.getIndexPriceKline({ symbol, interval, from }),
).toMatchObject(successResponseList());
});
it('getPremiumIndexKline()', async () => {
expect(
await api.getPremiumIndexKline({ symbol, interval, from })
await api.getPremiumIndexKline({ symbol, interval, from }),
).toMatchObject(successResponseList());
});
it('getLastFundingRate()', async () => {
expect(await api.getLastFundingRate({ symbol })).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
@@ -83,7 +84,7 @@ describe('Public Inverse-Futures REST API Endpoints', () => {
it('getApiAnnouncements()', async () => {
expect(await api.getApiAnnouncements()).toMatchObject(
successResponseList()
successResponseList(),
);
});
});