Skip to content

Commit

Permalink
test: group tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov committed Aug 22, 2017
1 parent 8b53921 commit 3c16d0a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 56 deletions.
114 changes: 59 additions & 55 deletions test/nodejs-bundle/circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,68 +133,72 @@ describe(`circuit`, function () {
], done)
})

it('should dial from WS1 to TCP1 over any R', function (done) {
nodeWS1.dial(nodeTCP1.peerInfo, '/echo/1.0.0', (err, conn) => {
expect(err).to.not.exist()
expect(conn).to.exist()

pull(
pull.values(['hello']),
conn,
pull.collect((e, result) => {
expect(e).to.not.exist()
expect(result[0].toString()).to.equal('hello')
done()
})
)
describe(`any relay`, function () {
it('should dial from WS1 to TCP1 over any R', function (done) {
nodeWS1.dial(nodeTCP1.peerInfo, '/echo/1.0.0', (err, conn) => {
expect(err).to.not.exist()
expect(conn).to.exist()

pull(
pull.values(['hello']),
conn,
pull.collect((e, result) => {
expect(e).to.not.exist()
expect(result[0].toString()).to.equal('hello')
done()
})
)
})
})
})

it('should dial from WS1 to TCP1 over R1', function (done) {
nodeWS1.dial(nodeTCP1.peerInfo, '/echo/1.0.0', (err, conn) => {
expect(err).to.not.exist()
expect(conn).to.exist()

pull(
pull.values(['hello']),
conn,
pull.collect((e, result) => {
expect(e).to.not.exist()
expect(result[0].toString()).to.equal('hello')

const addr = multiaddr(handlerSpies[0].args[2][0].dstPeer.addrs[0]).toString()
expect(addr).to.equal(`/ipfs/${nodeTCP1.peerInfo.id.toB58String()}`)
done()
})
)
it(`should not dial - no R from WS2 to TCP1`, function (done) {
nodeWS2.dial(nodeTCP2.peerInfo, '/echo/1.0.0', (err, conn) => {
expect(err).to.exist()
expect(conn).to.not.exist()
done()
})
})
})

it(`should dial from WS1 to TCP2 over R2`, function (done) {
nodeWS1.dial(nodeTCP2.peerInfo, '/echo/1.0.0', (err, conn) => {
expect(err).to.not.exist()
expect(conn).to.exist()

pull(
pull.values(['hello']),
conn,
pull.collect((e, result) => {
expect(e).to.not.exist()
expect(result[0].toString()).to.equal('hello')

const addr = multiaddr(handlerSpies[1].args[2][0].dstPeer.addrs[0]).toString()
expect(addr).to.equal(`/ipfs/${nodeTCP2.peerInfo.id.toB58String()}`)
done()
})
)
describe(`explicit relay`, function () {
it('should dial from WS1 to TCP1 over R1', function (done) {
nodeWS1.dial(nodeTCP1.peerInfo, '/echo/1.0.0', (err, conn) => {
expect(err).to.not.exist()
expect(conn).to.exist()

pull(
pull.values(['hello']),
conn,
pull.collect((e, result) => {
expect(e).to.not.exist()
expect(result[0].toString()).to.equal('hello')

const addr = multiaddr(handlerSpies[0].args[2][0].dstPeer.addrs[0]).toString()
expect(addr).to.equal(`/ipfs/${nodeTCP1.peerInfo.id.toB58String()}`)
done()
})
)
})
})
})

it(`should not dial - no R from WS2 to TCP1`, function (done) {
nodeWS2.dial(nodeTCP2.peerInfo, '/echo/1.0.0', (err, conn) => {
expect(err).to.exist()
expect(conn).to.not.exist()
done()
it(`should dial from WS1 to TCP2 over R2`, function (done) {
nodeWS1.dial(nodeTCP2.peerInfo, '/echo/1.0.0', (err, conn) => {
expect(err).to.not.exist()
expect(conn).to.exist()

pull(
pull.values(['hello']),
conn,
pull.collect((e, result) => {
expect(e).to.not.exist()
expect(result[0].toString()).to.equal('hello')

const addr = multiaddr(handlerSpies[1].args[2][0].dstPeer.addrs[0]).toString()
expect(addr).to.equal(`/ipfs/${nodeTCP2.peerInfo.id.toB58String()}`)
done()
})
)
})
})
})
})
1 change: 0 additions & 1 deletion test/nodejs-bundle/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const waterfall = require('async/waterfall')
const pull = require('pull-stream')

function createNode (multiaddrs, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
Expand Down

0 comments on commit 3c16d0a

Please sign in to comment.