Files

61 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

import assert from 'assert'
import axios from 'axios'
import BCHJS from '../../src/bch-js.js'
import sinon from 'sinon'
2020-07-27 21:32:51 -07:00
const bchjs = new BCHJS()
2021-01-02 15:41:12 -08:00
describe('#Control', () => {
let sandbox
beforeEach(() => (sandbox = sinon.createSandbox()))
afterEach(() => sandbox.restore())
2020-07-27 21:32:51 -07:00
describe('#getNetworkInfo', () => {
2021-01-02 15:41:12 -08:00
it('should get info', done => {
2020-07-27 21:32:51 -07:00
const data = {
version: 170000,
protocolversion: 70015,
blocks: 527813,
timeoffset: 0,
connections: 21,
2021-01-02 15:41:12 -08:00
proxy: '',
2020-07-27 21:32:51 -07:00
difficulty: 581086703759.5878,
testnet: false,
paytxfee: 0,
relayfee: 0.00001,
2021-01-02 15:41:12 -08:00
errors: ''
2020-07-27 21:32:51 -07:00
}
2025-11-16 13:47:24 -08:00
const resolved = new Promise(resolve => resolve({ data }))
2021-01-02 15:41:12 -08:00
sandbox.stub(axios, 'get').returns(resolved)
2020-07-27 21:32:51 -07:00
bchjs.Control.getNetworkInfo()
.then(result => {
2021-01-02 16:39:44 -08:00
assert.deepStrictEqual(data, result)
2020-07-27 21:32:51 -07:00
})
.then(done, done)
})
})
2021-01-02 15:41:12 -08:00
describe('#getMemoryInfo', () => {
it('should get memory info', done => {
2020-07-27 21:32:51 -07:00
const data = {
locked: {
used: 0,
free: 65536,
total: 65536,
locked: 65536,
chunks_used: 0,
chunks_free: 1
}
}
2025-11-16 13:47:24 -08:00
const resolved = new Promise(resolve => resolve({ data }))
2021-01-02 15:41:12 -08:00
sandbox.stub(axios, 'get').returns(resolved)
2020-07-27 21:32:51 -07:00
bchjs.Control.getMemoryInfo()
.then(result => {
2021-01-02 16:39:44 -08:00
assert.deepStrictEqual(data, result)
2020-07-27 21:32:51 -07:00
})
.then(done, done)
})
})
})