Skip to content

Commit 58f4d53

Browse files
authored
Merge pull request #926 from ccxt/live-tests-protect-balance
Live tests protect balance
2 parents b01a876 + 4f4cfd1 commit 58f4d53

3 files changed

Lines changed: 18 additions & 9 deletions

File tree

examples/class-example.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Binance from "../node-binance-api-class.mjs"
1+
import Binance from "../src/node-binance-api.js"
22

33

44
async function main() {

examples/proxy.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// import Binance from "node-binance-api"
2-
import Binance from "../node-binance-api-class.mjs"
2+
import Binance from "../src/node-binance-api.js"
33

44

55
async function main () {

tests/binance-class-live.test.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,19 +281,28 @@ describe('Limit buy Order', function () {
281281

282282
describe('MarketSell', function () {
283283
it('Attempt to buy LTC at market price', async function () {
284-
let quantity = 0.5;
285-
const res = await binance.marketSell('LTCUSDT', quantity)
286-
assert(res['orderId'] !== undefined)
284+
285+
try {
286+
let quantity = 0.5;
287+
const res = await binance.marketSell('LTCUSDT', quantity)
288+
assert(res['orderId'] !== undefined)
289+
} catch (e) {
290+
assert(e.toString().includes('{"code":-2010,"msg":"Account has insufficient balance for requested action."}'));
291+
}
287292

288293
}).timeout(TIMEOUT);
289294
});
290295

291296
describe('Futures MarketBuy', function () {
292297
it('futures Attempt to buy ETH at market price', async function () {
293-
let quantity = 0.1;
294-
const res = await futuresBinance.futuresMarketBuy('ETHUSDT', quantity)
295-
assert(res['orderId'] !== undefined)
296-
futuresOrderId = res['orderId'];
298+
try {
299+
let quantity = 0.1;
300+
const res = await futuresBinance.futuresMarketBuy('ETHUSDT', quantity)
301+
assert(res['orderId'] !== undefined)
302+
futuresOrderId = res['orderId'];
303+
} catch (e) {
304+
assert(e.toString().includes('{"code":-2010,"msg":"Account has insufficient balance for requested action."}'));
305+
}
297306

298307
}).timeout(TIMEOUT);
299308
});

0 commit comments

Comments
 (0)