Skip to content

Commit 78035e4

Browse files
committed
test: group tests
1 parent 8b53921 commit 78035e4

File tree

2 files changed

+60
-57
lines changed

2 files changed

+60
-57
lines changed

test/nodejs-bundle/circuit.js

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe(`circuit`, function () {
103103
nodeTCP1 = node
104104
cb()
105105
}),
106-
// set up node with TCP and listening on relay1 over TCP transport
106+
// set up node with TCP and listening on relay2 over TCP transport
107107
(cb) => setupNode([
108108
`/ip4/0.0.0.0/tcp/9311`,
109109
`/ip4/0.0.0.0/tcp/9111/ipfs/${relayNode2.peerInfo.id.toB58String()}/p2p-circuit`
@@ -133,68 +133,72 @@ describe(`circuit`, function () {
133133
], done)
134134
})
135135

136-
it('should dial from WS1 to TCP1 over any R', function (done) {
137-
nodeWS1.dial(nodeTCP1.peerInfo, '/echo/1.0.0', (err, conn) => {
138-
expect(err).to.not.exist()
139-
expect(conn).to.exist()
140-
141-
pull(
142-
pull.values(['hello']),
143-
conn,
144-
pull.collect((e, result) => {
145-
expect(e).to.not.exist()
146-
expect(result[0].toString()).to.equal('hello')
147-
done()
148-
})
149-
)
136+
describe(`any relay`, function () {
137+
it('should dial from WS1 to TCP1 over any R', function (done) {
138+
nodeWS1.dial(nodeTCP1.peerInfo, '/echo/1.0.0', (err, conn) => {
139+
expect(err).to.not.exist()
140+
expect(conn).to.exist()
141+
142+
pull(
143+
pull.values(['hello']),
144+
conn,
145+
pull.collect((e, result) => {
146+
expect(e).to.not.exist()
147+
expect(result[0].toString()).to.equal('hello')
148+
done()
149+
})
150+
)
151+
})
150152
})
151-
})
152153

153-
it('should dial from WS1 to TCP1 over R1', function (done) {
154-
nodeWS1.dial(nodeTCP1.peerInfo, '/echo/1.0.0', (err, conn) => {
155-
expect(err).to.not.exist()
156-
expect(conn).to.exist()
157-
158-
pull(
159-
pull.values(['hello']),
160-
conn,
161-
pull.collect((e, result) => {
162-
expect(e).to.not.exist()
163-
expect(result[0].toString()).to.equal('hello')
164-
165-
const addr = multiaddr(handlerSpies[0].args[2][0].dstPeer.addrs[0]).toString()
166-
expect(addr).to.equal(`/ipfs/${nodeTCP1.peerInfo.id.toB58String()}`)
167-
done()
168-
})
169-
)
154+
it(`should not dial - no R from WS2 to TCP1`, function (done) {
155+
nodeWS2.dial(nodeTCP2.peerInfo, '/echo/1.0.0', (err, conn) => {
156+
expect(err).to.exist()
157+
expect(conn).to.not.exist()
158+
done()
159+
})
170160
})
171161
})
172162

173-
it(`should dial from WS1 to TCP2 over R2`, function (done) {
174-
nodeWS1.dial(nodeTCP2.peerInfo, '/echo/1.0.0', (err, conn) => {
175-
expect(err).to.not.exist()
176-
expect(conn).to.exist()
177-
178-
pull(
179-
pull.values(['hello']),
180-
conn,
181-
pull.collect((e, result) => {
182-
expect(e).to.not.exist()
183-
expect(result[0].toString()).to.equal('hello')
184-
185-
const addr = multiaddr(handlerSpies[1].args[2][0].dstPeer.addrs[0]).toString()
186-
expect(addr).to.equal(`/ipfs/${nodeTCP2.peerInfo.id.toB58String()}`)
187-
done()
188-
})
189-
)
163+
describe(`explicit relay`, function () {
164+
it('should dial from WS1 to TCP1 over R1', function (done) {
165+
nodeWS1.dial(nodeTCP1.peerInfo, '/echo/1.0.0', (err, conn) => {
166+
expect(err).to.not.exist()
167+
expect(conn).to.exist()
168+
169+
pull(
170+
pull.values(['hello']),
171+
conn,
172+
pull.collect((e, result) => {
173+
expect(e).to.not.exist()
174+
expect(result[0].toString()).to.equal('hello')
175+
176+
const addr = multiaddr(handlerSpies[0].args[2][0].dstPeer.addrs[0]).toString()
177+
expect(addr).to.equal(`/ipfs/${nodeTCP1.peerInfo.id.toB58String()}`)
178+
done()
179+
})
180+
)
181+
})
190182
})
191-
})
192183

193-
it(`should not dial - no R from WS2 to TCP1`, function (done) {
194-
nodeWS2.dial(nodeTCP2.peerInfo, '/echo/1.0.0', (err, conn) => {
195-
expect(err).to.exist()
196-
expect(conn).to.not.exist()
197-
done()
184+
it(`should dial from WS1 to TCP2 over R2`, function (done) {
185+
nodeWS1.dial(nodeTCP2.peerInfo, '/echo/1.0.0', (err, conn) => {
186+
expect(err).to.not.exist()
187+
expect(conn).to.exist()
188+
189+
pull(
190+
pull.values(['hello']),
191+
conn,
192+
pull.collect((e, result) => {
193+
expect(e).to.not.exist()
194+
expect(result[0].toString()).to.equal('hello')
195+
196+
const addr = multiaddr(handlerSpies[1].args[2][0].dstPeer.addrs[0]).toString()
197+
expect(addr).to.equal(`/ipfs/${nodeTCP2.peerInfo.id.toB58String()}`)
198+
done()
199+
})
200+
)
201+
})
198202
})
199203
})
200204
})

test/nodejs-bundle/utils.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const waterfall = require('async/waterfall')
1010
const pull = require('pull-stream')
1111

1212
function createNode (multiaddrs, options, callback) {
13-
options = options || {}
1413
if (typeof options === 'function') {
1514
callback = options
1615
options = {}

0 commit comments

Comments
 (0)