added test for version message handling
This commit is contained in:
parent
6db209b9b6
commit
1545abbea0
34
test/peer.js
34
test/peer.js
@ -71,7 +71,6 @@ describe('Peer', function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('create instance', function() {
|
||||
var peer = new Peer('localhost');
|
||||
peer.host.should.equal('localhost');
|
||||
@ -168,6 +167,39 @@ describe('Peer', function() {
|
||||
|
||||
});
|
||||
|
||||
it('should send version on version if not already sent', function(done) {
|
||||
var peer = new Peer({host:'localhost'});
|
||||
var commands = {};
|
||||
peer.sendMessage = function(message) {
|
||||
commands[message.command] = true;
|
||||
if (commands.verack && commands.version) {
|
||||
done();
|
||||
}
|
||||
};
|
||||
peer.socket = {};
|
||||
peer.emit('version', {
|
||||
version: 'version',
|
||||
subversion: 'subversion',
|
||||
startHeight: 'startHeight'
|
||||
});
|
||||
});
|
||||
|
||||
it('should not send version on version if already sent', function(done) {
|
||||
var peer = new Peer({host:'localhost'});
|
||||
peer.versionSent = true;
|
||||
var commands = {};
|
||||
peer.sendMessage = function(message) {
|
||||
message.command.should.not.equal('version');
|
||||
done();
|
||||
};
|
||||
peer.socket = {};
|
||||
peer.emit('version', {
|
||||
version: 'version',
|
||||
subversion: 'subversion',
|
||||
startHeight: 'startHeight'
|
||||
});
|
||||
});
|
||||
|
||||
it('relay set properly', function() {
|
||||
var peer = new Peer({host: 'localhost'});
|
||||
peer.relay.should.equal(true);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user