Added more tests around script.isPublicKeyHashIn
This commit is contained in:
parent
770e0e3a7f
commit
7e23109f9b
|
@ -247,7 +247,7 @@ Script.prototype.isPublicKeyHashOut = function() {
|
|||
/**
|
||||
* @returns {boolean} if this is a pay to public key hash input script
|
||||
*/
|
||||
Script.prototype.isPublicKeyHashIn = function(inaccurate) {
|
||||
Script.prototype.isPublicKeyHashIn = function() {
|
||||
if (this.chunks.length === 2) {
|
||||
var signatureBuf = this.chunks[0].buf;
|
||||
var pubkeyBuf = this.chunks[1].buf;
|
||||
|
|
|
@ -233,19 +233,27 @@ describe('Script', function() {
|
|||
|
||||
describe('#isPublicKeyHashIn', function() {
|
||||
|
||||
it('should identify this known pubkeyhashin', function() {
|
||||
it('should identify this known pubkeyhashin (uncompressed pubkey version)', function() {
|
||||
Script('73 0x3046022100bb3c194a30e460d81d34be0a230179c043a656f67e3c5c8bf47eceae7c4042ee0221008bf54ca11b2985285be0fd7a212873d243e6e73f5fad57e8eb14c4f39728b8c601 65 0x04e365859b3c78a8b7c202412b949ebca58e147dba297be29eee53cd3e1d300a6419bc780cc9aec0dc94ed194e91c8f6433f1b781ee00eac0ead2aae1e8e0712c6').isPublicKeyHashIn().should.equal(true);
|
||||
});
|
||||
|
||||
it('should identify this known pubkeyhashin starting with 0x02', function() {
|
||||
it('should identify this known pubkeyhashin (hybrid pubkey version w/06)', function() {
|
||||
Script('73 0x3046022100bb3c194a30e460d81d34be0a230179c043a656f67e3c5c8bf47eceae7c4042ee0221008bf54ca11b2985285be0fd7a212873d243e6e73f5fad57e8eb14c4f39728b8c601 65 0x06e365859b3c78a8b7c202412b949ebca58e147dba297be29eee53cd3e1d300a6419bc780cc9aec0dc94ed194e91c8f6433f1b781ee00eac0ead2aae1e8e0712c6').isPublicKeyHashIn().should.equal(true);
|
||||
});
|
||||
|
||||
it('should identify this known pubkeyhashin (hybrid pubkey version w/07)', function() {
|
||||
Script('73 0x3046022100bb3c194a30e460d81d34be0a230179c043a656f67e3c5c8bf47eceae7c4042ee0221008bf54ca11b2985285be0fd7a212873d243e6e73f5fad57e8eb14c4f39728b8c601 65 0x07e365859b3c78a8b7c202412b949ebca58e147dba297be29eee53cd3e1d300a6419bc780cc9aec0dc94ed194e91c8f6433f1b781ee00eac0ead2aae1e8e0712c6').isPublicKeyHashIn().should.equal(true);
|
||||
});
|
||||
|
||||
it('should identify this known pubkeyhashin (compressed pubkey w/ 0x02)', function() {
|
||||
Script('73 0x3046022100bb3c194a30e460d81d34be0a230179c043a656f67e3c5c8bf47eceae7c4042ee0221008bf54ca11b2985285be0fd7a212873d243e6e73f5fad57e8eb14c4f39728b8c601 21 0x02aec6b86621e7fef63747fbfd6a6e7d54c8e1052044ef2dd2c5e46656ef1194d4').isPublicKeyHashIn().should.equal(true);
|
||||
});
|
||||
|
||||
it('should identify this known pubkeyhashin starting with 0x03', function() {
|
||||
it('should identify this known pubkeyhashin (compressed pubkey w/ 0x03)', function() {
|
||||
Script('73 0x3046022100bb3c194a30e460d81d34be0a230179c043a656f67e3c5c8bf47eceae7c4042ee0221008bf54ca11b2985285be0fd7a212873d243e6e73f5fad57e8eb14c4f39728b8c601 21 0x03e724d93c4fda5f1236c525de7ffac6c5f1f72b0f5cdd1fc4b4f5642b6d055fcc').isPublicKeyHashIn().should.equal(true);
|
||||
});
|
||||
|
||||
it('should identify this known non-pubkeyhashin', function() {
|
||||
it('should identify this known non-pubkeyhashin (bad ops length)', function() {
|
||||
Script('73 0x3046022100bb3c194a30e460d81d34be0a230179c043a656f67e3c5c8bf47eceae7c4042ee0221008bf54ca11b2985285be0fd7a212873d243e6e73f5fad57e8eb14c4f39728b8c601 65 0x04e365859b3c78a8b7c202412b949ebca58e147dba297be29eee53cd3e1d300a6419bc780cc9aec0dc94ed194e91c8f6433f1b781ee00eac0ead2aae1e8e0712c6 OP_CHECKSIG').isPublicKeyHashIn().should.equal(false);
|
||||
});
|
||||
|
||||
|
@ -253,6 +261,22 @@ describe('Script', function() {
|
|||
Script('70 0x3043021f336721e4343f67c835cbfd465477db09073dc38a936f9c445d573c1c8a7fdf022064b0e3cb6892a9ecf870030e3066bc259e1f24841c9471d97f9be08b73f6530701 33 0x0370b2e1dcaa8f51cb0ead1221dd8cb31721502b3b5b7d4b374d263dfec63a4369').isPublicKeyHashIn().should.equal(true);
|
||||
});
|
||||
|
||||
it('should identify this known non-pubkeyhashin (bad version)', function() {
|
||||
Script('70 0x3043021f336721e4343f67c835cbfd465477db09073dc38a936f9c445d573c1c8a7fdf022064b0e3cb6892a9ecf870030e3066bc259e1f24841c9471d97f9be08b73f6530701 33 0x1270b2e1dcaa8f51cb0ead1221dd8cb31721502b3b5b7d4b374d263dfec63a4369').isPublicKeyHashIn().should.equal(false);
|
||||
});
|
||||
|
||||
it('should identify this known non-pubkeyhashin (bad signature version)', function() {
|
||||
Script('70 0x4043021f336721e4343f67c835cbfd465477db09073dc38a936f9c445d573c1c8a7fdf022064b0e3cb6892a9ecf870030e3066bc259e1f24841c9471d97f9be08b73f6530701 33 0x0370b2e1dcaa8f51cb0ead1221dd8cb31721502b3b5b7d4b374d263dfec63a4369').isPublicKeyHashIn().should.equal(false);
|
||||
});
|
||||
|
||||
it('should identify this known non-pubkeyhashin (no public key)', function() {
|
||||
Script('70 0x3043021f336721e4343f67c835cbfd465477db09073dc38a936f9c445d573c1c8a7fdf022064b0e3cb6892a9ecf870030e3066bc259e1f24841c9471d97f9be08b73f6530701 OP_CHECKSIG').isPublicKeyHashIn().should.equal(false);
|
||||
});
|
||||
|
||||
it('should identify this known non-pubkeyhashin (no signature)', function() {
|
||||
Script('OP_DROP OP_CHECKSIG').isPublicKeyHashIn().should.equal(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#isPublicKeyHashOut', function() {
|
||||
|
|
Loading…
Reference in New Issue