Commit e442dca1 authored by Georgios Konstantopoulos's avatar Georgios Konstantopoulos Committed by GitHub

test: allow configuring integration tests with env vars (#669)

parent bdba203d
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
"@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",
"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",
......
import { Direction, waitForXDomainTransaction } from './watcher-utils'
import { import {
getContractFactory, getContractFactory,
getContractInterface, getContractInterface,
...@@ -11,28 +13,28 @@ import { ...@@ -11,28 +13,28 @@ import {
BigNumberish, BigNumberish,
BigNumber, BigNumber,
} from 'ethers' } from 'ethers'
import { Direction, waitForXDomainTransaction } from './watcher-utils' import { cleanEnv, str, num } from 'envalid'
export const GWEI = BigNumber.from(1e9) export const GWEI = BigNumber.from(1e9)
const env = cleanEnv(process.env, {
L1_URL: str({ default: "http://localhost:9545" }),
L2_URL: str({ default: "http://localhost:8545" }),
L1_POLLING_INTERVAL: num({ default: 10 }),
L2_POLLING_INTERVAL: num({ default: 10 }),
PRIVATE_KEY: str({ default: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80' }),
ADDRESS_MANAGER: str({ default: '0x5FbDB2315678afecb367f032d93F642f64180aa3' })
})
// The hardhat instance // The hardhat instance
const l1HttpPort = 9545 export const l1Provider = new providers.JsonRpcProvider(env.L1_URL)
export const l1Provider = new providers.JsonRpcProvider( l1Provider.pollingInterval = env.L1_POLLING_INTERVAL
`http://localhost:${l1HttpPort}`
) export const l2Provider = new providers.JsonRpcProvider(env.L2_URL)
l1Provider.pollingInterval = 10 l2Provider.pollingInterval = env.L2_POLLING_INTERVAL
const httpPort = 8545
export const l2Provider = new providers.JsonRpcProvider(
`http://localhost:${httpPort}`
)
l2Provider.pollingInterval = 10
// The sequencer private key which is funded on L1 // The sequencer private key which is funded on L1
export const l1Wallet = new Wallet( export const l1Wallet = new Wallet(env.PRIVATE_KEY, l1Provider)
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
l1Provider
)
// A random private key which should always be funded with deposits from L1 -> L2 // A random private key which should always be funded with deposits from L1 -> L2
// if it's using non-0 gas price // if it's using non-0 gas price
...@@ -43,14 +45,10 @@ export const PROXY_SEQUENCER_ENTRYPOINT_ADDRESS = ...@@ -43,14 +45,10 @@ export const PROXY_SEQUENCER_ENTRYPOINT_ADDRESS =
'0x4200000000000000000000000000000000000004' '0x4200000000000000000000000000000000000004'
export const OVM_ETH_ADDRESS = '0x4200000000000000000000000000000000000006' export const OVM_ETH_ADDRESS = '0x4200000000000000000000000000000000000006'
// The address manager is always at the same address in testnet deployments
export const addressManagerAddress =
'0x5FbDB2315678afecb367f032d93F642f64180aa3'
export const getAddressManager = (provider: any) => { export const getAddressManager = (provider: any) => {
return getContractFactory('Lib_AddressManager') return getContractFactory('Lib_AddressManager')
.connect(provider) .connect(provider)
.attach(addressManagerAddress) .attach(env.ADDRESS_MANAGER)
} }
// Gets the gateway using the proxy if available // Gets the gateway using the proxy if available
......
...@@ -5216,6 +5216,11 @@ env-paths@^2.2.0: ...@@ -5216,6 +5216,11 @@ env-paths@^2.2.0:
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2" resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2"
integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A== integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==
envalid@^7.1.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/envalid/-/envalid-7.1.0.tgz#fccc499abb257e3992d73b02d014c867a85e2a69"
integrity sha512-C5rtCxfj+ozW5q79fBYKcBEf0KSNklKwZudjCzXy9ANT8Pz1MKxPBn6unZnYXXy6e+cqVgnEURQeXmdueG9/kA==
envinfo@^7.7.4: envinfo@^7.7.4:
version "7.8.1" version "7.8.1"
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475"
......
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