Browse Source

added sig_canonical tests

patch-2
Manuel Araoz 10 years ago
parent
commit
17459dd7c2
  1. 24
      test/crypto/signature.js

24
test/crypto/signature.js

@ -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…
Cancel
Save