test(fix): correct findProviders test for missing provider (#391)

* test(fix): correct findProviders test for missing provider

* chore: fix lint
This commit is contained in:
Jacob Heun 2019-07-30 15:11:24 +02:00 committed by GitHub
parent 48b1b442e9
commit 65d52857a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 69 additions and 68 deletions

View File

@ -63,7 +63,7 @@
}, },
"devDependencies": { "devDependencies": {
"@nodeutils/defaults-deep": "^1.1.0", "@nodeutils/defaults-deep": "^1.1.0",
"aegir": "^19.0.3", "aegir": "^20.0.0",
"chai": "^4.2.0", "chai": "^4.2.0",
"chai-checkmark": "^1.0.1", "chai-checkmark": "^1.0.1",
"cids": "^0.7.1", "cids": "^0.7.1",
@ -74,7 +74,7 @@
"libp2p-circuit": "^0.3.7", "libp2p-circuit": "^0.3.7",
"libp2p-delegated-content-routing": "^0.2.2", "libp2p-delegated-content-routing": "^0.2.2",
"libp2p-delegated-peer-routing": "^0.2.2", "libp2p-delegated-peer-routing": "^0.2.2",
"libp2p-kad-dht": "^0.15.2", "libp2p-kad-dht": "^0.15.3",
"libp2p-mdns": "^0.12.3", "libp2p-mdns": "^0.12.3",
"libp2p-mplex": "^0.8.4", "libp2p-mplex": "^0.8.4",
"libp2p-secio": "^0.11.1", "libp2p-secio": "^0.11.1",

View File

@ -69,7 +69,7 @@ class Libp2p extends EventEmitter {
// Attach stream multiplexers // Attach stream multiplexers
if (this._modules.streamMuxer) { if (this._modules.streamMuxer) {
let muxers = this._modules.streamMuxer const muxers = this._modules.streamMuxer
muxers.forEach((muxer) => this._switch.connection.addStreamMuxer(muxer)) muxers.forEach((muxer) => this._switch.connection.addStreamMuxer(muxer))
// If muxer exists // If muxer exists
@ -99,7 +99,7 @@ class Libp2p extends EventEmitter {
// Attach crypto channels // Attach crypto channels
if (this._modules.connEncryption) { if (this._modules.connEncryption) {
let cryptos = this._modules.connEncryption const cryptos = this._modules.connEncryption
cryptos.forEach((crypto) => { cryptos.forEach((crypto) => {
this._switch.connection.crypto(crypto.tag, crypto.encrypt) this._switch.connection.crypto(crypto.tag, crypto.encrypt)
}) })

View File

@ -16,7 +16,7 @@ const tryEcho = require('./utils/try-echo')
const echo = require('./utils/echo') const echo = require('./utils/echo')
describe('circuit relay', () => { describe('circuit relay', () => {
let handlerSpies = [] const handlerSpies = []
let relayNode1 let relayNode1
let relayNode2 let relayNode2
let nodeWS1 let nodeWS1

View File

@ -121,8 +121,9 @@ describe('.contentRouting', () => {
const cid = new CID('QmTp9VkYvnHyrqKQuFPiuZkiX9gPcqj6x5LJ1rmWuSnnnn') const cid = new CID('QmTp9VkYvnHyrqKQuFPiuZkiX9gPcqj6x5LJ1rmWuSnnnn')
nodeE.contentRouting.findProviders(cid, { maxTimeout: 5000 }, (err, providers) => { nodeE.contentRouting.findProviders(cid, { maxTimeout: 5000 }, (err, providers) => {
expect(err).to.not.exist() expect(err).to.exist()
expect(providers).to.have.length(0) expect(err.code).to.eql('ERR_NOT_FOUND')
expect(providers).to.not.exist()
done() done()
}) })
}) })

View File

@ -29,10 +29,10 @@ describe('libp2p creation', () => {
}, (err, node) => { }, (err, node) => {
expect(err).to.not.exist() expect(err).to.not.exist()
let sw = node._switch const sw = node._switch
let cm = node.connectionManager const cm = node.connectionManager
let dht = node._dht const dht = node._dht
let pub = node._floodSub const pub = node._floodSub
sinon.spy(sw, 'start') sinon.spy(sw, 'start')
sinon.spy(cm, 'start') sinon.spy(cm, 'start')

View File

@ -99,7 +99,7 @@ describe('libp2p state machine (fsm)', () => {
}) })
it('should error on start with no transports', (done) => { it('should error on start with no transports', (done) => {
let transports = node._modules.transport const transports = node._modules.transport
node._modules.transport = null node._modules.transport = null
node.on('stop', () => { node.on('stop', () => {

View File

@ -294,7 +294,7 @@ describe('peer discovery', () => {
}) })
it('find peers', function (done) { it('find peers', function (done) {
let expectedPeers = new Set([ const expectedPeers = new Set([
nodeB.peerInfo.id.toB58String(), nodeB.peerInfo.id.toB58String(),
nodeC.peerInfo.id.toB58String() nodeC.peerInfo.id.toB58String()
]) ])
@ -332,7 +332,7 @@ describe('peer discovery', () => {
it('find peers', function (done) { it('find peers', function (done) {
this.timeout(20e3) this.timeout(20e3)
let expectedPeers = new Set([ const expectedPeers = new Set([
nodeB.peerInfo.id.toB58String(), nodeB.peerInfo.id.toB58String(),
nodeC.peerInfo.id.toB58String() nodeC.peerInfo.id.toB58String()
]) ])
@ -374,7 +374,7 @@ describe('peer discovery', () => {
}) })
it('find peers', function (done) { it('find peers', function (done) {
let expectedPeers = new Set([ const expectedPeers = new Set([
nodeB.peerInfo.id.toB58String(), nodeB.peerInfo.id.toB58String(),
nodeC.peerInfo.id.toB58String() nodeC.peerInfo.id.toB58String()
]) ])
@ -421,7 +421,7 @@ describe('peer discovery', () => {
}) })
it('find peers through the dht', function (done) { it('find peers through the dht', function (done) {
let expectedPeers = new Set([ const expectedPeers = new Set([
nodeB.peerInfo.id.toB58String(), nodeB.peerInfo.id.toB58String(),
nodeC.peerInfo.id.toB58String() nodeC.peerInfo.id.toB58String()
]) ])

View File

@ -50,14 +50,14 @@ describe('private network', () => {
it('should create a libp2p node with a provided protector', () => { it('should create a libp2p node with a provided protector', () => {
let node let node
let protector = { const protector = {
psk: '123', psk: '123',
tag: '/psk/1.0.0', tag: '/psk/1.0.0',
protect: () => { } protect: () => { }
} }
expect(() => { expect(() => {
let options = defaultsDeep(config, { const options = defaultsDeep(config, {
modules: { modules: {
connProtector: protector connProtector: protector
} }
@ -71,7 +71,7 @@ describe('private network', () => {
it('should throw an error if the protector does not have a protect method', () => { it('should throw an error if the protector does not have a protect method', () => {
expect(() => { expect(() => {
let options = defaultsDeep(config, { const options = defaultsDeep(config, {
modules: { modules: {
connProtector: { } connProtector: { }
} }