HDNode/tests: add testing for invalid network version from networks list

This commit is contained in:
Daniel Cousens 2016-02-25 13:41:35 +11:00
parent 9e32c892ef
commit bdb0dd4a17
3 changed files with 9 additions and 6 deletions

View file

@ -64,7 +64,9 @@ HDNode.fromBase58 = function (string, networks) {
network = networks.filter(function (network) {
return version === network.bip32.private ||
version === network.bip32.public
}).pop() || {}
}).pop()
if (!network) throw new Error('Invalid network version')
// otherwise, assume a network object (or default to bitcoin)
} else {
@ -72,7 +74,7 @@ HDNode.fromBase58 = function (string, networks) {
}
if (version !== network.bip32.private &&
version !== network.bip32.public) throw new Error('Invalid network')
version !== network.bip32.public) throw new Error('Invalid network version')
// 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ...
var depth = buffer[4]