add Address parameter test

This commit is contained in:
Manuel Araoz 2015-02-05 11:09:30 -03:00
parent cdd4df3cb3
commit d632bbb4cd
1 changed files with 10 additions and 4 deletions

View File

@ -5,6 +5,7 @@ var expect = chai.expect;
var should = chai.should();
var bitcore = require('bitcore');
var Address = bitcore.Address;
var Signature = bitcore.crypto.Signature;
var Message = require('../');
@ -24,7 +25,7 @@ describe('Message', function() {
var publicKey = privateKey.toPublicKey();
it('will error with incorrect message type', function() {
expect(function(){
expect(function() {
return new Message(new Date());
}).to.throw('First argument should be a string');
});
@ -46,7 +47,7 @@ describe('Message', function() {
});
it('sign will error with incorrect private key argument', function() {
expect(function(){
expect(function() {
var message3 = new Message(text);
return message3.sign('not a private key');
}).to.throw('First argument should be an instance of PrivateKey');
@ -65,14 +66,14 @@ describe('Message', function() {
});
it('verify will error with incorrect public key argument', function() {
expect(function(){
expect(function() {
var message6 = new Message(text);
return message6._verify('not a public key', signature);
}).to.throw(TypeError);
});
it('verify will error with incorrect signature argument', function() {
expect(function(){
expect(function() {
var message7 = new Message(text);
return message7._verify(publicKey, 'not a signature');
}).to.throw(TypeError);
@ -146,5 +147,10 @@ describe('Message', function() {
});
it('accepts Address for verification', function() {
var verified = Message(text)
.verify(new Address(address), signatureString);
verified.should.equal(true);
});
});