PrivateKey: Lodash to check if undefined, and made tests not random (T2)
This commit is contained in:
parent
920f25b58e
commit
96c7812ed1
|
@ -1,5 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
var _ = require('lodash');
|
||||
var Address = require('./address');
|
||||
var base58check = require('./encoding/base58check');
|
||||
var BN = require('./crypto/bn');
|
||||
|
@ -44,7 +45,7 @@ var PrivateKey = function PrivateKey(data, network, compressed) {
|
|||
};
|
||||
|
||||
// detect type of data
|
||||
if (typeof(data) === 'undefined' || data === 'random'){
|
||||
if (_.isUndefined(data)){
|
||||
info.bn = PrivateKey._getRandomBN();
|
||||
} else if (data instanceof BN) {
|
||||
info.bn = data;
|
||||
|
|
|
@ -110,7 +110,7 @@ describe('PrivateKey', function() {
|
|||
|
||||
it('should not be able to instantiate because compressed is non-boolean', function() {
|
||||
expect(function() {
|
||||
var a = new PrivateKey('random', 'testnet', 'compressed');
|
||||
var a = new PrivateKey(BN(2), 'testnet', 'compressed');
|
||||
}).to.throw('Must specify whether the corresponding public key is compressed or not (true or false)');
|
||||
});
|
||||
|
||||
|
@ -122,7 +122,7 @@ describe('PrivateKey', function() {
|
|||
|
||||
it('should not be able to instantiate with unknown network', function() {
|
||||
expect(function() {
|
||||
var a = new PrivateKey('random', 'unknown');
|
||||
var a = new PrivateKey(BN(2), 'unknown');
|
||||
}).to.throw('Must specify the network ("livenet" or "testnet")');
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue