Skip to content

Commit

Permalink
make coveralls happy
Browse files Browse the repository at this point in the history
  • Loading branch information
yusefnapora committed Feb 10, 2017
1 parent e35d60e commit 48b9237
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
11 changes: 11 additions & 0 deletions test/peer/directory_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ describe('Directory Node', function () {
}))
})

it('node can set directory with string multiaddr', () => {
const dirInfo = dir.p2p.peerInfo
const dirId = dirInfo.id
const addrString = dirInfo.multiaddrs[0].toString() + '/p2p/' + dirId.toB58String()
expect(() =>
node.setDirectory(addrString)
).to.not.throw()

node.setDirectory(dirInfo)
})

it('responds to lookup requests for known peers', function () {
// just stuff the node's id into the directory manually
dir.peerBook.put(node.peerInfo)
Expand Down
13 changes: 9 additions & 4 deletions test/peer/node_info_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
const assert = require('assert')
const { before, describe, it } = require('mocha')
const { makeNode } = require('../util')
const { PublisherId } = require('../../src/peer/identity')

describe('Node Info', function () {
const infoMessage = 'tests are great!'

let p1, p2
before(() => Promise.all([
makeNode({listenAddresses: ['/ip4/127.0.0.1/tcp/9090/ws']}).then(_p1 => { p1 = _p1 }),
makeNode({listenAddresses: ['/ip4/127.0.0.1/tcp/9091/ws']}).then(_p2 => { p2 = _p2; p2.setInfoMessage(infoMessage) })
]))
before(() => PublisherId.generate()
.then(publisherId => Promise.all([
makeNode({listenAddresses: ['/ip4/127.0.0.1/tcp/9090/ws']}).then(_p1 => { p1 = _p1 }),
makeNode({publisherId, listenAddresses: ['/ip4/127.0.0.1/tcp/9091/ws']}).then(_p2 => { p2 = _p2; p2.setInfoMessage(infoMessage) })
]))
)

it('retrieves the ids and info message from another node', () => {
return Promise.all([p1.start(), p2.start()]) // start both peers
Expand All @@ -21,6 +24,8 @@ describe('Node Info', function () {
'node info response should include correct peer id')
assert.equal(result.info, infoMessage,
'node info response should include correct info message')
assert.equal(result.publisher, p2.publisherId.id58,
'if remote node has a publisher id, it should be included')
})
.then(() => Promise.all([p1.stop(), p2.stop()]))
})
Expand Down

0 comments on commit 48b9237

Please sign in to comment.