Commit 8f85a105 authored by Liam Horne's avatar Liam Horne

test: enable auto start of docker-compose services in integration tests

parent 4837aaed
...@@ -69,7 +69,6 @@ cd ops ...@@ -69,7 +69,6 @@ cd ops
export COMPOSE_DOCKER_CLI_BUILD=1 export COMPOSE_DOCKER_CLI_BUILD=1
export DOCKER_BUILDKIT=1 export DOCKER_BUILDKIT=1
docker-compose build docker-compose build
docker-compose up -d
cd ../integration-tests cd ../integration-tests
yarn build:integration yarn build:integration
yarn test:integration yarn test:integration
......
...@@ -23,12 +23,14 @@ ...@@ -23,12 +23,14 @@
"@nomiclabs/hardhat-ethers": "^2.0.2", "@nomiclabs/hardhat-ethers": "^2.0.2",
"chai": "^4.3.3", "chai": "^4.3.3",
"chai-as-promised": "^7.1.1", "chai-as-promised": "^7.1.1",
"docker-compose": "^0.23.8",
"envalid": "^7.1.0", "envalid": "^7.1.0",
"ethereum-waffle": "^3.3.0", "ethereum-waffle": "^3.3.0",
"ethers": "^5.0.32", "ethers": "^5.0.32",
"hardhat": "^2.2.1", "hardhat": "^2.2.1",
"hardhat-gas-reporter": "^1.0.4", "hardhat-gas-reporter": "^1.0.4",
"mocha": "^8.3.1", "mocha": "^8.3.1",
"rimraf": "^3.0.2" "rimraf": "^3.0.2",
"shelljs": "^0.8.4"
} }
} }
...@@ -8,6 +8,12 @@ import { Direction } from './shared/watcher-utils' ...@@ -8,6 +8,12 @@ import { Direction } from './shared/watcher-utils'
import l1SimpleStorageJson from '../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json' import l1SimpleStorageJson from '../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json'
import l2SimpleStorageJson from '../artifacts-ovm/contracts/SimpleStorage.sol/SimpleStorage.json' import l2SimpleStorageJson from '../artifacts-ovm/contracts/SimpleStorage.sol/SimpleStorage.json'
import { OptimismEnv } from './shared/env' import { OptimismEnv } from './shared/env'
import { DockerComposeNetwork } from './shared/docker-compose'
before(async () => {
await new DockerComposeNetwork().up()
})
describe('Basic L1<>L2 Communication', async () => { describe('Basic L1<>L2 Communication', async () => {
let Factory__L1SimpleStorage: ContractFactory let Factory__L1SimpleStorage: ContractFactory
......
...@@ -3,6 +3,12 @@ import { ethers } from 'hardhat' ...@@ -3,6 +3,12 @@ import { ethers } from 'hardhat'
import { expect } from 'chai' import { expect } from 'chai'
import { GWEI } from './shared/utils' import { GWEI } from './shared/utils'
import { OptimismEnv } from './shared/env' import { OptimismEnv } from './shared/env'
import { DockerComposeNetwork } from './shared/docker-compose'
before(async () => {
await new DockerComposeNetwork().up()
})
describe('Basic ERC20 interactions', async () => { describe('Basic ERC20 interactions', async () => {
const initialAmount = 1000 const initialAmount = 1000
......
...@@ -3,6 +3,11 @@ import chaiAsPromised from 'chai-as-promised' ...@@ -3,6 +3,11 @@ import chaiAsPromised from 'chai-as-promised'
chai.use(chaiAsPromised) chai.use(chaiAsPromised)
import { BigNumber, utils } from 'ethers' import { BigNumber, utils } from 'ethers'
import { OptimismEnv } from './shared/env' import { OptimismEnv } from './shared/env'
import { DockerComposeNetwork } from './shared/docker-compose'
before(async () => {
await new DockerComposeNetwork().up()
})
describe('Fee Payment Integration Tests', async () => { describe('Fee Payment Integration Tests', async () => {
let env: OptimismEnv let env: OptimismEnv
......
...@@ -2,9 +2,15 @@ import { expect } from 'chai' ...@@ -2,9 +2,15 @@ import { expect } from 'chai'
import { Wallet, utils, BigNumber } from 'ethers' import { Wallet, utils, BigNumber } from 'ethers'
import { Direction } from './shared/watcher-utils' import { Direction } from './shared/watcher-utils'
import { DockerComposeNetwork } from './shared/docker-compose'
import { PROXY_SEQUENCER_ENTRYPOINT_ADDRESS } from './shared/utils' import { PROXY_SEQUENCER_ENTRYPOINT_ADDRESS } from './shared/utils'
import { OptimismEnv } from './shared/env' import { OptimismEnv } from './shared/env'
before(async () => {
await new DockerComposeNetwork().up()
})
describe('Native ETH Integration Tests', async () => { describe('Native ETH Integration Tests', async () => {
let env: OptimismEnv let env: OptimismEnv
let l1Bob: Wallet let l1Bob: Wallet
......
...@@ -8,9 +8,15 @@ import { ...@@ -8,9 +8,15 @@ import {
getAddressManager, getAddressManager,
} from './shared/utils' } from './shared/utils'
import { OptimismEnv } from './shared/env' import { OptimismEnv } from './shared/env'
import { DockerComposeNetwork } from './shared/docker-compose'
import { getContractFactory } from '@eth-optimism/contracts' import { getContractFactory } from '@eth-optimism/contracts'
import { Contract, ContractFactory, Wallet, BigNumber } from 'ethers' import { Contract, ContractFactory, Wallet, BigNumber } from 'ethers'
before(async () => {
await new DockerComposeNetwork().up()
})
/** /**
* These tests cover the OVM execution contexts. In the OVM execution * These tests cover the OVM execution contexts. In the OVM execution
* of a L1 to L2 transaction, both `block.number` and `block.timestamp` * of a L1 to L2 transaction, both `block.number` and `block.timestamp`
......
...@@ -2,11 +2,16 @@ ...@@ -2,11 +2,16 @@
import { injectL2Context } from '@eth-optimism/core-utils' import { injectL2Context } from '@eth-optimism/core-utils'
import { sleep } from './shared/utils' import { sleep } from './shared/utils'
import { OptimismEnv } from './shared/env' import { OptimismEnv } from './shared/env'
import { DockerComposeNetwork } from './shared/docker-compose'
/* Imports: External */ /* Imports: External */
import { providers } from 'ethers' import { providers } from 'ethers'
import { expect } from 'chai' import { expect } from 'chai'
before(async () => {
await new DockerComposeNetwork().up()
})
// This test ensures that the transactions which get `enqueue`d get // This test ensures that the transactions which get `enqueue`d get
// added to the L2 blocks by the Sync Service (which queries the DTL) // added to the L2 blocks by the Sync Service (which queries the DTL)
describe('Queue Ingestion', () => { describe('Queue Ingestion', () => {
......
...@@ -4,6 +4,12 @@ import { ethers } from 'hardhat' ...@@ -4,6 +4,12 @@ import { ethers } from 'hardhat'
/* Imports: External */ /* Imports: External */
import { Contract, Wallet } from 'ethers' import { Contract, Wallet } from 'ethers'
import { OptimismEnv } from './shared/env' import { OptimismEnv } from './shared/env'
import { DockerComposeNetwork } from './shared/docker-compose'
before(async () => {
await new DockerComposeNetwork().up()
})
describe('Reading events from proxy contracts', () => { describe('Reading events from proxy contracts', () => {
let l2Wallet: Wallet let l2Wallet: Wallet
......
import { injectL2Context } from '@eth-optimism/core-utils' import { injectL2Context } from '@eth-optimism/core-utils'
import { Wallet, BigNumber } from 'ethers' import { Wallet, BigNumber } from 'ethers'
import chai, { expect } from 'chai' import chai, { expect } from 'chai'
import { sleep, l2Provider, GWEI } from './shared/utils' import { sleep, l2Provider, GWEI } from './shared/utils'
import chaiAsPromised from 'chai-as-promised' import chaiAsPromised from 'chai-as-promised'
import { OptimismEnv } from './shared/env' import { OptimismEnv } from './shared/env'
import { DockerComposeNetwork } from './shared/docker-compose'
chai.use(chaiAsPromised) chai.use(chaiAsPromised)
before(async () => {
await new DockerComposeNetwork().up()
})
describe('Basic RPC tests', () => { describe('Basic RPC tests', () => {
let env: OptimismEnv let env: OptimismEnv
......
import * as compose from 'docker-compose'
import * as shell from 'shelljs'
import * as path from 'path'
type ServiceNames = 'batch_submitter' | 'dtl' | 'l2geth' | 'relayer'
const OPS_DIRECTORY = path.join(process.cwd(), '../ops')
const DEFAULT_SERVICES: ServiceNames[] = ['batch_submitter', 'dtl', 'l2geth', 'relayer']
export class DockerComposeNetwork {
constructor(private readonly services: ServiceNames[] = DEFAULT_SERVICES) {}
async up() {
const out = await compose.upMany(this.services, {cwd: OPS_DIRECTORY})
const {err, exitCode} = out;
if (!err || exitCode) {
console.error(err)
throw new Error('Unexpected error when starting docker-compose network, dumping output')
}
if (err.includes('Creating')) {
console.info('🐳 Tests required starting containers. Waiting for sequencer to ready.')
shell.exec(`${OPS_DIRECTORY}/scripts/wait-for-sequencer.sh`, {cwd: OPS_DIRECTORY})
}
}
}
...@@ -5058,6 +5058,13 @@ directory-tree@^2.2.7: ...@@ -5058,6 +5058,13 @@ directory-tree@^2.2.7:
resolved "https://registry.yarnpkg.com/directory-tree/-/directory-tree-2.2.7.tgz#4617c794ee89d5618f03fffb7486c7e49df52ad2" resolved "https://registry.yarnpkg.com/directory-tree/-/directory-tree-2.2.7.tgz#4617c794ee89d5618f03fffb7486c7e49df52ad2"
integrity sha512-fgTad/YdV6Y2njsCRK4fl4ZUlGhmb5xj1qrZUIMjvnrKvghVqh8dkB+OUssjYVvb/Q2L+5+8XG0l5uTGI9/8iQ== integrity sha512-fgTad/YdV6Y2njsCRK4fl4ZUlGhmb5xj1qrZUIMjvnrKvghVqh8dkB+OUssjYVvb/Q2L+5+8XG0l5uTGI9/8iQ==
docker-compose@^0.23.8:
version "0.23.8"
resolved "https://registry.yarnpkg.com/docker-compose/-/docker-compose-0.23.8.tgz#475b1e1294821d380316c54277ad350074186c6f"
integrity sha512-uUxjnz77oU+HBwwRYKO/O5a1IywSZbWNayC1+q4e4t3HzKwBHi+5pmIpESjpsEvIVl/HWAC3mPB89NjUNEBWuQ==
dependencies:
yaml "^1.10.2"
dom-walk@^0.1.0: dom-walk@^0.1.0:
version "0.1.2" version "0.1.2"
resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.2.tgz#0c548bef048f4d1f2a97249002236060daa3fd84" resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.2.tgz#0c548bef048f4d1f2a97249002236060daa3fd84"
...@@ -11663,7 +11670,7 @@ shebang-regex@^3.0.0: ...@@ -11663,7 +11670,7 @@ shebang-regex@^3.0.0:
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
shelljs@^0.8.3: shelljs@^0.8.3, shelljs@^0.8.4:
version "0.8.4" version "0.8.4"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.4.tgz#de7684feeb767f8716b326078a8a00875890e3c2" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.4.tgz#de7684feeb767f8716b326078a8a00875890e3c2"
integrity sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ== integrity sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==
...@@ -14063,7 +14070,7 @@ yallist@^4.0.0: ...@@ -14063,7 +14070,7 @@ yallist@^4.0.0:
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
yaml@^1.10.0: yaml@^1.10.0, yaml@^1.10.2:
version "1.10.2" version "1.10.2"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"
integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment