Add support for TEST_PROVIDER env var

This commit is contained in:
Alex Browne
2018-06-04 17:47:18 -07:00
parent 2dfc468094
commit 5900899c01
2 changed files with 6 additions and 5 deletions

View File

@@ -5,7 +5,7 @@ import { Provider } from 'ethereum-types';
import { coverage } from './coverage';
const useGeth = true;
const testProvider = process.env.TEST_PROVIDER || 'ganache';
const ganacheTxDefaults = {
from: devConstants.TESTRPC_FIRST_ADDRESS,
@@ -14,7 +14,7 @@ const ganacheTxDefaults = {
const gethTxDefaults = {
from: devConstants.TESTRPC_FIRST_ADDRESS,
};
export const txDefaults = useGeth ? gethTxDefaults : ganacheTxDefaults;
export const txDefaults = testProvider === 'ganache' ? ganacheTxDefaults : gethTxDefaults;
const gethConfigs = {
shouldUseInProcessGanache: false,
@@ -24,7 +24,8 @@ const gethConfigs = {
const ganacheConfigs = {
shouldUseInProcessGanache: true,
};
const providerConfigs = useGeth ? gethConfigs : ganacheConfigs;
const providerConfigs = testProvider === 'ganache' ? ganacheConfigs : gethConfigs;
export const provider = web3Factory.getRpcProvider(providerConfigs);
const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage);

View File

@@ -257,9 +257,9 @@ export class Web3Wrapper {
* Increase the next blocks timestamp on TestRPC/Ganache local node
* @param timeDelta Amount of time to add in seconds
*/
public async increaseTimeAsync(timeDelta: number): Promise<void> {
public async increaseTimeAsync(timeDelta: number): Promise<number> {
// TODO(albrow): Detect Geth vs. Ganache and use appropriate endpoint.
await this._sendRawPayloadAsync<string>({ method: 'debug_increaseTime', params: [timeDelta] });
return this._sendRawPayloadAsync<number>({ method: 'debug_increaseTime', params: [timeDelta] });
}
/**
* Retrieve smart contract logs for a given filter