diff options
author | Leonid <logvinov.leon@gmail.com> | 2017-11-29 04:37:33 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-29 04:37:33 +0800 |
commit | a98d6bf496ae8d1698fd63a3a7a4db756e743cb1 (patch) | |
tree | 3018bdd100d8280056c459b8ac41ff08b7115dc7 /packages/0x.js/test/utils/subproviders | |
parent | bbcf669bd9bc73924436e9ea41fe393b8d23a863 (diff) | |
parent | 353abffba9afd73d70fce47fee2f2d6067c6c8ae (diff) | |
download | dexon-sol-tools-a98d6bf496ae8d1698fd63a3a7a4db756e743cb1.tar dexon-sol-tools-a98d6bf496ae8d1698fd63a3a7a4db756e743cb1.tar.gz dexon-sol-tools-a98d6bf496ae8d1698fd63a3a7a4db756e743cb1.tar.bz2 dexon-sol-tools-a98d6bf496ae8d1698fd63a3a7a4db756e743cb1.tar.lz dexon-sol-tools-a98d6bf496ae8d1698fd63a3a7a4db756e743cb1.tar.xz dexon-sol-tools-a98d6bf496ae8d1698fd63a3a7a4db756e743cb1.tar.zst dexon-sol-tools-a98d6bf496ae8d1698fd63a3a7a4db756e743cb1.zip |
Merge pull request #235 from 0xProject/feature/gasPriceGasLimit
Add optional config for gasPrice and gasLimit for every transaction sending method
Diffstat (limited to 'packages/0x.js/test/utils/subproviders')
-rw-r--r-- | packages/0x.js/test/utils/subproviders/empty_wallet_subprovider.ts | 27 | ||||
-rw-r--r-- | packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts | 34 |
2 files changed, 61 insertions, 0 deletions
diff --git a/packages/0x.js/test/utils/subproviders/empty_wallet_subprovider.ts b/packages/0x.js/test/utils/subproviders/empty_wallet_subprovider.ts new file mode 100644 index 000000000..e5e279873 --- /dev/null +++ b/packages/0x.js/test/utils/subproviders/empty_wallet_subprovider.ts @@ -0,0 +1,27 @@ +import {JSONRPCPayload} from '../../../src/types'; + +/* + * This class implements the web3-provider-engine subprovider interface and returns + * that the provider has no addresses when queried. + * Source: https://github.com/MetaMask/provider-engine/blob/master/subproviders/subprovider.js + */ +export class EmptyWalletSubprovider { + // 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_accounts': + end(null, []); + 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 + } +} 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 + } +} |