Merge pull request #1154 from martindale/addnetwork-crashfix
Fix bug if no value is supplied.
This commit is contained in:
commit
4390b08b48
|
@ -75,7 +75,7 @@ function addNetwork(data) {
|
||||||
});
|
});
|
||||||
|
|
||||||
_.each(_.values(network), function(value) {
|
_.each(_.values(network), function(value) {
|
||||||
if (!_.isObject(value)) {
|
if (!_.isUndefined(value) && !_.isObject(value)) {
|
||||||
networkMaps[value] = network;
|
networkMaps[value] = network;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe('Networks', function() {
|
||||||
pubkeyhash: 0x10,
|
pubkeyhash: 0x10,
|
||||||
privatekey: 0x90,
|
privatekey: 0x90,
|
||||||
scripthash: 0x08,
|
scripthash: 0x08,
|
||||||
xpubkey: 0x0278b20e,
|
xpubkey: 0x0278b20e,
|
||||||
xprivkey: 0x0278ade4,
|
xprivkey: 0x0278ade4,
|
||||||
networkMagic: 0xe7beb4d4,
|
networkMagic: 0xe7beb4d4,
|
||||||
port: 20001,
|
port: 20001,
|
||||||
|
@ -40,6 +40,25 @@ describe('Networks', function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not set a network map for an undefined value', function() {
|
||||||
|
var custom = {
|
||||||
|
name: 'somenet',
|
||||||
|
pubkeyhash: 0x13,
|
||||||
|
privatekey: 0x93,
|
||||||
|
scripthash: 0x11,
|
||||||
|
xpubkey: 0x0278b20f,
|
||||||
|
xprivkey: 0x0278ade5,
|
||||||
|
networkMagic: 0xe7beb4d5,
|
||||||
|
port: 20008,
|
||||||
|
dnsSeeds: [
|
||||||
|
'somenet.localhost'
|
||||||
|
]
|
||||||
|
};
|
||||||
|
networks.add(custom);
|
||||||
|
var network = networks.get(undefined);
|
||||||
|
should.not.exist(network);
|
||||||
|
});
|
||||||
|
|
||||||
var constants = ['name', 'alias', 'pubkeyhash', 'scripthash', 'xpubkey', 'xprivkey'];
|
var constants = ['name', 'alias', 'pubkeyhash', 'scripthash', 'xpubkey', 'xprivkey'];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue