2017-07-14 19:34:03 +02:00
|
|
|
const assert = require('assert')
|
2017-07-14 22:06:42 +02:00
|
|
|
const sinon = require('sinon')
|
2018-05-21 14:59:26 +02:00
|
|
|
const InfuraController = require('../../../../app/scripts/controllers/infura')
|
2017-07-14 19:34:03 +02:00
|
|
|
|
|
|
|
describe('infura-controller', function () {
|
2017-07-14 22:06:42 +02:00
|
|
|
let infuraController, sandbox, networkStatus
|
|
|
|
const response = {'mainnet': 'degraded', 'ropsten': 'ok', 'kovan': 'ok', 'rinkeby': 'down'}
|
2017-07-14 19:34:03 +02:00
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
infuraController = new InfuraController()
|
2018-04-04 21:48:30 +02:00
|
|
|
sandbox = sinon.createSandbox()
|
2017-07-14 22:06:42 +02:00
|
|
|
sinon.stub(infuraController, 'checkInfuraNetworkStatus').resolves(response)
|
|
|
|
networkStatus = await infuraController.checkInfuraNetworkStatus()
|
|
|
|
})
|
|
|
|
|
|
|
|
after(function () {
|
|
|
|
sandbox.restore()
|
2017-07-14 19:34:03 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
describe('Network status queries', function () {
|
|
|
|
|
|
|
|
describe('Mainnet', function () {
|
|
|
|
it('should have Mainnet', function () {
|
2017-07-14 22:06:42 +02:00
|
|
|
assert.equal(Object.keys(networkStatus)[0], 'mainnet')
|
2017-07-14 19:34:03 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('should have a value for Mainnet status', function () {
|
2017-07-14 22:06:42 +02:00
|
|
|
assert.equal(networkStatus.mainnet, 'degraded')
|
2017-07-14 19:34:03 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('Ropsten', function () {
|
|
|
|
it('should have Ropsten', function () {
|
2017-07-14 22:06:42 +02:00
|
|
|
assert.equal(Object.keys(networkStatus)[1], 'ropsten')
|
2017-07-14 19:34:03 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('should have a value for Ropsten status', function () {
|
2017-07-14 22:06:42 +02:00
|
|
|
assert.equal(networkStatus.ropsten, 'ok')
|
2017-07-14 19:34:03 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('Kovan', function () {
|
|
|
|
it('should have Kovan', function () {
|
2017-07-14 22:06:42 +02:00
|
|
|
assert.equal(Object.keys(networkStatus)[2], 'kovan')
|
2017-07-14 19:34:03 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('should have a value for Kovan status', function () {
|
2017-07-14 22:06:42 +02:00
|
|
|
assert.equal(networkStatus.kovan, 'ok')
|
2017-07-14 19:34:03 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('Rinkeby', function () {
|
|
|
|
it('should have Rinkeby', function () {
|
2017-07-14 22:06:42 +02:00
|
|
|
assert.equal(Object.keys(networkStatus)[3], 'rinkeby')
|
2017-07-14 19:34:03 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('should have a value for Rinkeby status', function () {
|
2017-07-14 22:06:42 +02:00
|
|
|
assert.equal(networkStatus.rinkeby, 'down')
|
2017-07-14 19:34:03 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|