diff --git a/README.md b/README.md index db2408a..ca0378e 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ your own API key [here][55] and set it with the `coinmarketcap` option. | Option | Type | Default | Description | | ----------------- | ---------------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | currency | _String_ | 'EUR' | National currency to represent gas costs in. Exchange rates loaded at runtime from the `coinmarketcap` api. Available currency codes can be found [here](https://coinmarketcap.com/api/documentation/v1/#section/Standards-and-Conventions). | -| coinmarketcap | _String_ | (unprotected API key) | [API key][55] to use when fetching current market price data. (Use this if you stop seeing price data) | +| coinmarketcap | _String_ | (unprotected API key) | [API key][55] to use when fetching current market price data. For example: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` | | gasPrice | _Number_ | (varies) | Denominated in `gwei`. Default is loaded at runtime from the `eth gas station` api | | outputFile | _String_ | stdout | File path to write report output to | | noColors | _Boolean_ | false | Suppress report color. Useful if you are printing to file b/c terminal colorization corrupts the text. | @@ -118,6 +118,10 @@ An advanced use guide is available [here](https://github.com/cgewecke/eth-gas-re - Method calls that throw are filtered from the stats. - Contracts that are only ever created by other contracts within Solidity are not shown in the deployments table. +### Troubleshooting + +- [Missing price data](./docs/missingPriceData.md) + ### Contributions Feel free to open PRs or issues. There is an integration test and one of the mock test cases is expected to fail. If you're adding an option, you can vaildate it in CI by adding it to the mock options config located [here](https://github.com/cgewecke/eth-gas-reporter/blob/master/mock/config-template.js#L13-L19). @@ -144,3 +148,4 @@ All the ideas in this utility have been borrowed from elsewhere. Many thanks to: - [@gnidan](https://github.com/gnidan) - [@fodisi](https://github.com/fodisi) - [@vicnaum](https://github.com/vicnaum) +- [@markmiro](https://github.com/markmiro) diff --git a/docs/missingPriceData.md b/docs/missingPriceData.md new file mode 100644 index 0000000..c0a2a66 --- /dev/null +++ b/docs/missingPriceData.md @@ -0,0 +1,16 @@ +# Missing Price Data + +Two possible reasons for this: +- [Default API key](https://github.com/cgewecke/eth-gas-reporter/blob/23fc57687b4e190c7e28571a14773d96cdbf7d63/lib/config.js#L12) reached a usage cap. +- The tests ran too quickly and price data couldn't be fetched before returning the test. You can manually slow down your tests with a dummy + +To slow down unit tests, you can add a dummy test like this: +```js +// Wait so the reporter has time to fetch and return prices from APIs. +// https://github.com/cgewecke/eth-gas-reporter/issues/254 +describe("eth-gas-reporter workaround", () => { + it("should kill time", (done) => { + setTimeout(done, 2000); + }); +}); +``` \ No newline at end of file diff --git a/index.js b/index.js index 0d5ddab..2e70166 100644 --- a/index.js +++ b/index.js @@ -50,7 +50,10 @@ function Gas(runner, options) { } // These call the cloud, start running them. - utils.setGasAndPriceRates(config); + let didGetPriceData = false; + utils.setGasAndPriceRates(config).then(() => { + didGetPriceData = true; + }); // ------------------------------------ Runners ------------------------------------------------- @@ -143,6 +146,9 @@ function Gas(runner, options) { runner.on("end", () => { table.generate(watch.data); + if (!didGetPriceData) { + console.log("Tests ran too quickly. Pricing data couldn't be fetched in time."); + } self.epilogue(); }); }