parent
6d1c5d39a3
commit
901d836231
|
@ -64,7 +64,7 @@ var PublicKey = function PublicKey(data, extra) {
|
|||
|
||||
Object.defineProperty(this, 'network', {
|
||||
configurable: false,
|
||||
value: info.network
|
||||
value: info.network || Network.defaultNetwork
|
||||
});
|
||||
|
||||
return this;
|
||||
|
|
|
@ -8,8 +8,8 @@ var Point = bitcore.crypto.Point;
|
|||
var BN = bitcore.crypto.BN;
|
||||
var PublicKey = bitcore.PublicKey;
|
||||
var PrivateKey = bitcore.PrivateKey;
|
||||
var Networks = bitcore.Networks;
|
||||
|
||||
// DER uncompressed format
|
||||
/* jshint maxlen: 200 */
|
||||
|
||||
describe('PublicKey', function() {
|
||||
|
@ -65,6 +65,12 @@ describe('PublicKey', function() {
|
|||
publicKey.should.equal(publicKey2);
|
||||
});
|
||||
|
||||
it('sets the network to defaultNetwork if none provided', function() {
|
||||
var publicKeyHex = '031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a';
|
||||
var publicKey = new PublicKey(publicKeyHex);
|
||||
publicKey.network.should.equal(Networks.defaultNetwork);
|
||||
});
|
||||
|
||||
it('from a hex encoded DER string', function() {
|
||||
var pk = new PublicKey('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341');
|
||||
should.exist(pk.point);
|
||||
|
@ -317,12 +323,12 @@ describe('PublicKey', function() {
|
|||
describe('#inspect', function() {
|
||||
it('should output known uncompressed pubkey for console', function() {
|
||||
var pubkey = PublicKey.fromString('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341');
|
||||
pubkey.inspect().should.equal('<PublicKey: 041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341, uncompressed>');
|
||||
pubkey.inspect().should.equal('<PublicKey: 041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341, uncompressed, network: livenet>');
|
||||
});
|
||||
|
||||
it('should output known compressed pubkey for console', function() {
|
||||
var pubkey = PublicKey.fromString('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
|
||||
pubkey.inspect().should.equal('<PublicKey: 031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a>');
|
||||
pubkey.inspect().should.equal('<PublicKey: 031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a, network: livenet>');
|
||||
});
|
||||
|
||||
it('should output known compressed pubkey with network for console', function() {
|
||||
|
|
Loading…
Reference in New Issue