Skip to content

Commit

Permalink
Add test for Reject message
Browse files Browse the repository at this point in the history
  • Loading branch information
smh committed Dec 15, 2015
1 parent 1dfdd66 commit 6a88aaa
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/messages/commands/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

var should = require('chai').should();
var expect = require('chai').expect;
var P2P = require('../../../');
var Messages = P2P.Messages;
var sinon = require('sinon');
Expand Down Expand Up @@ -263,6 +264,28 @@ describe('Command Messages', function() {
});
});

describe('Reject', function() {
it('should set properties from arg in constructor', function() {
var message = messages.Reject({
message: 'tx',
ccode: 0x01,
reason: 'transaction is malformed',
data: new Buffer('12345678901234567890123456789012', 'hex')
});
message.message.should.equal('tx');
message.ccode.should.equal(0x01);
message.reason.should.equal('transaction is malformed');
message.data.toString('hex').should.equal('12345678901234567890123456789012');
});
it('should let arg be optional in constructor', function() {
var message = messages.Reject();
expect(message.message).to.be.undefined;
expect(message.ccode).to.be.undefined;
expect(message.reason).to.be.undefined;
expect(message.data).to.be.undefined;
});
});

describe('Version', function() {
it('should set the default relay property as true', function() {
var message = messages.Version();
Expand Down

0 comments on commit 6a88aaa

Please sign in to comment.