Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit b7f5906

Browse files
committed
test: add additional pnet tests
temporarily use a temp branch of pull-reader for testing
1 parent 045adbb commit b7f5906

File tree

2 files changed

+80
-32
lines changed

2 files changed

+80
-32
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
"ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#master",
7676
"libp2p-pnet": "github:libp2p/js-libp2p-pnet#feat/initial",
7777
"libp2p": "github:libp2p/js-libp2p#feat/priv-net",
78-
"libp2p-switch": "github:libp2p/js-libp2p-switch#feat/priv-net"
78+
"libp2p-switch": "github:libp2p/js-libp2p-switch#feat/priv-net",
79+
"pull-reader": "github:jacobheun/pull-reader#overreading"
7980
},
8081
"dependencies": {},
8182
"contributors": []

test/pnet.js

+78-31
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ describe('Private network', function () {
7272
let jsPrivateDaemon
7373
let jsSameNetworkDaemon
7474
let jsDiffNetworkDaemon
75-
// let goPublicNetworkDaemon
76-
// let jsPublicNetworkDaemon
75+
let goPublicNetworkDaemon
76+
let jsPublicNetworkDaemon
7777

7878
before('start the nodes', function (done) {
7979
this.timeout(45 * 1000)
@@ -83,16 +83,26 @@ describe('Private network', function () {
8383
(cb) => startIpfsNode(goDf, goDiffNetworkRepoPath, networkBKey, cb),
8484
(cb) => startIpfsNode(jsDf, jsPrivateRepoPath, networkAKey, cb),
8585
(cb) => startIpfsNode(jsDf, jsSameNetworkRepoPath, networkAKey, cb),
86-
(cb) => startIpfsNode(jsDf, jsDiffNetworkRepoPath, networkBKey, cb)
86+
(cb) => startIpfsNode(jsDf, jsDiffNetworkRepoPath, networkBKey, cb),
8787
// Create and start 1 public go node
88-
// (cb) => goDf.spawn((err, daemon) => {
89-
// if (err) {
90-
// return cb(err)
91-
// }
92-
93-
// goPublicNetworkDaemon = daemon
94-
// goPublicNetworkDaemon.start(cb)
95-
// })
88+
(cb) => goDf.spawn((err, daemon) => {
89+
if (err) {
90+
return cb(err)
91+
}
92+
93+
goPublicNetworkDaemon = daemon
94+
goPublicNetworkDaemon.start(cb)
95+
}),
96+
// Create and start 1 public js node
97+
(cb) => jsDf.spawn((err, daemon) => {
98+
if (err) {
99+
return cb(err)
100+
}
101+
102+
jsPublicNetworkDaemon = daemon
103+
// jsPublicNetworkDaemon.start(cb)
104+
cb()
105+
})
96106
], (err, nodes) => {
97107
goSameNetworkDaemon = nodes[0]
98108
goDiffNetworkDaemon = nodes[1]
@@ -109,8 +119,9 @@ describe('Private network', function () {
109119
(cb) => goDiffNetworkDaemon.stop(cb),
110120
(cb) => jsPrivateDaemon.stop(cb),
111121
(cb) => jsSameNetworkDaemon.stop(cb),
112-
(cb) => jsDiffNetworkDaemon.stop(cb)
113-
// (cb) => jsD.stop(cb)
122+
(cb) => jsDiffNetworkDaemon.stop(cb),
123+
(cb) => goPublicNetworkDaemon.stop(cb),
124+
(cb) => jsPublicNetworkDaemon.stop(cb)
114125
], done)
115126
})
116127

@@ -210,15 +221,8 @@ describe('Private network', function () {
210221
})
211222
})
212223

213-
/**
214-
* Skipping while https://github.com/dominictarr/pull-reader/issues/5 is unresolved
215-
* These tests will regularly timeout. Rather than basing the tests on timeouts,
216-
* they are being skipped until functionality is updated to properly end
217-
* bad connection attempts
218-
*/
219-
describe.skip('go <-> js on different private networks', () => {
220-
it('should NOT be able to connect go <-> js', function (done) {
221-
this.timeout(20 * 1000)
224+
describe('go <-> js on different private networks', () => {
225+
it('should NOT be able to connect go <-> js', (done) => {
222226
let goId
223227

224228
series([
@@ -232,21 +236,16 @@ describe('Private network', function () {
232236
}),
233237
(cb) => jsPrivateDaemon.api.swarm.connect(goId.addresses[0], cb)
234238
], (err) => {
239+
// These errors are currently a bit random depending on who sends data first
240+
// This could be muxing errors, overreading errors, or stream destroyed errors
235241
expect(err).to.exist()
236242
done()
237243
})
238244
})
239245
})
240246

241-
/**
242-
* Skipping while https://github.com/dominictarr/pull-reader/issues/5 is unresolved
243-
* These tests will regularly timeout. Rather than basing the tests on timeouts,
244-
* they are being skipped until functionality is updated to properly end
245-
* bad connection attempts
246-
*/
247-
describe.skip('js <-> js on different private networks', () => {
248-
it('should NOT be able to connect js <-> js', function (done) {
249-
this.timeout(20 * 1000)
247+
describe('js <-> js on different private networks', () => {
248+
it('should NOT be able to connect js <-> js', (done) => {
250249
let jsDiffId
251250

252251
series([
@@ -260,6 +259,54 @@ describe('Private network', function () {
260259
}),
261260
(cb) => jsPrivateDaemon.api.swarm.connect(jsDiffId.addresses[0], cb)
262261
], (err) => {
262+
// These errors are currently a bit random depending on who sends data first
263+
// This could be muxing errors, overreading errors, or stream destroyed errors
264+
expect(err).to.exist()
265+
done()
266+
})
267+
})
268+
})
269+
270+
describe('js private network <-> go public network', () => {
271+
it('should NOT be able to connect js <-> go', (done) => {
272+
let goPubId
273+
274+
series([
275+
(cb) => parallel([
276+
(cb) => jsPrivateDaemon.api.id(cb),
277+
(cb) => goPublicNetworkDaemon.api.id(cb)
278+
], (err, ids) => {
279+
expect(err).to.not.exist()
280+
goPubId = ids[1]
281+
cb()
282+
}),
283+
(cb) => jsPrivateDaemon.api.swarm.connect(goPubId.addresses[0], cb)
284+
], (err) => {
285+
// These errors are currently a bit random depending on who sends data first
286+
// This could be muxing errors, bad nonce, or stream destroyed errors
287+
expect(err).to.exist()
288+
done()
289+
})
290+
})
291+
})
292+
293+
describe('js private network <-> js public network', () => {
294+
it('should NOT be able to connect js <-> js', (done) => {
295+
let jsPubId
296+
297+
series([
298+
(cb) => parallel([
299+
(cb) => jsPrivateDaemon.api.id(cb),
300+
(cb) => jsPublicNetworkDaemon.api.id(cb)
301+
], (err, ids) => {
302+
expect(err).to.not.exist()
303+
jsPubId = ids[1]
304+
cb()
305+
}),
306+
(cb) => jsPrivateDaemon.api.swarm.connect(jsPubId.addresses[0], cb)
307+
], (err) => {
308+
// These errors are currently a bit random depending on who sends data first
309+
// This could be muxing errors, bad nonce, or stream destroyed errors
263310
expect(err).to.exist()
264311
done()
265312
})

0 commit comments

Comments
 (0)