-
Notifications
You must be signed in to change notification settings - Fork 18
/
index.js
52 lines (49 loc) · 1.3 KB
/
index.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
42
43
44
45
46
47
48
49
50
51
52
'use strict'
const MockServer = require('./lib/server')
const MockWSv2Server = require('./lib/ws2')
const MockRESTv2Server = require('./lib/rest2')
/**
* This module hosts mock servers for the
* {@link MockWSv2Server|WSv2} and {@link MockRESTv2Server|RESTv2} Bitfinex
* APIs, and is intended for testing the Bitfinex API libraries.
*
* @license Apache-2.0
* @module bfx-api-mock-srv
* @example
* const { MockRESTv2Server } = require('bfx-api-mock-srv')
*
* const FUNDING_OFFER = [
* 41215275, 'fUSD', 1524784806000, 1524784806000, 1000, 1000, 'FRRDELTAVAR',
* null, null, 0, 'ACTIVE', null, null, null, 0, 30, 0, 0, null, 0,
* 0.00207328
* ]
*
* debug('spawning mock server...')
*
* const srv = new MockRESTv2Server({ listen: true })
* const rest = new RESTv2({
* apiKey: 'dummy',
* apiSecret: 'dummy',
* url: 'http://localhost:9999'
* })
*
* srv.setResponse('f_offers.fUSD', [FUNDING_OFFER])
*
* debug('requesting preset response...')
*
* rest.fundingOffers('fUSD').then(([incomingFundingOffer]) => {
* assert.deepStrictEqual(incomingFundingOffer, FUNDING_OFFER)
*
* debug('correct response received')
* srv.close()
*
* return null
* }).catch((e) => {
* debug(`error: ${e.message}`)
* })
*/
module.exports = {
MockServer,
MockWSv2Server,
MockRESTv2Server
}