for indutny

This commit is contained in:
David Dias
2015-07-09 20:00:54 -07:00
parent f08d407bf9
commit 0aab8ead56
2 changed files with 49 additions and 8 deletions

View File

@ -23,24 +23,34 @@ beforeEach(function (done) {
swarmB = new Swarm()
var c = new Counter(2, done)
swarmA.listen(4000, function () {
swarmA.listen(8100, function () {
peerA = new Peer(Id.create(), [multiaddr('/ip4/127.0.0.1/tcp/' + swarmA.port)])
c.hit()
})
swarmB.listen(4001, function () {
swarmB.listen(8101, function () {
peerB = new Peer(Id.create(), [multiaddr('/ip4/127.0.0.1/tcp/' + swarmB.port)])
c.hit()
})
})
afterEach(function (done) {
var c = new Counter(2, done)
swarmA.close(function () {
afterEach({ timeout: 5000 }, function (done) {
var c = new Counter(4, done)
swarmA.closeConns(function () {
c.hit()
swarmA.closeListener(function () {
console.log('AAA CLOSE')
c.hit()
})
})
swarmB.close(function () {
swarmB.closeConns(function () {
console.log('bb')
c.hit()
swarmB.closeListener(function () {
console.log('BBB CLOSE')
c.hit()
})
})
})
@ -58,6 +68,20 @@ experiment('BASE', function () {
c.hit()
})
})
test('Reuse stream (from dialer)', {timeout: false}, function (done) {
var protocol = '/sparkles/3.3.3'
var c = new Counter(2, done)
swarmB.registerHandle(protocol, function (stream) {
c.hit()
})
swarmA.openStream(peerB, protocol, function (err, stream) {
expect(err).to.not.be.instanceof(Error)
c.hit()
})
})
})
experiment('IDENTIFY', function () {})