Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Show message if tests ran too fast #256

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down Expand Up @@ -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).
Expand All @@ -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)
16 changes: 16 additions & 0 deletions docs/missingPriceData.md
Original file line number Diff line number Diff line change
@@ -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);
});
});
```
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 -------------------------------------------------

Expand Down Expand Up @@ -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();
});
}
Expand Down