@0x/contracts-test-utils: Fix blockchainTests fork config to work with other tests.
				
					
				
			This commit is contained in:
		@@ -117,6 +117,15 @@ interface IDydx {
 | 
				
			|||||||
    )
 | 
					    )
 | 
				
			||||||
        external;
 | 
					        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.
 | 
					    /// @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.
 | 
					    ///      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
 | 
					    /// @param owner The owner of the accounts
 | 
				
			||||||
@@ -171,13 +180,4 @@ interface IDydx {
 | 
				
			|||||||
        external
 | 
					        external
 | 
				
			||||||
        view
 | 
					        view
 | 
				
			||||||
        returns (Value memory supplyValue, Value memory borrowValue);
 | 
					        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;
 | 
					        return _testTokenAddress;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// @dev Unused.
 | 
				
			||||||
 | 
					    function setOperators(OperatorArg[] calldata args) external {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// @dev Unused.
 | 
					    /// @dev Unused.
 | 
				
			||||||
    function getIsLocalOperator(
 | 
					    function getIsLocalOperator(
 | 
				
			||||||
        address owner,
 | 
					        address owner,
 | 
				
			||||||
@@ -216,9 +219,6 @@ contract TestDydxBridge is
 | 
				
			|||||||
        returns (Value memory supplyValue, Value memory borrowValue)
 | 
					        returns (Value memory supplyValue, Value memory borrowValue)
 | 
				
			||||||
    {}
 | 
					    {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// @dev Unused.
 | 
					 | 
				
			||||||
    function setOperators(OperatorArg[] calldata args) external {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /// @dev overrides `_getDydxAddress()` from `DeploymentConstants` to return this address.
 | 
					    /// @dev overrides `_getDydxAddress()` from `DeploymentConstants` to return this address.
 | 
				
			||||||
    function _getDydxAddress()
 | 
					    function _getDydxAddress()
 | 
				
			||||||
        internal
 | 
					        internal
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,11 +33,11 @@ enum DydxAssetReference {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const MAKER_ADDRESS = '0x3a9F7C8cA36C42d7035E87C3304eE5cBd353a532';
 | 
					const MAKER_ADDRESS = '0x3a9F7C8cA36C42d7035E87C3304eE5cBd353a532';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
blockchainTests.config = {
 | 
					blockchainTests.configure({
 | 
				
			||||||
    fork: {
 | 
					    fork: {
 | 
				
			||||||
        unlockedAccounts: [MAKER_ADDRESS],
 | 
					        unlockedAccounts: [MAKER_ADDRESS],
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
};
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
blockchainTests.fork('DevUtils dydx order validation tests', env => {
 | 
					blockchainTests.fork('DevUtils dydx order validation tests', env => {
 | 
				
			||||||
    const { ZERO_AMOUNT: ZERO } = constants;
 | 
					    const { ZERO_AMOUNT: ZERO } = constants;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,12 +30,14 @@ export interface BlockchainContextConfig {
 | 
				
			|||||||
    }>;
 | 
					    }>;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					let TEST_ENV_CONFIG: Partial<BlockchainContextConfig> = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 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>;
 | 
					    configure: (config?: Partial<BlockchainContextConfig>) => void;
 | 
				
			||||||
    only: BlockchainContextDefinitionCallback<ISuite>;
 | 
					    only: BlockchainContextDefinitionCallback<ISuite>;
 | 
				
			||||||
    skip: BlockchainContextDefinitionCallback<void>;
 | 
					    skip: BlockchainContextDefinitionCallback<void>;
 | 
				
			||||||
    optional: BlockchainContextDefinitionCallback<ISuite | void>;
 | 
					    optional: BlockchainContextDefinitionCallback<ISuite | void>;
 | 
				
			||||||
@@ -102,6 +104,11 @@ export class StandardBlockchainTestsEnvironmentSingleton extends BlockchainTests
 | 
				
			|||||||
        return StandardBlockchainTestsEnvironmentSingleton._instance;
 | 
					        return StandardBlockchainTestsEnvironmentSingleton._instance;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Reset the singleton.
 | 
				
			||||||
 | 
					    public static reset(): void {
 | 
				
			||||||
 | 
					        StandardBlockchainTestsEnvironmentSingleton._instance = undefined;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Get the singleton instance of this class.
 | 
					    // Get the singleton instance of this class.
 | 
				
			||||||
    public static getInstance(): StandardBlockchainTestsEnvironmentSingleton | undefined {
 | 
					    public static getInstance(): StandardBlockchainTestsEnvironmentSingleton | undefined {
 | 
				
			||||||
        return StandardBlockchainTestsEnvironmentSingleton._instance;
 | 
					        return StandardBlockchainTestsEnvironmentSingleton._instance;
 | 
				
			||||||
@@ -130,8 +137,13 @@ export class ForkedBlockchainTestsEnvironmentSingleton extends BlockchainTestsEn
 | 
				
			|||||||
        return ForkedBlockchainTestsEnvironmentSingleton._instance;
 | 
					        return ForkedBlockchainTestsEnvironmentSingleton._instance;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Reset the singleton.
 | 
				
			||||||
 | 
					    public static reset(): void {
 | 
				
			||||||
 | 
					        ForkedBlockchainTestsEnvironmentSingleton._instance = undefined;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected static _createWeb3Provider(forkHost: string): Web3ProviderEngine {
 | 
					    protected static _createWeb3Provider(forkHost: string): Web3ProviderEngine {
 | 
				
			||||||
        const forkConfig = blockchainTests.config.fork || {};
 | 
					        const forkConfig = TEST_ENV_CONFIG.fork || {};
 | 
				
			||||||
        const unlockedAccounts = forkConfig.unlockedAccounts;
 | 
					        const unlockedAccounts = forkConfig.unlockedAccounts;
 | 
				
			||||||
        return web3Factory.getRpcProvider({
 | 
					        return web3Factory.getRpcProvider({
 | 
				
			||||||
            ...providerConfigs,
 | 
					            ...providerConfigs,
 | 
				
			||||||
@@ -172,6 +184,11 @@ export class LiveBlockchainTestsEnvironmentSingleton extends BlockchainTestsEnvi
 | 
				
			|||||||
        return LiveBlockchainTestsEnvironmentSingleton._instance;
 | 
					        return LiveBlockchainTestsEnvironmentSingleton._instance;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Reset the singleton.
 | 
				
			||||||
 | 
					    public static reset(): void {
 | 
				
			||||||
 | 
					        LiveBlockchainTestsEnvironmentSingleton._instance = undefined;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected static _createWeb3Provider(rpcHost: string): Web3ProviderEngine {
 | 
					    protected static _createWeb3Provider(rpcHost: string): Web3ProviderEngine {
 | 
				
			||||||
        const providerEngine = new Web3ProviderEngine();
 | 
					        const providerEngine = new Web3ProviderEngine();
 | 
				
			||||||
        providerEngine.addProvider(new RPCSubprovider(rpcHost));
 | 
					        providerEngine.addProvider(new RPCSubprovider(rpcHost));
 | 
				
			||||||
@@ -223,7 +240,16 @@ export const blockchainTests: BlockchainContextDefinition = _.assign(
 | 
				
			|||||||
        return defineBlockchainSuite(StandardBlockchainTestsEnvironmentSingleton, description, callback, describe);
 | 
					        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 {
 | 
					        only(description: string, callback: BlockchainSuiteCallback): ISuite {
 | 
				
			||||||
            return defineBlockchainSuite(
 | 
					            return defineBlockchainSuite(
 | 
				
			||||||
                StandardBlockchainTestsEnvironmentSingleton,
 | 
					                StandardBlockchainTestsEnvironmentSingleton,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user