Fixed test cases that were being missed.

This commit is contained in:
ricmoo 2016-08-05 03:04:17 -04:00
parent a4e1f531b7
commit 1e5933eb45
5 changed files with 29 additions and 17 deletions

@ -356,8 +356,10 @@ index.js
+ testContracts
+ testSecretStorage
+ testBrainWallet
+ testContractAddress
+ testProviders
OK: 52156 assertions (127920ms)
OK: 52178 assertions (147788ms)
```
There are also some test JSON wallets available in the [test-wallets](https://github.com/ethers-io/ethers-wallet/tree/master/test-wallets) directory.

28
dist/ethers-wallet.js vendored

@ -1004,7 +1004,6 @@ function getGasPrice(value) {
if (!value || !value.transactions || value.transactions.length === 0) {
throw new Error('invalid response');
}
console.log(value.transactions[0].gasPrice)
return hexToBN(value.transactions[0].gasPrice);
}
@ -1082,11 +1081,8 @@ utils.defineProperty(EtherscanProvider.prototype, 'getTransactionCount', functio
});
utils.defineProperty(EtherscanProvider.prototype, 'getGasPrice', function() {
/* This doesn't work, over-estimates gas if current block was anxious
var query = ('module=proxy&action=eth_getBlockByNumber&tag=latest&boolean=true');
return this._send(query, getGasPrice);
*/
throw new Error('etherscan does not support gasPrice');
var query = ('module=proxy&action=eth_gasPrice');
return this._send(query, hexToBN);
});
utils.defineProperty(EtherscanProvider.prototype, 'sendTransaction', function(signedTransaction) {
@ -1104,7 +1100,25 @@ utils.defineProperty(EtherscanProvider.prototype, 'call', function(transaction)
});
utils.defineProperty(EtherscanProvider.prototype, 'estimateGas', function(transaction) {
throw new Error('etherscan does not support estimation');
var address = SigningKey.getAddress(transaction.to);
var query = 'module=proxy&action=eth_estimateGas&to=' + address;
if (transaction.gasPrice) {
query += '&gasPrice=' + utils.hexlify(transaction.gasPrice);
}
if (transaction.gasLimit) {
query += '&gas=' + utils.hexlify(transaction.gasLimit);
}
if (transaction.from) {
query += '&from=' + SigningKey.getAddress(transaction.from);
}
if (transaction.data) {
query += '&data=' + ensureHex(transaction.data);
}
if (transaction.value) {
query += '&value=' + utils.hexlify(transaction.value);
}
return this._send(query, hexToBN);
});

File diff suppressed because one or more lines are too long

@ -1,6 +1,6 @@
{
"name": "ethers-wallet",
"version": "0.0.8",
"version": "0.0.9",
"description": "Ethereum wallet library.",
"main": "index.js",
"scripts": {

@ -35,14 +35,10 @@ module.exports.testSecretStorage = require('./test-secret-storage.js');
module.exports.testBrainWallet = require('./test-brain-wallet.js');
// Test the solidity encoding/decoding parameters
module.exports.testSolidityCoder = require('./test-solidity-coder.js');
// Test contract address helper
module.exports.testSolidityCoder = require('./test-contract-address.js');
module.exports.testContractAddress = require('./test-contract-address.js');
// Test the providers API (we still need to add a lot ore test cases here)
module.exports.testSolidityCoder = require('./test-providers.js');
module.exports.testProviders = require('./test-providers.js');