Fixed default network for providers (#51).
This commit is contained in:
parent
e4c455bdb6
commit
54c19dfb5a
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ethers-providers",
|
"name": "ethers-providers",
|
||||||
"version": "2.1.5",
|
"version": "2.1.6",
|
||||||
"description": "Service provider for Ethereum wallet library.",
|
"description": "Service provider for Ethereum wallet library.",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "http://github.com/ethers-io/ethers.js/issues",
|
"url": "http://github.com/ethers-io/ethers.js/issues",
|
||||||
|
@ -482,6 +482,9 @@ utils.defineProperty(Provider, '_legacyConstructor', function(network, length, a
|
|||||||
} else if (typeof(network) === 'string') {
|
} else if (typeof(network) === 'string') {
|
||||||
network = networks[network];
|
network = networks[network];
|
||||||
if (!network) { throw new Error('unknown network'); }
|
if (!network) { throw new Error('unknown network'); }
|
||||||
|
|
||||||
|
} else if (network == null) {
|
||||||
|
network = networks['homestead'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof(network.chainId) !== 'number') { throw new Error('invalid chainId'); }
|
if (typeof(network.chainId) !== 'number') { throw new Error('invalid chainId'); }
|
||||||
|
@ -83,6 +83,8 @@ var blockchainData = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockchainData['default'] = blockchainData.homestead;
|
||||||
|
|
||||||
function equals(name, actual, expected) {
|
function equals(name, actual, expected) {
|
||||||
if (expected.eq) {
|
if (expected.eq) {
|
||||||
assert.ok(expected.eq(actual), name + ' matches');
|
assert.ok(expected.eq(actual), name + ' matches');
|
||||||
@ -100,7 +102,20 @@ function equals(name, actual, expected) {
|
|||||||
|
|
||||||
function testProvider(providerName, networkName) {
|
function testProvider(providerName, networkName) {
|
||||||
describe(('Read-Only ' + providerName + ' (' + networkName + ')'), function() {
|
describe(('Read-Only ' + providerName + ' (' + networkName + ')'), function() {
|
||||||
var provider = new providers[providerName](networkName);
|
var provider = null;
|
||||||
|
if (networkName === 'default') {
|
||||||
|
if (providerName === 'getDefaultProvider') {
|
||||||
|
provider = providers.getDefaultProvider();
|
||||||
|
} else {
|
||||||
|
provider = new providers[providerName]();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (providerName === 'getDefaultProvider') {
|
||||||
|
provider = providers.getDefaultProvider(networkName);
|
||||||
|
} else {
|
||||||
|
provider = new providers[providerName](networkName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
it('fetches block #3', function() {
|
it('fetches block #3', function() {
|
||||||
this.timeout(20000);
|
this.timeout(20000);
|
||||||
@ -148,8 +163,9 @@ function testProvider(providerName, networkName) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
['homestead', 'ropsten', 'rinkeby', 'kovan'].forEach(function(networkName) {
|
['default', 'homestead', 'ropsten', 'rinkeby', 'kovan'].forEach(function(networkName) {
|
||||||
['InfuraProvider', 'EtherscanProvider'].forEach(function(providerName) {
|
['getDefaultProvider', 'InfuraProvider', 'EtherscanProvider'].forEach(function(providerName) {
|
||||||
testProvider(providerName, networkName);
|
testProvider(providerName, networkName);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user