Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduces forking via integration tests #1307

Merged
merged 3 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ jobs:
- run: npx hardhat compile --optimizer --fail-oversize
- run: rm -rf build # force a clean build
- run: npx hardhat compile --use-ovm --optimizer --fail-oversize
job-fork-tests:
working_directory: ~/repo
docker:
- image: synthetixio/docker-node:14.16-focal
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_TOKEN
steps:
- checkout
- attach_workspace:
at: .
- run:
command: npm run fork
background: true
- cmd-wait-for-port:
port: 8545
- run: npx hardhat test:integration:l1 --compile --deploy --fork
job-integration-tests:
working_directory: ~/repo
machine:
Expand Down Expand Up @@ -63,7 +80,7 @@ jobs:
- run:
name: Run isolated layer 1 integration tests
command: |
npx hardhat test:integration:l1 --compile --deploy
npx hardhat test:integration:l1 --compile --deploy --provider-port 9545
- run:
name: Run isolated layer 2 integration tests
command: |
Expand Down Expand Up @@ -178,8 +195,8 @@ jobs:
git clone git@github.com:ethereum-optimism/optimism.git
cd optimism
git fetch
git checkout develop
git pull origin develop
git checkout master
git pull origin master
yarn
yarn build
cd ops
Expand Down Expand Up @@ -410,6 +427,9 @@ workflows:
- job-test-deploy-script:
requires:
- job-prepare
- job-fork-tests:
requires:
- job-prepare
- job-integration-tests:
requires:
- job-prepare
Expand Down
12 changes: 12 additions & 0 deletions .circleci/src/jobs/job-fork-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Starts a fork of mainnet, deploys the latest release, and runs L1 integration tests
{{> job-header.yml}}
steps:
- checkout
- attach_workspace:
at: .
- run:
command: npm run fork
background: true
- cmd-wait-for-port:
port: 8545
- run: npx hardhat test:integration:l1 --compile --deploy --fork
2 changes: 1 addition & 1 deletion .circleci/src/jobs/job-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ steps:
- run:
name: Run isolated layer 1 integration tests
command: |
npx hardhat test:integration:l1 --compile --deploy
npx hardhat test:integration:l1 --compile --deploy --provider-port 9545
- run:
name: Run isolated layer 2 integration tests
command: |
Expand Down
4 changes: 2 additions & 2 deletions .circleci/src/jobs/job-prod-tests-ovm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ steps:
git clone git@github.com:ethereum-optimism/optimism.git
cd optimism
git fetch
git checkout develop
git pull origin develop
git checkout master
git pull origin master
yarn
yarn build
cd ops
Expand Down
6 changes: 6 additions & 0 deletions .circleci/src/workflows/workflow-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ jobs:
- job-test-deploy-script:
{{> require-prepare.yml}}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Fork tests
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- job-fork-tests:
{{> require-prepare.yml}}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Integration tests
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
24 changes: 21 additions & 3 deletions hardhat/tasks/task-test-integration-l1.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
const { task } = require('hardhat/config');
const { compileInstance, deployInstance } = require('../../test/integration/utils/deploy');
const {
compileInstance,
prepareDeploy,
deployInstance,
} = require('../../test/integration/utils/deploy');

task('test:integration:l1', 'run isolated layer 1 production tests')
.addFlag('compile', 'Compile an l1 instance before running the tests')
.addFlag('deploy', 'Deploy an l1 instance before running the tests')
.addFlag('fork', 'Run the tests against a fork of mainnet')
.addOptionalParam(
'providerPort',
'The target port for the running local chain to test on',
'9545'
'8545'
)
.setAction(async (taskArguments, hre) => {
hre.config.paths.tests = './test/integration/l1/';
Expand All @@ -19,6 +24,7 @@ task('test:integration:l1', 'run isolated layer 1 production tests')
hre.config.mocha.timeout = timeout;
hre.config.mocha.bail = false;
hre.config.networks.localhost.timeout = timeout;
hre.config.fork = taskArguments.fork;

taskArguments.maxMemory = true;

Expand All @@ -27,7 +33,19 @@ task('test:integration:l1', 'run isolated layer 1 production tests')
}

if (taskArguments.deploy) {
await deployInstance({ useOvm: false, providerUrl, providerPort });
if (taskArguments.fork) {
await prepareDeploy({ network: 'mainnet' });
await deployInstance({
useFork: true,
network: 'mainnet',
useOvm: false,
freshDeploy: false,
providerUrl,
providerPort,
});
} else {
await deployInstance({ useOvm: false, providerUrl, providerPort });
}
}

await hre.run('test', taskArguments);
Expand Down
Loading