added sig_canonical tests
This commit is contained in:
parent
9e3d13a8ff
commit
17459dd7c2
@ -4,6 +4,10 @@ var should = require('chai').should();
|
|||||||
var bitcore = require('../..');
|
var bitcore = require('../..');
|
||||||
var BN = bitcore.crypto.BN;
|
var BN = bitcore.crypto.BN;
|
||||||
var Signature = bitcore.crypto.Signature;
|
var Signature = bitcore.crypto.Signature;
|
||||||
|
var JSUtil = bitcore.util.js;
|
||||||
|
|
||||||
|
var sig_canonical = require('../data/bitcoind/sig_canonical');
|
||||||
|
var sig_noncanonical = require('../data/bitcoind/sig_noncanonical');
|
||||||
|
|
||||||
describe('Signature', function() {
|
describe('Signature', function() {
|
||||||
|
|
||||||
@ -201,6 +205,26 @@ describe('Signature', function() {
|
|||||||
sigbuf[0] = 0x31;
|
sigbuf[0] = 0x31;
|
||||||
Signature.isTxDER(sigbuf).should.equal(false);
|
Signature.isTxDER(sigbuf).should.equal(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('bitcoind fixtures', function() {
|
||||||
|
var test_sigs = function(set, expected) {
|
||||||
|
var i = 0;
|
||||||
|
set.forEach(function(vector) {
|
||||||
|
if (!JSUtil.isHexa(vector)) {
|
||||||
|
// non-hex strings are ignored
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
it('should be ' + (expected ? '' : 'in') + 'valid for fixture #' + i, function() {
|
||||||
|
var sighex = vector;
|
||||||
|
Signature.isTxDER(new Buffer(sighex, 'hex')).should.equal(expected);
|
||||||
|
});
|
||||||
|
i++;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
test_sigs(sig_canonical, true);
|
||||||
|
//test_sigs(sig_noncanonical, false);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
describe('#hasLowS', function() {
|
describe('#hasLowS', function() {
|
||||||
it('should detect high and low S', function() {
|
it('should detect high and low S', function() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user