Browse Source

Fixes Script test case for coverage and style

patch-2
Esteban Ordano 10 years ago
parent
commit
ffca4cfb6f
  1. 6
      lib/script/script.js
  2. 20
      test/script/script.js

6
lib/script/script.js

@ -709,11 +709,11 @@ Script.prototype.toAddress = function(network) {
$.checkArgument(network, 'Must provide a network');
if (this.isPublicKeyHashOut()) {
return new Address(this.getData(), network, Address.PayToPublicKeyHash);
}
if (this.isScriptHashOut()) {
} else if (this.isScriptHashOut()) {
return new Address(this.getData(), network, Address.PayToScriptHash);
} else {
throw new Error('The script type needs to be PayToPublicKeyHash or PayToScriptHash');
}
throw new Error('The script type needs to be PayToPublicKeyHash or PayToScriptHash');
};
/**

20
test/script/script.js

@ -585,13 +585,9 @@ describe('Script', function() {
expect(BufferUtil.equal(Script('OP_RETURN 1 0xFF').getData(), new Buffer([255]))).to.be.true();
});
it('fails if content is not recognized', function() {
var failed = false;
try {
Script('1 0xFF').getData();
} catch (e) {
failed = true;
}
failed.should.equal(true);
expect(function() {
return Script('1 0xFF').getData();
}).to.throw();
});
});
@ -609,13 +605,9 @@ describe('Script', function() {
script.toAddress(Networks.livenet).toString().should.equal(stringAddress);
});
it('fails if content is not recognized', function() {
var failed = false;
try {
Script().toAddress();
} catch (e) {
failed = true;
}
failed.should.equal(true);
expect(function() {
return Script().toAddress(Networks.livenet);
}).to.throw();
});
});

Loading…
Cancel
Save