From 6a88aaae9bf964bd322594ffe4ff35ec2407ad85 Mon Sep 17 00:00:00 2001 From: Stein Martin Hustad Date: Thu, 6 Aug 2015 20:33:53 +0200 Subject: [PATCH] Add test for Reject message --- test/messages/commands/index.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/messages/commands/index.js b/test/messages/commands/index.js index ae4d39e..9da412d 100644 --- a/test/messages/commands/index.js +++ b/test/messages/commands/index.js @@ -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'); @@ -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();