eth-gas-reporter
Advanced tools
Comparing version 0.0.11 to 0.0.12
## Changelog: eth-gas-reporter | ||
0.0.11 / 2017-10-23 | ||
================== | ||
* Add Travis CI | ||
* Fix bug that crashed reported when truffle could not find required file | ||
0.0.10 / 2017-10-22 | ||
@@ -4,0 +10,0 @@ ================== |
@@ -14,4 +14,10 @@ /** | ||
const blockLimit = 6718946 | ||
/** | ||
* block.gasLimit. Set to a default at declaration but set to the rpc's declared limit | ||
* at `mapMethodsToContracts` | ||
* @type {Number} | ||
*/ | ||
let blockLimit = 6718946 | ||
/** | ||
* Expresses gas usage as a nation-state currency price | ||
@@ -81,3 +87,3 @@ * @param {Number} gas gas used | ||
const uniform = (stats.min === stats.max) | ||
stats.min = (uniform) ? '-' : stats.min.toString().yellow | ||
stats.min = (uniform) ? '-' : stats.min.toString().cyan | ||
stats.max = (uniform) ? '-' : stats.max.toString().red | ||
@@ -117,3 +123,3 @@ | ||
const uniform = (stats.min === stats.max) | ||
stats.min = (uniform) ? '-' : stats.min.toString().yellow | ||
stats.min = (uniform) ? '-' : stats.min.toString().cyan | ||
stats.max = (uniform) ? '-' : stats.max.toString().red | ||
@@ -136,5 +142,5 @@ | ||
chars: { | ||
'mid': '·', 'top-mid': '·', 'left-mid': '·', 'mid-mid': '·', 'right-mid': '·', | ||
'mid': '·', 'top-mid': '|', 'left-mid': '·', 'mid-mid': '|', 'right-mid': '·', | ||
'top-left': '·', 'top-right': '·', 'bottom-left': '·', 'bottom-right': '·', | ||
'middle': '·', 'top': '-', 'bottom': '-', 'bottom-mid': '-' | ||
'middle': '·', 'top': '-', 'bottom': '-', 'bottom-mid': '|' | ||
} | ||
@@ -145,3 +151,3 @@ }) | ||
let title = [ | ||
{hAlign: 'center', colSpan: 5, content: 'Gas Usage Metrics'.green.bold}, | ||
{hAlign: 'center', colSpan: 5, content: 'Gas'.green.bold}, | ||
{hAlign: 'center', colSpan: 2, content: `Block limit: ${blockLimit} gas`.grey } | ||
@@ -220,3 +226,3 @@ ] | ||
// Load config | ||
const config = reqCwd.silent('.ethgas.js') || {} | ||
const config = reqCwd.silent('./.ethgas.js') || {} | ||
const currency = config.currency || 'eur' | ||
@@ -265,4 +271,5 @@ | ||
* @param {Object} truffleArtifacts the `artifacts` of `artifacts.require('MetaCoin.sol') | ||
* @return {Object} mapping | ||
* @return {Object} { methodMap: <Object>, deployMap: <array> } | ||
* @example output | ||
* methodMap { | ||
* { | ||
@@ -275,2 +282,12 @@ * "90b98a11": { | ||
* } | ||
* ... | ||
* }, | ||
* deployMap [ | ||
* { | ||
* name: "Metacoin", | ||
* binary: "0x56484152.......", | ||
* gasData: [] | ||
* }, | ||
* .... | ||
* ] | ||
*/ | ||
@@ -282,5 +299,6 @@ function mapMethodsToContracts (truffleArtifacts) { | ||
const block = web3.eth.getBlock('latest'); | ||
blockLimit = block.gasLimit; | ||
const names = shell.ls('./contracts/**/*.sol') | ||
names.sort() | ||
names.forEach(name => { | ||
@@ -287,0 +305,0 @@ name = path.basename(name) |
@@ -133,4 +133,5 @@ const mocha = require('mocha') | ||
runner.on('end', () => { | ||
stats.generateGasStatsReport(methodMap, deployMap) | ||
self.epilogue() | ||
stats | ||
.generateGasStatsReport(methodMap, deployMap) | ||
.then(() => self.epilogue()); | ||
}) | ||
@@ -137,0 +138,0 @@ } |
{ | ||
"name": "eth-gas-reporter", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Mocha reporter which shows gas used per unit test.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -47,2 +47,6 @@ const VariableCosts = artifacts.require('./VariableCosts.sol') | ||
}) | ||
it.skip('prints a table at end of test suites with failures', async() => { | ||
assert(false); | ||
}) | ||
}) |
{ | ||
"name": "eth-gas-reporter", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "Mocha reporter which shows gas used per unit test.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# eth-gas-reporter | ||
[![Build Status](https://travis-ci.org/cgewecke/eth-gas-reporter.svg?branch=add-travis)](https://travis-ci.org/cgewecke/eth-gas-reporter) | ||
[![npm version](https://badge.fury.io/js/eth-gas-reporter.svg)](https://badge.fury.io/js/eth-gas-reporter) | ||
[![Build Status](https://travis-ci.org/cgewecke/eth-gas-reporter.svg?branch=master)](https://travis-ci.org/cgewecke/eth-gas-reporter) | ||
@@ -11,5 +12,6 @@ A mocha reporter for Truffle. | ||
![screen shot 2017-10-22 at 4 03 57 pm](https://user-images.githubusercontent.com/7332026/31867351-c45a5a80-b742-11e7-98dd-49051684e5fd.png) | ||
![screen shot 2017-10-28 at 1 29 52 pm](https://user-images.githubusercontent.com/7332026/32138588-db1d56e0-bbe9-11e7-820e-511d6e36c846.png) | ||
### Install | ||
@@ -24,11 +26,7 @@ ```javascript | ||
### Configure for truffle | ||
### Truffle config | ||
```javascript | ||
module.exports = { | ||
networks: { | ||
development: { | ||
host: "localhost", | ||
port: 8545, | ||
network_id: "*" | ||
} | ||
...etc... | ||
}, | ||
@@ -41,2 +39,14 @@ mocha: { | ||
### Options | ||
You can also create a `.ethgas.js` config in the root directory of your project to set | ||
`gasPrice` and `currency` options. Available currency codes can be found [here](https://coinmarketcap.com/api/). | ||
```javascript | ||
module.exports = { | ||
currency: "CHF", // Default: "EUR" (loaded at run-time from the `coinmarketcap` api) | ||
gasPrice: 21 * 1e9 // Default: (~5 gwei, loaded at run-time from the `blockcypher` api) | ||
} | ||
``` | ||
### Examples | ||
@@ -47,4 +57,3 @@ + [gnosis/gnosis-contracts](https://github.com/cgewecke/eth-gas-reporter/blob/master/docs/gnosis.md) | ||
### Usage Notes | ||
+ Euro/ETH rates are loaded at run-time from the `coinmarketcap` api | ||
+ Gas prices are `safe-low` and loaded at run-time from the `blockcypher` api | ||
+ Table will not print if any tests fail (this is a bug, possibly rooted in `truffle`). | ||
+ Method calls that throw are filtered from the stats. | ||
@@ -55,2 +64,3 @@ + Not currently shown in the `deployments` table: | ||
+ Tests that make assumptions about the value of `block.timestamp` sometimes fail using this utility. | ||
+ Tests run slower. | ||
@@ -57,0 +67,0 @@ ### Credits |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33299
27
592
67