This repository has been archived by the owner on Aug 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
restructure and add spdy to browser tests #64
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,21 +37,24 @@ | |
"node": "^4.3.0" | ||
}, | ||
"devDependencies": { | ||
"aegir": "^3.0.4", | ||
"bl": "^1.1.2", | ||
"buffer-loader": "0.0.1", | ||
"chai": "^3.5.0", | ||
"aegir": "^3.0.4", | ||
"gulp": "^3.9.1", | ||
"istanbul": "^0.4.3", | ||
"libp2p-multiplex": "^0.2.1", | ||
"libp2p-spdy": "^0.5.0", | ||
"libp2p-tcp": "^0.5.1", | ||
"libp2p-websockets": "^0.5.0", | ||
"libp2p-spdy": "^0.6.1", | ||
"libp2p-tcp": "^0.6.0", | ||
"libp2p-webrtc-star": "^0.1.3", | ||
"libp2p-websockets": "^0.6.0", | ||
"pre-commit": "^1.1.2", | ||
"stream-pair": "^1.0.3" | ||
"stream-pair": "^1.0.3", | ||
"webrtcsupport": "^2.2.0" | ||
}, | ||
"dependencies": { | ||
"babel-runtime": "^6.6.1", | ||
"browserify-zlib": "github:ipfs/browserify-zlib", | ||
"duplex-passthrough": "github:diasdavid/duplex-passthrough", | ||
"ip-address": "^5.8.0", | ||
"lodash.contains": "^2.4.3", | ||
|
@@ -79,4 +82,4 @@ | |
"Richard Littauer <[email protected]>", | ||
"dignifiedquire <[email protected]>" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const expect = require('chai').expect | ||
const multiaddr = require('multiaddr') | ||
const Id = require('peer-id') | ||
const Peer = require('peer-info') | ||
const WebSockets = require('libp2p-websockets') | ||
const bl = require('bl') | ||
|
||
const Swarm = require('../src') | ||
|
||
describe('transport - websockets', function () { | ||
this.timeout(10000) | ||
|
||
var swarm | ||
|
||
before(() => { | ||
const b58IdSrc = 'QmYzgdesgjdvD3okTPGZT9NPmh1BuH5FfTVNKjsvaAprhb' | ||
// use a pre generated Id to save time | ||
const idSrc = Id.createFromB58String(b58IdSrc) | ||
const peerSrc = new Peer(idSrc) | ||
swarm = new Swarm(peerSrc) | ||
}) | ||
|
||
it('add', (done) => { | ||
swarm.transport.add('ws', new WebSockets(), () => { | ||
expect(Object.keys(swarm.transports).length).to.equal(1) | ||
done() | ||
}) | ||
}) | ||
|
||
it('dial', (done) => { | ||
const ma = multiaddr('/ip4/127.0.0.1/tcp/9100/ws') | ||
|
||
const conn = swarm.transport.dial('ws', ma, (err, conn) => { | ||
expect(err).to.not.exist | ||
}) | ||
|
||
conn.pipe(bl((err, data) => { | ||
expect(err).to.not.exist | ||
expect(data.toString()).to.equal('hey') | ||
done() | ||
})) | ||
conn.write('hey') | ||
conn.end() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const expect = require('chai').expect | ||
const multiaddr = require('multiaddr') | ||
const peerId = require('peer-id') | ||
const PeerInfo = require('peer-info') | ||
const WebRTCStar = require('libp2p-webrtc-star') | ||
const bl = require('bl') | ||
const parallel = require('run-parallel') | ||
|
||
const Swarm = require('../src') | ||
|
||
describe('transport - webrtc-star', function () { | ||
this.timeout(10000) | ||
|
||
let swarm1 | ||
let peer1 | ||
|
||
let swarm2 | ||
let peer2 | ||
|
||
before(() => { | ||
const id1 = peerId.createFromB58String('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooooA') | ||
peer1 = new PeerInfo(id1) | ||
const mh1 = multiaddr('/libp2p-webrtc-star/ip4/127.0.0.1/tcp/15555/ws/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooooA') | ||
peer1.multiaddr.add(mh1) | ||
|
||
const id2 = peerId.createFromB58String('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooooB') | ||
peer2 = new PeerInfo(id2) | ||
const mh2 = multiaddr('/libp2p-webrtc-star/ip4/127.0.0.1/tcp/15555/ws/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooooB') | ||
peer2.multiaddr.add(mh2) | ||
|
||
swarm1 = new Swarm(peer1) | ||
swarm2 = new Swarm(peer2) | ||
}) | ||
|
||
it('add WebRTCStar transport to swarm 1', (done) => { | ||
swarm1.transport.add('wstar', new WebRTCStar(), () => { | ||
expect(Object.keys(swarm1.transports).length).to.equal(1) | ||
done() | ||
}) | ||
}) | ||
|
||
it('add WebRTCStar transport to swarm 2', (done) => { | ||
swarm2.transport.add('wstar', new WebRTCStar(), () => { | ||
expect(Object.keys(swarm2.transports).length).to.equal(1) | ||
done() | ||
}) | ||
}) | ||
|
||
it('listen on swarm 1', (done) => { | ||
swarm1.transport.listen('wstar', {}, (conn) => { | ||
conn.pipe(conn) | ||
}, done) | ||
}) | ||
|
||
it('listen on swarm 2', (done) => { | ||
swarm2.transport.listen('wstar', {}, (conn) => { | ||
conn.pipe(conn) | ||
}, done) | ||
}) | ||
|
||
it('dial', (done) => { | ||
swarm1.transport.dial('wstar', peer2.multiaddrs[0], (err, conn) => { | ||
expect(err).to.not.exist | ||
|
||
const text = 'Hello World' | ||
conn.pipe(bl((err, data) => { | ||
expect(err).to.not.exist | ||
expect(data.toString()).to.equal(text) | ||
done() | ||
})) | ||
|
||
conn.write(text) | ||
conn.end() | ||
}) | ||
}) | ||
|
||
it('close', (done) => { | ||
parallel([ | ||
(cb) => { | ||
swarm1.transport.close('wstar', cb) | ||
}, | ||
(cb) => { | ||
swarm2.transport.close('wstar', cb) | ||
} | ||
], done) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const expect = require('chai').expect | ||
const multiaddr = require('multiaddr') | ||
const Id = require('peer-id') | ||
const Peer = require('peer-info') | ||
const WebSockets = require('libp2p-websockets') | ||
// const spdy = require('libp2p-spdy') | ||
|
||
const Swarm = require('../src') | ||
|
||
describe('high level API (swarm with spdy + websockets)', function () { | ||
this.timeout(10000) | ||
|
||
var swarm | ||
var peerDst | ||
|
||
before(() => { | ||
const b58IdSrc = 'QmYzgdesgjdvD3okTPGZT9NPmh1BuH5FfTVNKjsvaAprhb' | ||
// use a pre generated Id to save time | ||
const idSrc = Id.createFromB58String(b58IdSrc) | ||
const peerSrc = new Peer(idSrc) | ||
swarm = new Swarm(peerSrc) | ||
}) | ||
|
||
it('add spdy', () => { | ||
// swarm.connection.addStreamMuxer(spdy) | ||
// swarm.connection.reuse() | ||
}) | ||
|
||
it('add ws', () => { | ||
swarm.transport.add('ws', new WebSockets()) | ||
expect(Object.keys(swarm.transports).length).to.equal(1) | ||
}) | ||
|
||
it('create Dst peer info', () => { | ||
const b58IdDst = 'QmRy1iU6BHmG5Hd8rnPhPL98cy1W1przUSTAMcGDq9yAAV' | ||
// use a pre generated Id to save time | ||
const idDst = Id.createFromB58String(b58IdDst) | ||
peerDst = new Peer(idDst) | ||
|
||
const ma = multiaddr('/ip4/127.0.0.1/tcp/9200/ws') | ||
peerDst.multiaddr.add(ma) | ||
}) | ||
|
||
it('dial to warm a conn', (done) => { | ||
swarm.dial(peerDst, (err) => { | ||
expect(err).to.not.exist | ||
done() | ||
}) | ||
}) | ||
|
||
it('dial on protocol, use warmed conn', (done) => { | ||
swarm.dial(peerDst, '/echo/1.0.0', (err, conn) => { | ||
expect(err).to.not.exist | ||
conn.end() | ||
conn.on('data', () => {}) // let it flow.. let it flooooow | ||
conn.on('end', done) | ||
}) | ||
}) | ||
|
||
it('close', (done) => { | ||
// cause CI is slow | ||
setTimeout(() => { | ||
swarm.close(done) | ||
}, 1000) | ||
}) | ||
|
||
// TODO - test that the listener (node.js peer) can dial back | ||
// do that by dialing on a protocol to activate that behaviour | ||
// like libp2p-spdy tests | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dignifiedquire spdy (or identify) wasn't being used for browser tests and I found that if I run them:
However, this is combination is used in several other places, including orbit. Are these tests missing anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you seeing these issues with
tcp
as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nop. It doesn't even happen with websockets just in Node.js, it only happens in the browser tests