6 changed files with 3 additions and 137 deletions
@ -1,38 +0,0 @@ |
|||||
'use strict'; |
|
||||
|
|
||||
var chai = require('chai'); |
|
||||
var bitcore = require('../..'); |
|
||||
|
|
||||
var should = chai.should(); |
|
||||
|
|
||||
var ConnectionModule = bitcore.transport.Connection; |
|
||||
var Connection; |
|
||||
var nop = function() {}; |
|
||||
|
|
||||
describe('Connection', function() { |
|
||||
it('should initialze the main object', function() { |
|
||||
should.exist(ConnectionModule); |
|
||||
}); |
|
||||
|
|
||||
it('should be able to create class', function() { |
|
||||
Connection = ConnectionModule; |
|
||||
should.exist(Connection); |
|
||||
}); |
|
||||
|
|
||||
it('should be able to create instance', function() { |
|
||||
var mSocket = {server: null, addListener: nop}, |
|
||||
mPeer; |
|
||||
var c = new Connection(mSocket, mPeer); |
|
||||
should.exist(c); |
|
||||
}); |
|
||||
|
|
||||
if (typeof process !== 'undefined' && process.versions) { //node-only tests
|
|
||||
it('should create a proxied socket if instructed', function() { |
|
||||
var mPeer; |
|
||||
var c = new Connection(null, mPeer, { |
|
||||
proxy: { host: 'localhost', port: 9050 } |
|
||||
}); |
|
||||
should.exist(c.socket); |
|
||||
}); |
|
||||
}; |
|
||||
}); |
|
@ -1,52 +0,0 @@ |
|||||
'use strict'; |
|
||||
|
|
||||
var chai = require('chai'); |
|
||||
var bitcore = require('../..'); |
|
||||
|
|
||||
var should = chai.should(); |
|
||||
|
|
||||
var PeerModule = bitcore.transport.Peer; |
|
||||
var Peer; |
|
||||
|
|
||||
describe('Peer', function() { |
|
||||
it('should initialze the main object', function() { |
|
||||
should.exist(PeerModule); |
|
||||
}); |
|
||||
|
|
||||
it('should be able to create class', function() { |
|
||||
Peer = PeerModule; |
|
||||
should.exist(Peer); |
|
||||
}); |
|
||||
|
|
||||
it('should be able to create instance', function() { |
|
||||
var p = new Peer('localhost', 8333); |
|
||||
should.exist(p); |
|
||||
}); |
|
||||
|
|
||||
it('should be able to create instance', function() { |
|
||||
var p = new Peer('localhost:8333'); |
|
||||
should.exist(p); |
|
||||
}); |
|
||||
|
|
||||
it('should be able to create instance', function() { |
|
||||
var p = new Peer('localhost:8333'); |
|
||||
var p2 = new Peer(p); |
|
||||
should.exist(p2); |
|
||||
}); |
|
||||
|
|
||||
it('should not be able to create instance', function() { |
|
||||
should.throw(function() { |
|
||||
new Peer(8333); |
|
||||
}); |
|
||||
}); |
|
||||
|
|
||||
it('should be able to create instance', function() { |
|
||||
var p = new Peer('localhost', 8333); |
|
||||
p.toString().should.equal('localhost:8333'); |
|
||||
}); |
|
||||
|
|
||||
it('check host as buffer', function() { |
|
||||
var p = new Peer('127.0.0.1', 8333); |
|
||||
p.getHostAsBuffer().toString('hex').should.equal('7f000001'); |
|
||||
}); |
|
||||
}); |
|
@ -1,42 +0,0 @@ |
|||||
'use strict'; |
|
||||
|
|
||||
var chai = require('chai'); |
|
||||
var bitcore = require('../..'); |
|
||||
|
|
||||
var should = chai.should(); |
|
||||
|
|
||||
var PeerManager = bitcore.transport.PeerManager; |
|
||||
|
|
||||
describe('PeerManager', function() { |
|
||||
it('should be able to create class', function() { |
|
||||
should.exist(PeerManager); |
|
||||
}); |
|
||||
|
|
||||
it('should be able to create instance', function() { |
|
||||
var pm = new PeerManager(); |
|
||||
should.exist(pm); |
|
||||
}); |
|
||||
|
|
||||
it('should be able to start instance', function() { |
|
||||
var pm = new PeerManager(); |
|
||||
pm.start.bind(pm).should.not.throw(); |
|
||||
}); |
|
||||
|
|
||||
it('should be able to stop instance', function() { |
|
||||
var pm = new PeerManager(); |
|
||||
pm.start(); |
|
||||
pm.stop.bind(pm).should.not.throw(); |
|
||||
}); |
|
||||
|
|
||||
it('should extend default config with passed config', function() { |
|
||||
var pm = new PeerManager({ |
|
||||
proxy: { |
|
||||
host: 'localhost', |
|
||||
port: 9050 |
|
||||
} |
|
||||
}); |
|
||||
|
|
||||
should.exist(pm.config.network); |
|
||||
should.exist(pm.config.proxy); |
|
||||
}); |
|
||||
}); |
|
Loading…
Reference in new issue