-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtest.js
More file actions
119 lines (104 loc) · 3.07 KB
/
Copy pathtest.js
File metadata and controls
119 lines (104 loc) · 3.07 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
const TIMEOUT = 10000;
let chai = require( 'chai' );
let assert = chai.assert;
let path = require( 'path' );
let huobi = require( path.resolve( __dirname, 'node-huobi-api.js' ) )();
let util = require( 'util' );
let logger = {
log: function (msg){
let logLineDetails = ((new Error().stack).split('at ')[3]).trim();
let logLineNum = logLineDetails.split(':');
console.log('DEBUG', logLineNum[1] + ':' + logLineNum[2], msg);
}
}
let debug = function( x ) {
// if ( typeof ( process.env.node_huobi_api ) === 'undefined' ) {
// return;
// }
logger.log( typeof ( x ) );
logger.log( util.inspect( x ) );
}
debug('Begin');
/*global describe*/
/*eslint no-undef: "error"*/
describe( 'Construct', function() {
/*global it*/
/*eslint no-undef: "error"*/
it( 'Construct the huobi object', function( done ) {
huobi.options( {
APIKEY: process.env.APIKEY,
APISECRET:process.env.APISECRET,
useServerTime: true,
reconnect: true,
verbose: true,
log: debug
} );
assert( typeof ( huobi ) === 'object', 'Huobi is not an object' );
done();
} ).timeout( TIMEOUT );
} );
describe( 'exchangeInfo', function() {
it( 'Call exchangeInfo', function( done ) {
huobi.exchangeInfo((error, data) => {
assert(error === null);
debug( error );
debug( data );
done();
});
}).timeout( TIMEOUT );
});
describe( 'account', function() {
it( 'Call account', function( done ) {
huobi.account((error, data) => {
assert(error === null);
debug( error );
debug( data );
done();
});
}).timeout( TIMEOUT );
});
describe( 'balance', function() {
it( 'Call balance', function( done ) {
huobi.account((error, data) => {
assert(error === null);
debug( error );
debug( data );
if (error == null){
huobi.balance(data.data[0].id,(error1,data1)=>{
debug( error );
debug( data );
done();
});
}
});
}).timeout( TIMEOUT );
});
describe( 'time', function() {
it( 'Call time', function( done ) {
huobi.time((error, data) => {
assert(error === null);
debug( error );
debug( data );
done();
});
}).timeout( TIMEOUT );
});
describe( 'depthCache', function() {
it( 'Call depthCache', function( done ) {
const tickers=['xrpbtc', 'bchusdt'];
huobi.websockets.depthCache( tickers,(symbol, depth) => {
debug(symbol+'=='+ JSON.stringify( depth) );
},10);
//done();
}).timeout( TIMEOUT );
});
describe( 'depthCacheStaggered', function() {
it( 'Call depthCacheStaggered', function( done ) {
const tickers=['xrpbtc', 'bchusdt'];
huobi.websockets.depthCacheStaggered( tickers,(symbol, depth) => {
debug(symbol+'=='+ JSON.stringify( depth) );
done();
},10);
//done();
}).timeout( TIMEOUT );
});