add Address parameter test
This commit is contained in:
parent
cdd4df3cb3
commit
d632bbb4cd
|
@ -5,6 +5,7 @@ var expect = chai.expect;
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
var bitcore = require('bitcore');
|
var bitcore = require('bitcore');
|
||||||
|
var Address = bitcore.Address;
|
||||||
var Signature = bitcore.crypto.Signature;
|
var Signature = bitcore.crypto.Signature;
|
||||||
var Message = require('../');
|
var Message = require('../');
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ describe('Message', function() {
|
||||||
var publicKey = privateKey.toPublicKey();
|
var publicKey = privateKey.toPublicKey();
|
||||||
|
|
||||||
it('will error with incorrect message type', function() {
|
it('will error with incorrect message type', function() {
|
||||||
expect(function(){
|
expect(function() {
|
||||||
return new Message(new Date());
|
return new Message(new Date());
|
||||||
}).to.throw('First argument should be a string');
|
}).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() {
|
it('sign will error with incorrect private key argument', function() {
|
||||||
expect(function(){
|
expect(function() {
|
||||||
var message3 = new Message(text);
|
var message3 = new Message(text);
|
||||||
return message3.sign('not a private key');
|
return message3.sign('not a private key');
|
||||||
}).to.throw('First argument should be an instance of PrivateKey');
|
}).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() {
|
it('verify will error with incorrect public key argument', function() {
|
||||||
expect(function(){
|
expect(function() {
|
||||||
var message6 = new Message(text);
|
var message6 = new Message(text);
|
||||||
return message6._verify('not a public key', signature);
|
return message6._verify('not a public key', signature);
|
||||||
}).to.throw(TypeError);
|
}).to.throw(TypeError);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('verify will error with incorrect signature argument', function() {
|
it('verify will error with incorrect signature argument', function() {
|
||||||
expect(function(){
|
expect(function() {
|
||||||
var message7 = new Message(text);
|
var message7 = new Message(text);
|
||||||
return message7._verify(publicKey, 'not a signature');
|
return message7._verify(publicKey, 'not a signature');
|
||||||
}).to.throw(TypeError);
|
}).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);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue