Skip to content

Commit

Permalink
test: allow configuring integration tests with env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
gakonst committed Apr 28, 2021
1 parent 122df8c commit f228618
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
1 change: 1 addition & 0 deletions integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@nomiclabs/hardhat-ethers": "^2.0.2",
"chai": "^4.3.3",
"chai-as-promised": "^7.1.1",
"envalid": "^7.1.0",
"ethereum-waffle": "^3.3.0",
"ethers": "^5.0.32",
"hardhat": "^2.2.1",
Expand Down
40 changes: 19 additions & 21 deletions integration-tests/test/shared/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Direction, waitForXDomainTransaction } from './watcher-utils'

import {
getContractFactory,
getContractInterface,
Expand All @@ -11,28 +13,28 @@ import {
BigNumberish,
BigNumber,
} from 'ethers'
import { Direction, waitForXDomainTransaction } from './watcher-utils'
import { cleanEnv, str, num } from 'envalid'

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
const l1HttpPort = 9545
export const l1Provider = new providers.JsonRpcProvider(
`http://localhost:${l1HttpPort}`
)
l1Provider.pollingInterval = 10

const httpPort = 8545
export const l2Provider = new providers.JsonRpcProvider(
`http://localhost:${httpPort}`
)
l2Provider.pollingInterval = 10
export const l1Provider = new providers.JsonRpcProvider(env.L1_URL)
l1Provider.pollingInterval = env.L1_POLLING_INTERVAL

export const l2Provider = new providers.JsonRpcProvider(env.L2_URL)
l2Provider.pollingInterval = env.L2_POLLING_INTERVAL

// The sequencer private key which is funded on L1
export const l1Wallet = new Wallet(
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
l1Provider
)
export const l1Wallet = new Wallet(env.PRIVATE_KEY, l1Provider)

// A random private key which should always be funded with deposits from L1 -> L2
// if it's using non-0 gas price
Expand All @@ -43,14 +45,10 @@ export const PROXY_SEQUENCER_ENTRYPOINT_ADDRESS =
'0x4200000000000000000000000000000000000004'
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) => {
return getContractFactory('Lib_AddressManager')
.connect(provider)
.attach(addressManagerAddress)
.attach(env.ADDRESS_MANAGER)
}

// Gets the gateway using the proxy if available
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5216,6 +5216,11 @@ env-paths@^2.2.0:
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2"
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:
version "7.8.1"
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475"
Expand Down

0 comments on commit f228618

Please sign in to comment.