Browse Source

remove duplicate code, increase coverage

patch-2
Manuel Araoz 10 years ago
parent
commit
db6234b500
  1. 7
      lib/script/script.js
  2. 6
      test/encoding/bufferreader.js
  3. 9
      test/script/script.js

7
lib/script/script.js

@ -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

6
test/encoding/bufferreader.js

@ -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() {

9
test/script/script.js

@ -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);
});

Loading…
Cancel
Save