From 2cbcf7da1ca116d00fa92e10004c281c548f7b67 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Mon, 1 Dec 2014 18:19:17 -0500 Subject: [PATCH] Tests: Check that an Address is using the defaultNetwork --- test/address.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/address.js b/test/address.js index 00ed0b0..3c29c3b 100644 --- a/test/address.js +++ b/test/address.js @@ -6,6 +6,7 @@ var bitcore = require('..'); var PublicKey = bitcore.PublicKey; var Address = bitcore.Address; var Script = bitcore.Script; +var networks = bitcore.Networks; describe('Address', function() { @@ -260,6 +261,18 @@ describe('Address', function() { var c = new Address(hash).toString().should.equal(str); }); + it('should make an address using the default network', function() { + var hash = pubkeyhash; //use the same hash + var a = Address.fromPublicKeyHash(hash); + a.network.should.equal('livenet'); + // change the default + networks.defaultNetwork = networks.testnet; + var b = Address.fromPublicKeyHash(hash); + b.network.should.equal('testnet'); + // restore the default + networks.defaultNetwork = networks.livenet; + }); + it('should throw an error for invalid length hashBuffer', function() { (function() { var a = Address.fromPublicKeyHash(buf);