diff --git a/packages/ovm-toolchain/buidler.config.ts b/packages/ovm-toolchain/buidler.config.ts index 6919831bc7e5..392348194936 100644 --- a/packages/ovm-toolchain/buidler.config.ts +++ b/packages/ovm-toolchain/buidler.config.ts @@ -1,5 +1,5 @@ import path from 'path' -import { usePlugin } from '@nomiclabs/buidler/config' +import { usePlugin, task } from '@nomiclabs/buidler/config' usePlugin('@nomiclabs/buidler-ethers') usePlugin('@nomiclabs/buidler-waffle') @@ -7,6 +7,19 @@ usePlugin('@nomiclabs/buidler-waffle') import './src/buidler-plugins/buidler-ovm-compiler' import './src/buidler-plugins/buidler-ovm-node' +task('test') + .addFlag('ovm', 'Run tests on the OVM using a custom OVM provider') + .setAction(async (taskArguments, bre: any, runSuper) => { + if (taskArguments.ovm) { + console.log('Compiling and running tests in the OVM...') + bre.config.solc = { + path: path.resolve(__dirname, '../../node_modules/@eth-optimism/solc'), + } + await bre.config.startOvmNode() + } + await runSuper(taskArguments) + }) + const config: any = { networks: { buidlerevm: { @@ -23,9 +36,8 @@ const config: any = { timeout: 50000, }, solc: { - path: path.resolve(__dirname, '../../node_modules/@eth-optimism/solc'), + version: '0.5.16', }, - useOvm: true, } export default config diff --git a/packages/ovm-toolchain/package.json b/packages/ovm-toolchain/package.json index 73af343f9b0f..ebf106336b01 100644 --- a/packages/ovm-toolchain/package.json +++ b/packages/ovm-toolchain/package.json @@ -25,10 +25,10 @@ "build:waffle": "waffle \"test/config/waffle-config.json\"", "build:typescript": "tsc -p .", "clean": "rimraf build/", - "test": "yarn run test:truffle && yarn run test:waffle-v2", + "test": "yarn run test:truffle && yarn run test:waffle-v2 && yarn run test:buidler", "test:truffle": "truffle test \"test/test-truffle/erc20.spec.js\" --config \"test/config/truffle-config.js\"", "test:waffle-v2": "waffle \"test/config/waffle-config.json\" && mocha --require source-map-support/register --require ts-node/register \"test/test-waffle-v2/**/*.spec.ts\" --timeout 10000", - "test:buidler": "buidler test" + "test:buidler": "buidler test --ovm" }, "keywords": [ "optimistic", diff --git a/packages/ovm-toolchain/src/buidler-plugins/buidler-ovm-node.ts b/packages/ovm-toolchain/src/buidler-plugins/buidler-ovm-node.ts index 9f054c3e4c46..d3c33be07d60 100644 --- a/packages/ovm-toolchain/src/buidler-plugins/buidler-ovm-node.ts +++ b/packages/ovm-toolchain/src/buidler-plugins/buidler-ovm-node.ts @@ -6,7 +6,7 @@ const BN = require('bn.js') extendEnvironment(async (bre) => { const config: any = bre.config - if (config.useOvm) { + config.startOvmNode = async (): Promise => { const gasLimit = 100_000_000 // Initialize the provider so it has a VM instance ready to copy.