-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.balance.js
41 lines (34 loc) · 1.07 KB
/
test.balance.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict'
// ----------------------------------------------------------------------------
const assert = require ('assert')
// ----------------------------------------------------------------------------
module.exports = (exchange, balance, method) => {
const currencies = [
'USD',
'USDT',
'CNY',
'EUR',
'BTC',
'ETH',
'JPY',
'LTC',
'DASH',
'DOGE',
'UAH',
'RUB',
'XRP',
]
assert (typeof balance['total'] === 'object')
assert (typeof balance['free'] === 'object')
assert (typeof balance['used'] === 'object')
const codes = Object.keys (balance['total'])
for (let i = 0; i < codes.length; i++) {
const code = codes[i]
const total = balance['total'][code]
const free = balance['free'][code]
const used = balance['used'][code]
if ((total !== undefined) && (free !== undefined) && (used !== undefined)) {
assert (total === free + used, 'free and used do not sum to total ' + exchange.id)
}
}
}