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

Commit

Permalink
test: add additional pnet tests
Browse files Browse the repository at this point in the history
temporarily use a temp branch of pull-reader for testing
  • Loading branch information
jacobheun committed Jul 3, 2018
1 parent 045adbb commit b7f5906
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 32 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
Expand Down
109 changes: 78 additions & 31 deletions test/pnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand All @@ -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)
})

Expand Down Expand Up @@ -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([
Expand All @@ -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([
Expand All @@ -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()
})
Expand Down

0 comments on commit b7f5906

Please sign in to comment.