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,4 +1,5 @@
import { SpotClient } from '../../src';
import { getTestProxy } from '../proxy.util';
import { errorResponseObject, successResponseList } from '../response.util';
describe('Private Spot REST API GET Endpoints', () => {
@@ -10,16 +11,19 @@ describe('Private Spot REST API GET Endpoints', () => {
expect(API_SECRET).toStrictEqual(expect.any(String));
});
const api = new SpotClient({
key: API_KEY,
secret: API_SECRET,
testnet: false,
});
const api = new SpotClient(
{
key: API_KEY,
secret: API_SECRET,
testnet: false,
},
getTestProxy(),
);
it('getOrder()', async () => {
// No auth error == test pass
expect(await api.getOrder({ orderId: '123123' })).toMatchObject(
errorResponseObject({}, -2013, 'Order does not exist.')
errorResponseObject({}, -2013, 'Order does not exist.'),
);
});

View File

@@ -1,4 +1,5 @@
import { API_ERROR_CODE, SpotClient } from '../../src';
import { getTestProxy } from '../proxy.util';
import { successResponseObject } from '../response.util';
describe('Private Spot REST API POST Endpoints', () => {
@@ -10,11 +11,14 @@ describe('Private Spot REST API POST Endpoints', () => {
expect(API_SECRET).toStrictEqual(expect.any(String));
});
const api = new SpotClient({
key: API_KEY,
secret: API_SECRET,
testnet: false,
});
const api = new SpotClient(
{
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!
@@ -29,7 +33,7 @@ describe('Private Spot REST API POST Endpoints', () => {
symbol,
qty: 10000,
type: 'MARKET',
})
}),
).toMatchObject({
ret_code: API_ERROR_CODE.BALANCE_INSUFFICIENT_SPOT,
ret_msg: 'Balance insufficient ',
@@ -40,7 +44,7 @@ describe('Private Spot REST API POST Endpoints', () => {
expect(
await api.cancelOrder({
orderId: '1231231',
})
}),
).toMatchObject({
ret_code: API_ERROR_CODE.ORDER_NOT_FOUND_OR_TOO_LATE_SPOT,
ret_msg: 'Order does not exist.',
@@ -52,7 +56,7 @@ describe('Private Spot REST API POST Endpoints', () => {
await api.cancelOrderBatch({
symbol,
orderTypes: ['LIMIT', 'LIMIT_MAKER'],
})
}),
).toMatchObject(successResponseObject());
});
});

View File

@@ -1,4 +1,5 @@
import { API_ERROR_CODE, SpotClientV3 } from '../../src';
import { getTestProxy } from '../proxy.util';
import {
successEmptyResponseObjectV3,
successResponseListV3,
@@ -14,11 +15,14 @@ describe('Private Spot REST API GET Endpoints', () => {
expect(API_SECRET).toStrictEqual(expect.any(String));
});
const api = new SpotClientV3({
key: API_KEY,
secret: API_SECRET,
testnet: false,
});
const api = new SpotClientV3(
{
key: API_KEY,
secret: API_SECRET,
testnet: false,
},
getTestProxy(),
);
const symbol = 'BTCUSDT';
// const interval = '15m';
@@ -37,7 +41,7 @@ describe('Private Spot REST API GET Endpoints', () => {
it('getOpenOrders() with symbol', async () => {
expect(await api.getOpenOrders(symbol)).toMatchObject(
successResponseListV3()
successResponseListV3(),
);
});
@@ -47,13 +51,13 @@ describe('Private Spot REST API GET Endpoints', () => {
// all these should succeed
expect(
await api.getOpenOrders(symbol, orderId, ordersPerPage)
await api.getOpenOrders(symbol, orderId, ordersPerPage),
).toMatchObject(successResponseListV3());
expect(
await api.getOpenOrders(symbol, orderId, ordersPerPage, 0)
await api.getOpenOrders(symbol, orderId, ordersPerPage, 0),
).toMatchObject(successResponseListV3());
expect(
await api.getOpenOrders(symbol, orderId, ordersPerPage, 1)
await api.getOpenOrders(symbol, orderId, ordersPerPage, 1),
).toMatchObject(successResponseListV3());
});
@@ -76,7 +80,7 @@ describe('Private Spot REST API GET Endpoints', () => {
it('getLeveragedTokenMarketInfo()', async () => {
expect(await api.getLeveragedTokenMarketInfo(ltCode)).toMatchObject(
successResponseObjectV3()
successResponseObjectV3(),
);
});
@@ -89,25 +93,25 @@ describe('Private Spot REST API GET Endpoints', () => {
it('getCrossMarginBorrowingInfo()', async () => {
expect(await api.getCrossMarginBorrowingInfo()).toMatchObject(
successResponseObjectV3()
successResponseObjectV3(),
);
});
it('getCrossMarginAccountInfo()', async () => {
expect(await api.getCrossMarginAccountInfo()).toMatchObject({
retCode: API_ERROR_CODE.QUERY_ACCOUNT_INFO_ERROR,
retCode: API_ERROR_CODE.CROSS_MARGIN_NOT_ENABLED,
});
});
it('getCrossMarginInterestQuota()', async () => {
expect(await api.getCrossMarginInterestQuota('USDT')).toMatchObject(
successResponseObjectV3()
successResponseObjectV3(),
);
});
it('getCrossMarginRepaymentHistory()', async () => {
expect(await api.getCrossMarginRepaymentHistory()).toMatchObject(
successResponseObjectV3()
successResponseObjectV3(),
);
});
});

View File

@@ -1,4 +1,5 @@
import { API_ERROR_CODE, SpotClientV3 } from '../../src';
import { getTestProxy } from '../proxy.util';
import { successResponseObjectV3 } from '../response.util';
describe('Private Spot REST API POST Endpoints', () => {
@@ -10,11 +11,14 @@ describe('Private Spot REST API POST Endpoints', () => {
expect(API_SECRET).toStrictEqual(expect.any(String));
});
const api = new SpotClientV3({
key: API_KEY,
secret: API_SECRET,
testnet: false,
});
const api = new SpotClientV3(
{
key: API_KEY,
secret: API_SECRET,
testnet: false,
},
getTestProxy(),
);
const symbol = 'BTCUSDT';
const ltCode = 'BTC3S';
@@ -28,7 +32,7 @@ describe('Private Spot REST API POST Endpoints', () => {
symbol,
orderQty: '10000',
orderType: 'MARKET',
})
}),
).toMatchObject({
retCode: API_ERROR_CODE.BALANCE_INSUFFICIENT_SPOT_V3,
});
@@ -38,7 +42,7 @@ describe('Private Spot REST API POST Endpoints', () => {
expect(
await api.cancelOrder({
orderId: '1231231',
})
}),
).toMatchObject({
retCode: API_ERROR_CODE.ORDER_NOT_FOUND_SPOT_V3,
});
@@ -49,7 +53,7 @@ describe('Private Spot REST API POST Endpoints', () => {
await api.cancelOrderBatch({
symbol,
orderTypes: ['LIMIT', 'LIMIT_MAKER'],
})
}),
).toMatchObject(successResponseObjectV3());
});

View File

@@ -7,7 +7,7 @@ import {
successResponseObject,
} from '../response.util';
describe('Public Spot REST API Endpoints', () => {
describe.skip('Public Spot REST API Endpoints', () => {
const api = new SpotClient();
const symbol = 'BTCUSDT';
@@ -17,10 +17,10 @@ describe('Public Spot REST API Endpoints', () => {
it('should throw for unauthenticated private calls', async () => {
expect(() => api.getOpenOrders()).rejects.toMatchObject(
notAuthenticatedError()
notAuthenticatedError(),
);
expect(() => api.getBalances()).rejects.toMatchObject(
notAuthenticatedError()
notAuthenticatedError(),
);
});
@@ -30,13 +30,13 @@ describe('Public Spot REST API Endpoints', () => {
it('getOrderBook()', async () => {
expect(await api.getOrderBook(symbol)).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
it('getMergedOrderBook()', async () => {
expect(await api.getMergedOrderBook(symbol)).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
@@ -46,7 +46,7 @@ describe('Public Spot REST API Endpoints', () => {
it('getCandles()', async () => {
expect(await api.getCandles(symbol, interval)).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
@@ -56,13 +56,13 @@ describe('Public Spot REST API Endpoints', () => {
it('getLastTradedPrice()', async () => {
expect(await api.getLastTradedPrice()).toMatchObject(
successResponseObject()
successResponseObject(),
);
});
it('getBestBidAskPrice()', async () => {
expect(await api.getBestBidAskPrice()).toMatchObject(
successResponseObject()
successResponseObject(),
);
});

View File

@@ -1,13 +1,14 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { SpotClientV3 } from '../../src';
import { getTestProxy } from '../proxy.util';
import {
notAuthenticatedError,
successResponseObjectV3,
} from '../response.util';
describe('Public Spot REST API Endpoints', () => {
const api = new SpotClientV3();
const api = new SpotClientV3({}, getTestProxy());
const symbol = 'BTCUSDT';
const interval = '15m';
@@ -16,10 +17,10 @@ describe('Public Spot REST API Endpoints', () => {
it('should throw for unauthenticated private calls', async () => {
expect(() => api.getOpenOrders()).rejects.toMatchObject(
notAuthenticatedError()
notAuthenticatedError(),
);
expect(() => api.getBalances()).rejects.toMatchObject(
notAuthenticatedError()
notAuthenticatedError(),
);
});
@@ -29,25 +30,25 @@ describe('Public Spot REST API Endpoints', () => {
it('getOrderBook()', async () => {
expect(await api.getOrderBook(symbol)).toMatchObject(
successResponseObjectV3()
successResponseObjectV3(),
);
});
it('getMergedOrderBook()', async () => {
expect(await api.getMergedOrderBook(symbol)).toMatchObject(
successResponseObjectV3()
successResponseObjectV3(),
);
});
it('getTrades()', async () => {
expect(await api.getTrades(symbol)).toMatchObject(
successResponseObjectV3()
successResponseObjectV3(),
);
});
it('getCandles()', async () => {
expect(await api.getCandles(symbol, interval)).toMatchObject(
successResponseObjectV3()
successResponseObjectV3(),
);
});
@@ -57,13 +58,13 @@ describe('Public Spot REST API Endpoints', () => {
it('getLastTradedPrice()', async () => {
expect(await api.getLastTradedPrice()).toMatchObject(
successResponseObjectV3()
successResponseObjectV3(),
);
});
it('getBestBidAskPrice()', async () => {
expect(await api.getBestBidAskPrice()).toMatchObject(
successResponseObjectV3()
successResponseObjectV3(),
);
});