From b7f5906b01a99c71ba24a4399b1b988d25bf68da Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Wed, 4 Jul 2018 01:43:29 +0200 Subject: [PATCH] test: add additional pnet tests temporarily use a temp branch of pull-reader for testing --- package.json | 3 +- test/pnet.js | 109 ++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 80 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 3294a151..6f64e5de 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,8 @@ "ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#master", "libp2p-pnet": "github:libp2p/js-libp2p-pnet#feat/initial", "libp2p": "github:libp2p/js-libp2p#feat/priv-net", - "libp2p-switch": "github:libp2p/js-libp2p-switch#feat/priv-net" + "libp2p-switch": "github:libp2p/js-libp2p-switch#feat/priv-net", + "pull-reader": "github:jacobheun/pull-reader#overreading" }, "dependencies": {}, "contributors": [] diff --git a/test/pnet.js b/test/pnet.js index 80ad22ca..3f7b7e43 100644 --- a/test/pnet.js +++ b/test/pnet.js @@ -72,8 +72,8 @@ describe('Private network', function () { let jsPrivateDaemon let jsSameNetworkDaemon let jsDiffNetworkDaemon - // let goPublicNetworkDaemon - // let jsPublicNetworkDaemon + let goPublicNetworkDaemon + let jsPublicNetworkDaemon before('start the nodes', function (done) { this.timeout(45 * 1000) @@ -83,16 +83,26 @@ describe('Private network', function () { (cb) => startIpfsNode(goDf, goDiffNetworkRepoPath, networkBKey, cb), (cb) => startIpfsNode(jsDf, jsPrivateRepoPath, networkAKey, cb), (cb) => startIpfsNode(jsDf, jsSameNetworkRepoPath, networkAKey, cb), - (cb) => startIpfsNode(jsDf, jsDiffNetworkRepoPath, networkBKey, cb) + (cb) => startIpfsNode(jsDf, jsDiffNetworkRepoPath, networkBKey, cb), // Create and start 1 public go node - // (cb) => goDf.spawn((err, daemon) => { - // if (err) { - // return cb(err) - // } - - // goPublicNetworkDaemon = daemon - // goPublicNetworkDaemon.start(cb) - // }) + (cb) => goDf.spawn((err, daemon) => { + if (err) { + return cb(err) + } + + goPublicNetworkDaemon = daemon + goPublicNetworkDaemon.start(cb) + }), + // Create and start 1 public js node + (cb) => jsDf.spawn((err, daemon) => { + if (err) { + return cb(err) + } + + jsPublicNetworkDaemon = daemon + // jsPublicNetworkDaemon.start(cb) + cb() + }) ], (err, nodes) => { goSameNetworkDaemon = nodes[0] goDiffNetworkDaemon = nodes[1] @@ -109,8 +119,9 @@ describe('Private network', function () { (cb) => goDiffNetworkDaemon.stop(cb), (cb) => jsPrivateDaemon.stop(cb), (cb) => jsSameNetworkDaemon.stop(cb), - (cb) => jsDiffNetworkDaemon.stop(cb) - // (cb) => jsD.stop(cb) + (cb) => jsDiffNetworkDaemon.stop(cb), + (cb) => goPublicNetworkDaemon.stop(cb), + (cb) => jsPublicNetworkDaemon.stop(cb) ], done) }) @@ -210,15 +221,8 @@ describe('Private network', function () { }) }) - /** - * Skipping while https://github.com/dominictarr/pull-reader/issues/5 is unresolved - * These tests will regularly timeout. Rather than basing the tests on timeouts, - * they are being skipped until functionality is updated to properly end - * bad connection attempts - */ - describe.skip('go <-> js on different private networks', () => { - it('should NOT be able to connect go <-> js', function (done) { - this.timeout(20 * 1000) + describe('go <-> js on different private networks', () => { + it('should NOT be able to connect go <-> js', (done) => { let goId series([ @@ -232,21 +236,16 @@ describe('Private network', function () { }), (cb) => jsPrivateDaemon.api.swarm.connect(goId.addresses[0], cb) ], (err) => { + // These errors are currently a bit random depending on who sends data first + // This could be muxing errors, overreading errors, or stream destroyed errors expect(err).to.exist() done() }) }) }) - /** - * Skipping while https://github.com/dominictarr/pull-reader/issues/5 is unresolved - * These tests will regularly timeout. Rather than basing the tests on timeouts, - * they are being skipped until functionality is updated to properly end - * bad connection attempts - */ - describe.skip('js <-> js on different private networks', () => { - it('should NOT be able to connect js <-> js', function (done) { - this.timeout(20 * 1000) + describe('js <-> js on different private networks', () => { + it('should NOT be able to connect js <-> js', (done) => { let jsDiffId series([ @@ -260,6 +259,54 @@ describe('Private network', function () { }), (cb) => jsPrivateDaemon.api.swarm.connect(jsDiffId.addresses[0], cb) ], (err) => { + // These errors are currently a bit random depending on who sends data first + // This could be muxing errors, overreading errors, or stream destroyed errors + expect(err).to.exist() + done() + }) + }) + }) + + describe('js private network <-> go public network', () => { + it('should NOT be able to connect js <-> go', (done) => { + let goPubId + + series([ + (cb) => parallel([ + (cb) => jsPrivateDaemon.api.id(cb), + (cb) => goPublicNetworkDaemon.api.id(cb) + ], (err, ids) => { + expect(err).to.not.exist() + goPubId = ids[1] + cb() + }), + (cb) => jsPrivateDaemon.api.swarm.connect(goPubId.addresses[0], cb) + ], (err) => { + // These errors are currently a bit random depending on who sends data first + // This could be muxing errors, bad nonce, or stream destroyed errors + expect(err).to.exist() + done() + }) + }) + }) + + describe('js private network <-> js public network', () => { + it('should NOT be able to connect js <-> js', (done) => { + let jsPubId + + series([ + (cb) => parallel([ + (cb) => jsPrivateDaemon.api.id(cb), + (cb) => jsPublicNetworkDaemon.api.id(cb) + ], (err, ids) => { + expect(err).to.not.exist() + jsPubId = ids[1] + cb() + }), + (cb) => jsPrivateDaemon.api.swarm.connect(jsPubId.addresses[0], cb) + ], (err) => { + // These errors are currently a bit random depending on who sends data first + // This could be muxing errors, bad nonce, or stream destroyed errors expect(err).to.exist() done() })