Fixes Script test case for coverage and style

This commit is contained in:
Esteban Ordano 2014-12-30 15:33:52 -03:00
parent c1a1571535
commit ffca4cfb6f
2 changed files with 9 additions and 17 deletions

View File

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

View File

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