diff options
author | Fabio Berger <me@fabioberger.com> | 2017-11-29 05:21:15 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-11-29 05:21:15 +0800 |
commit | 15ce862334be14a7effcd55840ca96e425912df8 (patch) | |
tree | b51f48dfb6a0dc66745b62521c108472210dcfaa /packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts | |
parent | 72a00ac2df47ff793d74c2a82c7f403f501e784a (diff) | |
parent | da0af12834b16c960d9ebf2936eec450825ba987 (diff) | |
download | dexon-sol-tools-15ce862334be14a7effcd55840ca96e425912df8.tar dexon-sol-tools-15ce862334be14a7effcd55840ca96e425912df8.tar.gz dexon-sol-tools-15ce862334be14a7effcd55840ca96e425912df8.tar.bz2 dexon-sol-tools-15ce862334be14a7effcd55840ca96e425912df8.tar.lz dexon-sol-tools-15ce862334be14a7effcd55840ca96e425912df8.tar.xz dexon-sol-tools-15ce862334be14a7effcd55840ca96e425912df8.tar.zst dexon-sol-tools-15ce862334be14a7effcd55840ca96e425912df8.zip |
Merge branch 'development' into fix/refactorDocs
* development: (30 commits)
Export TransactionOpts type
Make website private
Publish
Update CHANGELOG
Change interval to 1h
Rename
Add ifExists to cleanupJobInterval
Add a cleanup job to an order watcher
Improve the comment
Add CHANGELOG comment
Add a HACK comment
Normalise subprovider names
Remove a comment
Fix a typo
Pin testrpc version
Remove gas params from tests
Add fake gas estimate suprovider for tests
Revert "Fix website linter errors"
Fix website linter errors
Fix tests
...
# Conflicts:
# packages/website/ts/utils/constants.ts
Diffstat (limited to 'packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts')
-rw-r--r-- | packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts b/packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts new file mode 100644 index 000000000..059163f2e --- /dev/null +++ b/packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts @@ -0,0 +1,34 @@ +import {JSONRPCPayload} from '../../../src/types'; + +/* + * This class implements the web3-provider-engine subprovider interface and returns + * the constant gas estimate when queried. + * HACK: We need this so that our tests don't use testrpc gas estimation which sometimes kills the node. + * Source: https://github.com/trufflesuite/ganache-cli/issues/417 + * Source: https://github.com/trufflesuite/ganache-cli/issues/437 + * Source: https://github.com/MetaMask/provider-engine/blob/master/subproviders/subprovider.js + */ +export class FakeGasEstimateSubprovider { + private constantGasAmount: number; + constructor(constantGasAmount: number) { + this.constantGasAmount = constantGasAmount; + } + // This method needs to be here to satisfy the interface but linter wants it to be static. + // tslint:disable-next-line:prefer-function-over-method + public handleRequest(payload: JSONRPCPayload, next: () => void, end: (err: Error|null, result: any) => void) { + switch (payload.method) { + case 'eth_estimateGas': + end(null, this.constantGasAmount); + return; + + default: + next(); + return; + } + } + // Required to implement this method despite not needing it for this subprovider + // tslint:disable-next-line:prefer-function-over-method + public setEngine(engine: any) { + // noop + } +} |