fixes for private spot GET calls, improve signing process, add private read tests for spot & linear
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
import { LinearClient } from '../../src/linear-client';
|
||||
import {
|
||||
notAuthenticatedError,
|
||||
successResponseList,
|
||||
successResponseObject,
|
||||
} from '../response.util';
|
||||
import { successResponseList, successResponseObject } from '../response.util';
|
||||
|
||||
describe('Public Linear REST API Endpoints', () => {
|
||||
const useLivenet = true;
|
||||
@@ -20,9 +16,6 @@ describe('Public Linear REST API Endpoints', () => {
|
||||
});
|
||||
|
||||
const symbol = 'BTCUSDT';
|
||||
const interval = '15';
|
||||
const timestampOneHourAgo = new Date().getTime() / 1000 - 1000 * 60 * 60;
|
||||
const from = Number(timestampOneHourAgo.toFixed(0));
|
||||
|
||||
describe('Linear only private GET endpoints', () => {
|
||||
it('getApiKeyInfo()', async () => {
|
||||
|
||||
@@ -14,6 +14,18 @@ export function successResponseObject(successMsg: string | null = 'OK') {
|
||||
};
|
||||
}
|
||||
|
||||
export function errorResponseObject(
|
||||
result: null | any = null,
|
||||
ret_code: number,
|
||||
ret_msg: string
|
||||
) {
|
||||
return {
|
||||
result,
|
||||
ret_code,
|
||||
ret_msg,
|
||||
};
|
||||
}
|
||||
|
||||
export function notAuthenticatedError() {
|
||||
return new Error('Private endpoints require api and private keys set');
|
||||
}
|
||||
|
||||
54
test/spot/private.read.test.ts
Normal file
54
test/spot/private.read.test.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { SpotClient } from '../../src';
|
||||
import {
|
||||
errorResponseObject,
|
||||
notAuthenticatedError,
|
||||
successResponseList,
|
||||
successResponseObject,
|
||||
} from '../response.util';
|
||||
|
||||
describe('Private Spot REST API Endpoints', () => {
|
||||
const useLivenet = true;
|
||||
const API_KEY = process.env.API_KEY_COM;
|
||||
const API_SECRET = process.env.API_SECRET_COM;
|
||||
|
||||
it('should have api credentials to test with', () => {
|
||||
expect(API_KEY).toStrictEqual(expect.any(String));
|
||||
expect(API_SECRET).toStrictEqual(expect.any(String));
|
||||
});
|
||||
|
||||
const api = new SpotClient(API_KEY, API_SECRET, useLivenet, {
|
||||
disable_time_sync: true,
|
||||
});
|
||||
|
||||
const symbol = 'BTCUSDT';
|
||||
const interval = '15m';
|
||||
|
||||
it('getOrder()', async () => {
|
||||
// No auth error == test pass
|
||||
expect(await api.getOrder({ orderId: '123123' })).toMatchObject(
|
||||
errorResponseObject(null, -2013, 'Order does not exist.')
|
||||
);
|
||||
});
|
||||
|
||||
it('getOpenOrders()', async () => {
|
||||
expect(await api.getOpenOrders()).toMatchObject(successResponseList(''));
|
||||
});
|
||||
|
||||
it('getPastOrders()', async () => {
|
||||
expect(await api.getPastOrders()).toMatchObject(successResponseList(''));
|
||||
});
|
||||
|
||||
it('getMyTrades()', async () => {
|
||||
expect(await api.getMyTrades()).toMatchObject(successResponseList(''));
|
||||
});
|
||||
|
||||
it('getBalances()', async () => {
|
||||
expect(await api.getBalances()).toMatchObject({
|
||||
result: {
|
||||
balances: expect.any(Array),
|
||||
},
|
||||
ret_code: 0,
|
||||
ret_msg: '',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user