Skip to content

Commit 347a914

Browse files
Enables separate folder compilation for integration tests (#1322)
* Enables separate folder compilation for integration tests * Clean install
1 parent a7ae3f8 commit 347a914

File tree

9 files changed

+128
-76
lines changed

9 files changed

+128
-76
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
- run:
9090
name: Run dual layer 1 and layer 2 integration tests
9191
command: |
92-
npx hardhat test:integration:dual --deploy
92+
npx hardhat test:integration:dual --deploy-evm --deploy-ovm --connect
9393
job-lint:
9494
working_directory: ~/repo
9595
docker:

.circleci/src/jobs/job-integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ steps:
4141
- run:
4242
name: Run dual layer 1 and layer 2 integration tests
4343
command: |
44-
npx hardhat test:integration:dual --deploy
44+
npx hardhat test:integration:dual --deploy-evm --deploy-ovm --connect

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ deploy_settings.py
55

66
# gitignore - Truffle proj
77
.idea/
8-
build
98
bin/
109
node_modules
1110
yarn-error.log
@@ -17,7 +16,7 @@ site/
1716
.env
1817

1918
# Build artifacts
20-
flattened-contracts/
19+
build*/
2120

2221
# For eth-gas-reporter in tests
2322
test-gas-used.log

hardhat/tasks/task-test-integration-dual.js

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
const path = require('path');
2+
const {
3+
constants: { BUILD_FOLDER },
4+
} = require('../..');
15
const { task } = require('hardhat/config');
26
const {
37
compileInstance,
@@ -6,28 +10,58 @@ const {
610
} = require('../../test/integration/utils/deploy');
711

812
task('test:integration:dual', 'run integrated layer 1 and layer 2 production tests')
9-
.addFlag('deploy', 'Deploy l1 and l2 instances before running the tests')
13+
.addFlag('compileEvm', 'Compile the l1 instance before running the tests')
14+
.addFlag('compileOvm', 'Compile the l2 instance before running the tests')
15+
.addFlag('deployEvm', 'Deploy the l1 instance before running the tests')
16+
.addFlag('deployOvm', 'Deploy the l2 instance before running the tests')
17+
.addFlag('connect', 'Connect deployed l1 and l2 instances before running the tests')
18+
.addOptionalParam('buildPathEvm', 'The target build path for the evm artifacts')
19+
.addOptionalParam('buildPathOvm', 'The target build path for the ovm artifacts')
1020
.setAction(async (taskArguments, hre) => {
1121
hre.config.paths.tests = './test/integration/dual/';
1222

1323
const providerUrl = (hre.config.providerUrl = 'http://localhost');
1424
const providerPortL1 = (hre.config.providerPortL1 = '9545');
1525
const providerPortL2 = (hre.config.providerPortL2 = '8545');
26+
const buildPathEvm =
27+
taskArguments.buildPathEvm || path.join(__dirname, '..', '..', BUILD_FOLDER);
28+
const buildPathOvm =
29+
taskArguments.buildPathOvm || path.join(__dirname, '..', '..', `${BUILD_FOLDER}-ovm`);
1630

1731
const timeout = 600000; // 10m
1832
hre.config.mocha.timeout = timeout;
19-
hre.config.mocha.bail = false;
33+
hre.config.mocha.bail = true;
2034
hre.config.networks.localhost.timeout = timeout;
2135

2236
taskArguments.maxMemory = true;
2337

24-
if (taskArguments.deploy) {
25-
await compileInstance({ useOvm: false });
26-
await deployInstance({ useOvm: false, providerUrl, providerPort: providerPortL1 });
38+
if (taskArguments.compileEvm) {
39+
await compileInstance({ useOvm: false, buildPath: buildPathEvm });
40+
}
41+
42+
if (taskArguments.compileOvm) {
43+
await compileInstance({ useOvm: true, buildPath: buildPathEvm });
44+
}
2745

28-
await compileInstance({ useOvm: true });
29-
await deployInstance({ useOvm: true, providerUrl, providerPort: providerPortL2 });
46+
if (taskArguments.deployEvm) {
47+
await deployInstance({
48+
useOvm: false,
49+
providerUrl,
50+
providerPort: providerPortL1,
51+
buildPath: buildPathEvm,
52+
});
53+
}
54+
55+
if (taskArguments.deployOvm) {
56+
await deployInstance({
57+
useOvm: true,
58+
providerUrl,
59+
providerPort: providerPortL2,
60+
buildPath: buildPathOvm,
61+
});
62+
}
3063

64+
if (taskArguments.connect) {
3165
await connectInstances({ providerUrl, providerPortL1, providerPortL2 });
3266
}
3367

hardhat/tasks/task-test-integration-l1.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
const path = require('path');
2+
const {
3+
constants: { BUILD_FOLDER },
4+
} = require('../..');
15
const { task } = require('hardhat/config');
26
const {
37
compileInstance,
@@ -9,6 +13,7 @@ task('test:integration:l1', 'run isolated layer 1 production tests')
913
.addFlag('compile', 'Compile an l1 instance before running the tests')
1014
.addFlag('deploy', 'Deploy an l1 instance before running the tests')
1115
.addFlag('fork', 'Run the tests against a fork of mainnet')
16+
.addOptionalParam('buildPath', 'The target build path for the evm artifacts')
1217
.addOptionalParam(
1318
'providerPort',
1419
'The target port for the running local chain to test on',
@@ -19,17 +24,18 @@ task('test:integration:l1', 'run isolated layer 1 production tests')
1924

2025
const providerUrl = (hre.config.providerUrl = 'http://localhost');
2126
const providerPort = (hre.config.providerPort = taskArguments.providerPort);
27+
const buildPath = taskArguments.buildPath || path.join(__dirname, '..', '..', BUILD_FOLDER);
2228

2329
const timeout = 600000; // 10m
2430
hre.config.mocha.timeout = timeout;
25-
hre.config.mocha.bail = false;
31+
hre.config.mocha.bail = true;
2632
hre.config.networks.localhost.timeout = timeout;
2733
hre.config.fork = taskArguments.fork;
2834

2935
taskArguments.maxMemory = true;
3036

3137
if (taskArguments.compile) {
32-
await compileInstance({ useOvm: false });
38+
await compileInstance({ useOvm: false, buildPath });
3339
}
3440

3541
if (taskArguments.deploy) {
@@ -42,9 +48,10 @@ task('test:integration:l1', 'run isolated layer 1 production tests')
4248
freshDeploy: false,
4349
providerUrl,
4450
providerPort,
51+
buildPath,
4552
});
4653
} else {
47-
await deployInstance({ useOvm: false, providerUrl, providerPort });
54+
await deployInstance({ useOvm: false, providerUrl, providerPort, buildPath });
4855
}
4956
}
5057

hardhat/tasks/task-test-integration-l2.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
const path = require('path');
2+
const {
3+
constants: { BUILD_FOLDER },
4+
} = require('../..');
15
const { task } = require('hardhat/config');
26
const { compileInstance, deployInstance } = require('../../test/integration/utils/deploy');
37

@@ -9,28 +13,32 @@ task('test:integration:l2', 'run isolated layer 2 production tests')
913
'The target port for the running local chain to test on',
1014
'8545'
1115
)
16+
.addOptionalParam('buildPath', 'The target build path for the ovm artifacts')
1217
.setAction(async (taskArguments, hre) => {
1318
hre.config.paths.tests = './test/integration/l2/';
1419

1520
const providerUrl = (hre.config.providerUrl = 'http://localhost');
1621
const providerPort = (hre.config.providerPort = taskArguments.providerPort);
22+
const buildPath =
23+
taskArguments.buildPath || path.join(__dirname, '..', '..', `${BUILD_FOLDER}-ovm`);
1724

1825
const timeout = 600000; // 10m
1926
hre.config.mocha.timeout = timeout;
20-
hre.config.mocha.bail = false;
27+
hre.config.mocha.bail = true;
2128
hre.config.networks.localhost.timeout = timeout;
2229

2330
taskArguments.maxMemory = true;
2431

2532
if (taskArguments.compile) {
26-
await compileInstance({ useOvm: true });
33+
await compileInstance({ useOvm: true, buildPath });
2734
}
2835

2936
if (taskArguments.deploy) {
3037
await deployInstance({
3138
useOvm: true,
3239
providerUrl,
3340
providerPort,
41+
buildPath,
3442
});
3543
}
3644

0 commit comments

Comments
 (0)