This commit is contained in:
David Dias
2015-09-28 16:11:16 +01:00
4 changed files with 35 additions and 13 deletions

View File

@ -16,19 +16,20 @@ var Swarm = require('../src')
var tcp = require('libp2p-tcp')
var Spdy = require('libp2p-spdy')
/* TODO
experiment('Basics', function () {
test('enforces creation with new', function (done) {done() })
})
*/
// because of Travis-CI
process.on('uncaughtException', function (err) {
console.log('Caught exception: ' + err)
})
experiment('Without a peer', function () {
test('it throws an exception', function (done) {
experiment('Basics', function () {
test('enforces creation with new', function (done) {
expect(function () {
Swarm()
}).to.throw()
done()
})
test('it throws an exception without peerSelf', function (done) {
expect(function () {
var sw = new Swarm()
sw.close()
@ -37,6 +38,21 @@ experiment('Without a peer', function () {
})
})
experiment('When dialing', function () {
experiment('if the swarm does add any of the peer transports', function () {
test('it returns an error', function (done) {
var peerOne = new Peer(Id.create(), [multiaddr('/ip4/127.0.0.1/tcp/8090')])
var peerTwo = new Peer(Id.create(), [multiaddr('/ip4/127.0.0.1/tcp/8091')])
var swarm = new Swarm(peerOne)
swarm.dial(peerTwo, {}, function (err) {
expect(err).to.exist()
done()
})
})
})
})
experiment('Without a Stream Muxer', function () {
experiment('and one swarm over tcp', function () {
test('add the transport', function (done) {
@ -218,7 +234,6 @@ experiment('With a SPDY Stream Muxer', function () {
}
test('dial a conn on a protocol', function (done) {
sw2.handleProtocol('/sparkles/1.0.0', function (conn) {
// formallity so that the conn starts flowing
conn.on('data', function (chunk) {})