@0x/contracts-test-utils
: Add blockchainTests.config
This commit is contained in:
parent
651e94bd94
commit
bd9c9cedca
@ -20,11 +20,22 @@ export interface ContextDefinition extends mocha.IContextDefinition {
|
|||||||
optional: ContextDefinitionCallback<ISuite | void>;
|
optional: ContextDefinitionCallback<ISuite | void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `blockchainTests()` config options.
|
||||||
|
*/
|
||||||
|
export interface BlockchainContextConfig {
|
||||||
|
fork: Partial<{
|
||||||
|
// Accounts to unlock on ganache.
|
||||||
|
unlockedAccounts: string[];
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for `blockchainTests()`.
|
* Interface for `blockchainTests()`.
|
||||||
*/
|
*/
|
||||||
export interface BlockchainContextDefinition {
|
export interface BlockchainContextDefinition {
|
||||||
(description: string, callback: BlockchainSuiteCallback): ISuite;
|
(description: string, callback: BlockchainSuiteCallback): ISuite;
|
||||||
|
config: Partial<BlockchainContextConfig>;
|
||||||
only: BlockchainContextDefinitionCallback<ISuite>;
|
only: BlockchainContextDefinitionCallback<ISuite>;
|
||||||
skip: BlockchainContextDefinitionCallback<void>;
|
skip: BlockchainContextDefinitionCallback<void>;
|
||||||
optional: BlockchainContextDefinitionCallback<ISuite | void>;
|
optional: BlockchainContextDefinitionCallback<ISuite | void>;
|
||||||
@ -120,10 +131,13 @@ export class ForkedBlockchainTestsEnvironmentSingleton extends BlockchainTestsEn
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static _createWeb3Provider(forkHost: string): Web3ProviderEngine {
|
protected static _createWeb3Provider(forkHost: string): Web3ProviderEngine {
|
||||||
|
const forkConfig = blockchainTests.config.fork || {};
|
||||||
|
const unlockedAccounts = forkConfig.unlockedAccounts;
|
||||||
return web3Factory.getRpcProvider({
|
return web3Factory.getRpcProvider({
|
||||||
...providerConfigs,
|
...providerConfigs,
|
||||||
fork: forkHost,
|
fork: forkHost,
|
||||||
blockTime: 0,
|
blockTime: 0,
|
||||||
|
...(unlockedAccounts ? { unlocked_accounts: unlockedAccounts } : {}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +223,7 @@ export const blockchainTests: BlockchainContextDefinition = _.assign(
|
|||||||
return defineBlockchainSuite(StandardBlockchainTestsEnvironmentSingleton, description, callback, describe);
|
return defineBlockchainSuite(StandardBlockchainTestsEnvironmentSingleton, description, callback, describe);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
config: {},
|
||||||
only(description: string, callback: BlockchainSuiteCallback): ISuite {
|
only(description: string, callback: BlockchainSuiteCallback): ISuite {
|
||||||
return defineBlockchainSuite(
|
return defineBlockchainSuite(
|
||||||
StandardBlockchainTestsEnvironmentSingleton,
|
StandardBlockchainTestsEnvironmentSingleton,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user