remove duplicate code, increase coverage

This commit is contained in:
Manuel Araoz 2015-04-29 19:45:41 -03:00
parent fe17f20a97
commit db6234b500
3 changed files with 13 additions and 9 deletions

View File

@ -778,13 +778,6 @@ Script.prototype.toAddress = function(network) {
return new Address(info);
};
/**
* @return {Script}
*/
Script.prototype.toScriptHashOut = function() {
return Script.buildScriptHashOut(this);
};
/**
* Analagous to bitcoind's FindAndDelete. Find and delete equivalent chunks,
* typically used with push data chunks. Note that this will find and delete

View File

@ -21,6 +21,12 @@ describe('BufferReader', function() {
should.exist(br);
Buffer.isBuffer(br.buf).should.equal(true);
});
it('should fail for invalid object', function() {
var fail = function() {
return new BufferReader(5);
};
fail.should.throw('Unrecognized argument for BufferReader');
});
describe('#set', function() {

View File

@ -326,11 +326,16 @@ describe('Script', function() {
describe('#isScripthashOut', function() {
it('should identify this known pubkeyhashout as pubkeyhashout', function() {
it('should identify this known p2shout as p2shout', function() {
Script('OP_HASH160 20 0x0000000000000000000000000000000000000000 OP_EQUAL').isScriptHashOut().should.equal(true);
});
it('should identify these known non-pubkeyhashout as not pubkeyhashout', function() {
it('should identify result of .isScriptHashOut() as p2sh', function() {
Script('OP_DUP OP_HASH160 20 0x0000000000000000000000000000000000000000 OP_EQUALVERIFY OP_CHECKSIG')
.toScriptHashOut().isScriptHashOut().should.equal(true);
});
it('should identify these known non-p2shout as not p2shout', function() {
Script('OP_HASH160 20 0x0000000000000000000000000000000000000000 OP_EQUAL OP_EQUAL').isScriptHashOut().should.equal(false);
Script('OP_HASH160 21 0x000000000000000000000000000000000000000000 OP_EQUAL').isScriptHashOut().should.equal(false);
});