@0x/contracts-test-utils
: Fix blockchainTests
fork config to work with other tests.
This commit is contained in:
parent
d94a26f0f4
commit
bf9b4b993f
@ -117,6 +117,15 @@ interface IDydx {
|
||||
)
|
||||
external;
|
||||
|
||||
// @dev Approves/disapproves any number of operators. An operator is an external address that has the
|
||||
// same permissions to manipulate an account as the owner of the account. Operators are simply
|
||||
// addresses and therefore may either be externally-owned Ethereum accounts OR smart contracts.
|
||||
// Operators are also able to act as AutoTrader contracts on behalf of the account owner if the
|
||||
// operator is a smart contract and implements the IAutoTrader interface.
|
||||
// @param args A list of OperatorArgs which have an address and a boolean. The boolean value
|
||||
// denotes whether to approve (true) or revoke approval (false) for that address.
|
||||
function setOperators(OperatorArg[] calldata args) external;
|
||||
|
||||
/// @dev Return true if a particular address is approved as an operator for an owner's accounts.
|
||||
/// Approved operators can act on the accounts of the owner as if it were the operator's own.
|
||||
/// @param owner The owner of the accounts
|
||||
@ -171,13 +180,4 @@ interface IDydx {
|
||||
external
|
||||
view
|
||||
returns (Value memory supplyValue, Value memory borrowValue);
|
||||
|
||||
// @dev Approves/disapproves any number of operators. An operator is an external address that has the
|
||||
// same permissions to manipulate an account as the owner of the account. Operators are simply
|
||||
// addresses and therefore may either be externally-owned Ethereum accounts OR smart contracts.
|
||||
// Operators are also able to act as AutoTrader contracts on behalf of the account owner if the
|
||||
// operator is a smart contract and implements the IAutoTrader interface.
|
||||
// @param args A list of OperatorArgs which have an address and a boolean. The boolean value
|
||||
// denotes whether to approve (true) or revoke approval (false) for that address.
|
||||
function setOperators(OperatorArg[] calldata args) external;
|
||||
}
|
||||
|
@ -172,6 +172,9 @@ contract TestDydxBridge is
|
||||
return _testTokenAddress;
|
||||
}
|
||||
|
||||
/// @dev Unused.
|
||||
function setOperators(OperatorArg[] calldata args) external {}
|
||||
|
||||
/// @dev Unused.
|
||||
function getIsLocalOperator(
|
||||
address owner,
|
||||
@ -216,9 +219,6 @@ contract TestDydxBridge is
|
||||
returns (Value memory supplyValue, Value memory borrowValue)
|
||||
{}
|
||||
|
||||
/// @dev Unused.
|
||||
function setOperators(OperatorArg[] calldata args) external {}
|
||||
|
||||
/// @dev overrides `_getDydxAddress()` from `DeploymentConstants` to return this address.
|
||||
function _getDydxAddress()
|
||||
internal
|
||||
|
@ -33,11 +33,11 @@ enum DydxAssetReference {
|
||||
|
||||
const MAKER_ADDRESS = '0x3a9F7C8cA36C42d7035E87C3304eE5cBd353a532';
|
||||
|
||||
blockchainTests.config = {
|
||||
blockchainTests.configure({
|
||||
fork: {
|
||||
unlockedAccounts: [MAKER_ADDRESS],
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
blockchainTests.fork('DevUtils dydx order validation tests', env => {
|
||||
const { ZERO_AMOUNT: ZERO } = constants;
|
||||
|
@ -30,12 +30,14 @@ export interface BlockchainContextConfig {
|
||||
}>;
|
||||
}
|
||||
|
||||
let TEST_ENV_CONFIG: Partial<BlockchainContextConfig> = {};
|
||||
|
||||
/**
|
||||
* Interface for `blockchainTests()`.
|
||||
*/
|
||||
export interface BlockchainContextDefinition {
|
||||
(description: string, callback: BlockchainSuiteCallback): ISuite;
|
||||
config: Partial<BlockchainContextConfig>;
|
||||
configure: (config?: Partial<BlockchainContextConfig>) => void;
|
||||
only: BlockchainContextDefinitionCallback<ISuite>;
|
||||
skip: BlockchainContextDefinitionCallback<void>;
|
||||
optional: BlockchainContextDefinitionCallback<ISuite | void>;
|
||||
@ -102,6 +104,11 @@ export class StandardBlockchainTestsEnvironmentSingleton extends BlockchainTests
|
||||
return StandardBlockchainTestsEnvironmentSingleton._instance;
|
||||
}
|
||||
|
||||
// Reset the singleton.
|
||||
public static reset(): void {
|
||||
StandardBlockchainTestsEnvironmentSingleton._instance = undefined;
|
||||
}
|
||||
|
||||
// Get the singleton instance of this class.
|
||||
public static getInstance(): StandardBlockchainTestsEnvironmentSingleton | undefined {
|
||||
return StandardBlockchainTestsEnvironmentSingleton._instance;
|
||||
@ -130,8 +137,13 @@ export class ForkedBlockchainTestsEnvironmentSingleton extends BlockchainTestsEn
|
||||
return ForkedBlockchainTestsEnvironmentSingleton._instance;
|
||||
}
|
||||
|
||||
// Reset the singleton.
|
||||
public static reset(): void {
|
||||
ForkedBlockchainTestsEnvironmentSingleton._instance = undefined;
|
||||
}
|
||||
|
||||
protected static _createWeb3Provider(forkHost: string): Web3ProviderEngine {
|
||||
const forkConfig = blockchainTests.config.fork || {};
|
||||
const forkConfig = TEST_ENV_CONFIG.fork || {};
|
||||
const unlockedAccounts = forkConfig.unlockedAccounts;
|
||||
return web3Factory.getRpcProvider({
|
||||
...providerConfigs,
|
||||
@ -172,6 +184,11 @@ export class LiveBlockchainTestsEnvironmentSingleton extends BlockchainTestsEnvi
|
||||
return LiveBlockchainTestsEnvironmentSingleton._instance;
|
||||
}
|
||||
|
||||
// Reset the singleton.
|
||||
public static reset(): void {
|
||||
LiveBlockchainTestsEnvironmentSingleton._instance = undefined;
|
||||
}
|
||||
|
||||
protected static _createWeb3Provider(rpcHost: string): Web3ProviderEngine {
|
||||
const providerEngine = new Web3ProviderEngine();
|
||||
providerEngine.addProvider(new RPCSubprovider(rpcHost));
|
||||
@ -223,7 +240,16 @@ export const blockchainTests: BlockchainContextDefinition = _.assign(
|
||||
return defineBlockchainSuite(StandardBlockchainTestsEnvironmentSingleton, description, callback, describe);
|
||||
},
|
||||
{
|
||||
config: {},
|
||||
configure(config?: Partial<BlockchainContextConfig>): void {
|
||||
// Update the global config and reset all environment singletons.
|
||||
TEST_ENV_CONFIG = {
|
||||
...TEST_ENV_CONFIG,
|
||||
...config,
|
||||
};
|
||||
ForkedBlockchainTestsEnvironmentSingleton.reset();
|
||||
StandardBlockchainTestsEnvironmentSingleton.reset();
|
||||
LiveBlockchainTestsEnvironmentSingleton.reset();
|
||||
},
|
||||
only(description: string, callback: BlockchainSuiteCallback): ISuite {
|
||||
return defineBlockchainSuite(
|
||||
StandardBlockchainTestsEnvironmentSingleton,
|
||||
|
Loading…
x
Reference in New Issue
Block a user