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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restructure and add spdy to browser tests
- Loading branch information
Showing
8 changed files
with
199 additions
and
108 deletions.
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,18 +37,20 @@ | |
"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-spdy": "^0.6.0", | ||
"libp2p-tcp": "^0.5.1", | ||
"libp2p-webrtc-star": "^0.1.0", | ||
"libp2p-websockets": "^0.5.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", | ||
|
@@ -79,4 +81,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
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,49 @@ | ||
/* 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 - webrtc-star', 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,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 | ||
}) |
Empty file.
Empty file.
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