test invalid address

This commit is contained in:
Ryan X. Charles 2014-08-28 17:32:08 -07:00
parent ac47796acd
commit 356ddcfa4e
2 changed files with 9 additions and 1 deletions

View File

@ -11,7 +11,11 @@ function Address(obj) {
}; };
Address.isValid = function(addrstr) { Address.isValid = function(addrstr) {
var address = new Address().fromString(addrstr); try {
var address = new Address().fromString(addrstr);
} catch (e) {
return false;
}
return address.isValid(); return address.isValid();
}; };

View File

@ -18,6 +18,10 @@ describe('Address', function() {
Address.isValid(str).should.equal(true); Address.isValid(str).should.equal(true);
}); });
it('should invalidate this valid address string', function() {
Address.isValid(str.substr(1)).should.equal(false);
});
}); });
describe('#fromPubkey', function() { describe('#fromPubkey', function() {