From 53df2130ea734fe49e34d24a25d71aa662e4b72b Mon Sep 17 00:00:00 2001 From: Lawrence Forman Date: Tue, 8 Oct 2019 09:27:53 +0900 Subject: [PATCH] `@0x/contracts-asset-proxy`: Remove `only` modifier on uniswap tests. --- contracts/asset-proxy/test/uniswap_bridge.ts | 2 +- packages/sol-compiler/src/cli.ts | 1 + packages/sol-compiler/src/compiler.ts | 14 +++++++++++-- packages/sol-compiler/src/utils/compiler.ts | 22 ++++++++++++++++---- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/contracts/asset-proxy/test/uniswap_bridge.ts b/contracts/asset-proxy/test/uniswap_bridge.ts index 92e70d5ca1..48c6d2883b 100644 --- a/contracts/asset-proxy/test/uniswap_bridge.ts +++ b/contracts/asset-proxy/test/uniswap_bridge.ts @@ -29,7 +29,7 @@ import { TestUniswapBridgeWethWithdrawEventArgs as WethWithdrawArgs, } from '../src'; -blockchainTests.resets.only('UniswapBridge unit tests', env => { +blockchainTests.resets('UniswapBridge unit tests', env => { const txHelper = new TransactionHelper(env.web3Wrapper, artifacts); let testContract: TestUniswapBridgeContract; let wethTokenAddress: string; diff --git a/packages/sol-compiler/src/cli.ts b/packages/sol-compiler/src/cli.ts index aa71246542..e53a680af2 100644 --- a/packages/sol-compiler/src/cli.ts +++ b/packages/sol-compiler/src/cli.ts @@ -40,6 +40,7 @@ const SEPARATOR = ','; contractsDir: argv.contractsDir, artifactsDir: argv.artifactsDir, contracts, + isOfflineMode: process.env.SOLC_OFFLINE ? true : undefined, }; const compiler = new Compiler(opts); if (argv.watch) { diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts index 919f9909bc..1c16a72829 100644 --- a/packages/sol-compiler/src/compiler.ts +++ b/packages/sol-compiler/src/compiler.ts @@ -28,7 +28,10 @@ import { createDirIfDoesNotExistAsync, getContractArtifactIfExistsAsync, getDependencyNameToPackagePath, + getSolcJSAsync, + getSolcJSFromPath, getSolcJSReleasesAsync, + getSolcJSVersionFromPath, getSourcesWithDependencies, getSourceTreeHash, makeContractPathsRelative, @@ -106,7 +109,10 @@ export class Compiler { : {}; assert.doesConformToSchema('compiler.json', config, compilerOptionsSchema); this._contractsDir = path.resolve(passedOpts.contractsDir || config.contractsDir || DEFAULT_CONTRACTS_DIR); - this._solcVersionIfExists = passedOpts.solcVersion || config.solcVersion; + this._solcVersionIfExists = + process.env.SOLCJS_PATH !== undefined + ? getSolcJSVersionFromPath(process.env.SOLCJS_PATH) + : passedOpts.solcVersion || config.solcVersion; this._compilerSettings = { ...DEFAULT_COMPILER_SETTINGS, ...config.compilerSettings, @@ -292,7 +298,11 @@ export class Compiler { compilerOutput = await compileDockerAsync(solcVersion, input.standardInput); } else { fullSolcVersion = solcJSReleases[solcVersion]; - compilerOutput = await compileSolcJSAsync(solcVersion, input.standardInput, this._isOfflineMode); + const solcInstance = + process.env.SOLCJS_PATH !== undefined + ? getSolcJSFromPath(process.env.SOLCJS_PATH) + : await getSolcJSAsync(solcVersion, this._isOfflineMode); + compilerOutput = await compileSolcJSAsync(solcInstance, input.standardInput); } if (compilerOutput.errors !== undefined) { printCompilationErrorsAndWarnings(compilerOutput.errors); diff --git a/packages/sol-compiler/src/utils/compiler.ts b/packages/sol-compiler/src/utils/compiler.ts index 085e1a55f2..c5d96ca0cc 100644 --- a/packages/sol-compiler/src/utils/compiler.ts +++ b/packages/sol-compiler/src/utils/compiler.ts @@ -136,16 +136,14 @@ export async function getSolcJSReleasesAsync(isOfflineMode: boolean): Promise { - const solcInstance = await getSolcJSAsync(solcVersion, isOfflineMode); const standardInputStr = JSON.stringify(standardInput); const standardOutputStr = solcInstance.compileStandardWrapper(standardInputStr); const compiled: solc.StandardOutput = JSON.parse(standardOutputStr); @@ -364,6 +362,22 @@ export async function getSolcJSAsync(solcVersion: string, isOfflineMode: boolean return solcInstance; } +/** + * Gets the solidity compiler instance from a module path. + * @param path The path to the solc module. + */ +export function getSolcJSFromPath(modulePath: string): solc.SolcInstance { + return require(modulePath); +} + +/** + * Gets the solidity compiler version from a module path. + * @param path The path to the solc module. + */ +export function getSolcJSVersionFromPath(modulePath: string): string { + return require(modulePath).version(); +} + /** * Solidity compiler emits the bytecode without a 0x prefix for a hex. This function fixes it if bytecode is present. * @param compiledContract The standard JSON output section for a contract. Geth modified in place.