fix overly strict inverse & usdc options tests

This commit is contained in:
tiagosiebler
2022-10-09 19:20:05 +01:00
parent 6989c3570c
commit 6a925f18e1
4 changed files with 54 additions and 12 deletions

View File

@@ -12,7 +12,27 @@ describe('Private Inverse-Futures REST API GET Endpoints', () => {
});
// 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!
const symbol = 'BTCUSDU22';
let symbol = '';
beforeAll(async () => {
const symbolsResponse = await api.getSymbols();
const prefix = 'BTCUSD';
const futuresAsset = symbolsResponse.result
.filter((row) => row.name.startsWith(prefix))
.find((row) => {
const splitSymbol = row.name.split(prefix);
return splitSymbol[1] && splitSymbol[1] !== 'T';
});
if (!futuresAsset?.name) {
throw new Error('No symbol');
}
symbol = futuresAsset?.name;
console.log('Symbol: ', symbol);
});
it('getApiKeyInfo()', async () => {
expect(await api.getApiKeyInfo()).toMatchObject(successResponseObject());

View File

@@ -17,7 +17,27 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
});
// 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!
const symbol = 'BTCUSDU22';
let symbol = '';
beforeAll(async () => {
const symbolsResponse = await api.getSymbols();
const prefix = 'BTCUSD';
const futuresAsset = symbolsResponse.result
.filter((row) => row.name.startsWith(prefix))
.find((row) => {
const splitSymbol = row.name.split(prefix);
return splitSymbol[1] && splitSymbol[1] !== 'T';
});
if (!futuresAsset?.name) {
throw new Error('No symbol');
}
symbol = futuresAsset?.name;
console.log('Symbol: ', symbol);
});
// These tests are primarily check auth is working by expecting balance or order not found style errors
@@ -134,7 +154,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
take_profit: 50000,
})
).toMatchObject({
ret_code: API_ERROR_CODE.POSITION_IDX_NOT_MATCH_POSITION_MODE,
ret_code: API_ERROR_CODE.POSITION_STATUS_NOT_NORMAL,
});
});