Run ethereum tests on CI (#1028)
* Add makefile to run ethereum tests * Run tests on CI * single rm in make clean Co-authored-by: Jeff Schroeder <jeffschroeder@computer.org> * Fix WETH address in bridge test Change-Id: Idd7455cc873d2db86c2ccc130bd673b065311e67 * Don't kill ganache-cli if already running Instead error the test * eth: omit mainnet stuff from ci Co-authored-by: Csongor Kiss <ckiss@jumptrading.com> Co-authored-by: Jeff Schroeder <jeffschroeder@computer.org> Co-authored-by: Drew Sterioti <asterioti@jumptrading.com> Co-authored-by: Evan Gray <battledingo@gmail.com>
This commit is contained in:
parent
b7ec3ac0d3
commit
745d3db68d
|
@ -45,6 +45,15 @@ jobs:
|
||||||
go-version: '1.17.5'
|
go-version: '1.17.5'
|
||||||
- run: make node
|
- run: make node
|
||||||
|
|
||||||
|
ethereum:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '16'
|
||||||
|
- run: cd ethereum && make test
|
||||||
|
|
||||||
# Run linters, Go tests and other outside-of-Tilt things.
|
# Run linters, Go tests and other outside-of-Tilt things.
|
||||||
lint-and-tests:
|
lint-and-tests:
|
||||||
# The linter is slow enough that we want to run it on the self-hosted runner
|
# The linter is slow enough that we want to run it on the self-hosted runner
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
ganache.log
|
|
@ -10,6 +10,9 @@ RUN mkdir -p /home/node/app
|
||||||
RUN mkdir -p /home/node/.npm
|
RUN mkdir -p /home/node/.npm
|
||||||
WORKDIR /home/node/app
|
WORKDIR /home/node/app
|
||||||
|
|
||||||
|
# Fix git ssh error
|
||||||
|
RUN git config --global url."https://".insteadOf ssh://
|
||||||
|
|
||||||
# Support additional root CAs
|
# Support additional root CAs
|
||||||
COPY README.md cert.pem* /certs/
|
COPY README.md cert.pem* /certs/
|
||||||
# Node
|
# Node
|
||||||
|
@ -18,7 +21,7 @@ ENV NODE_OPTIONS=--use-openssl-ca
|
||||||
# npm
|
# npm
|
||||||
RUN if [ -e /certs/cert.pem ]; then npm config set cafile /certs/cert.pem; fi
|
RUN if [ -e /certs/cert.pem ]; then npm config set cafile /certs/cert.pem; fi
|
||||||
# git
|
# git
|
||||||
RUN if [ -e /certs/cert.pem ]; then git config --global http.sslCAPath /certs; fi
|
RUN if [ -e /certs/cert.pem ]; then git config --global http.sslCAInfo /certs/cert.pem; fi
|
||||||
|
|
||||||
# Only invalidate the npm install step if package.json changed
|
# Only invalidate the npm install step if package.json changed
|
||||||
ADD --chown=node:node package.json .
|
ADD --chown=node:node package.json .
|
||||||
|
@ -28,7 +31,7 @@ ADD --chown=node:node .env.test .env
|
||||||
# We want to cache node_modules *and* incorporate it into the final image.
|
# We want to cache node_modules *and* incorporate it into the final image.
|
||||||
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
|
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
|
||||||
--mount=type=cache,uid=1000,gid=1000,target=node_modules \
|
--mount=type=cache,uid=1000,gid=1000,target=node_modules \
|
||||||
npm install && \
|
npm ci && \
|
||||||
cp -r node_modules node_modules_cache
|
cp -r node_modules node_modules_cache
|
||||||
|
|
||||||
# Amusingly, Debian's coreutils version has a bug where mv believes that
|
# Amusingly, Debian's coreutils version has a bug where mv believes that
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
SOURCE_FILES:=$(shell find contracts -name "*.sol")
|
||||||
|
|
||||||
|
.PHONY: dependencies test clean all
|
||||||
|
|
||||||
|
all: build
|
||||||
|
|
||||||
|
node_modules: package-lock.json
|
||||||
|
touch -m node_modules
|
||||||
|
npm ci
|
||||||
|
|
||||||
|
dependencies: node_modules
|
||||||
|
|
||||||
|
build: node_modules ${SOURCE_FILES}
|
||||||
|
mkdir -p build
|
||||||
|
touch -m build
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
.env: .env.test
|
||||||
|
cp $< $@
|
||||||
|
|
||||||
|
test: build .env dependencies
|
||||||
|
@if pgrep ganache-cli; then echo "Error: ganache-cli already running. Stop it before running tests"; exit 1; fi
|
||||||
|
npx ganache-cli -e 10000 --deterministic --time="1970-01-01T00:00:00+00:00" > ganache.log &
|
||||||
|
sleep 5
|
||||||
|
npm test || (pkill ganache-cli && exit 1)
|
||||||
|
pkill ganache-cli || true
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf ganache.log .env node_modules build
|
|
@ -7,6 +7,7 @@
|
||||||
// e.g. Polygon
|
// e.g. Polygon
|
||||||
// MNEMONIC="" npm run deploy-bridge-implementation-only -- --network polygon
|
// MNEMONIC="" npm run deploy-bridge-implementation-only -- --network polygon
|
||||||
const BridgeImplementation = artifacts.require("BridgeImplementation");
|
const BridgeImplementation = artifacts.require("BridgeImplementation");
|
||||||
module.exports = async function(deployer) {
|
module.exports = async function(deployer, network) {
|
||||||
|
if (network === "test") return;
|
||||||
await deployer.deploy(BridgeImplementation);
|
await deployer.deploy(BridgeImplementation);
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "truffle compile",
|
"build": "truffle compile",
|
||||||
"test": "mkdir -p build/contracts && cp node_modules/@openzeppelin/contracts/build/contracts/* build/contracts/ && truffle test",
|
"test": "mkdir -p build/contracts && cp node_modules/@openzeppelin/contracts/build/contracts/* build/contracts/ && truffle test --network test",
|
||||||
"migrate": "mkdir -p build/contracts && cp node_modules/@openzeppelin/contracts/build/contracts/* build/contracts/ && truffle migrate --to 4",
|
"migrate": "mkdir -p build/contracts && cp node_modules/@openzeppelin/contracts/build/contracts/* build/contracts/ && truffle migrate --to 4",
|
||||||
"flatten": "mkdir -p node_modules/@poanet/solidity-flattener/contracts && cp -r contracts/* node_modules/@poanet/solidity-flattener/contracts/ && poa-solidity-flattener",
|
"flatten": "mkdir -p node_modules/@poanet/solidity-flattener/contracts && cp -r contracts/* node_modules/@poanet/solidity-flattener/contracts/ && poa-solidity-flattener",
|
||||||
"deploy-bridge-implementation-only": "mkdir -p build/contracts && cp node_modules/@openzeppelin/contracts/build/contracts/* build/contracts/ && truffle migrate --f 6 --to 6",
|
"deploy-bridge-implementation-only": "mkdir -p build/contracts && cp node_modules/@openzeppelin/contracts/build/contracts/* build/contracts/ && truffle migrate --f 6 --to 6",
|
||||||
|
|
|
@ -23,7 +23,7 @@ contract("Bridge", function () {
|
||||||
const testChainId = "2";
|
const testChainId = "2";
|
||||||
const testGovernanceChainId = "1";
|
const testGovernanceChainId = "1";
|
||||||
const testGovernanceContract = "0x0000000000000000000000000000000000000000000000000000000000000004";
|
const testGovernanceContract = "0x0000000000000000000000000000000000000000000000000000000000000004";
|
||||||
let WETH = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
|
let WETH = process.env.BRIDGE_INIT_WETH;;
|
||||||
const testForeignChainId = "1";
|
const testForeignChainId = "1";
|
||||||
const testForeignBridgeContract = "0x000000000000000000000000000000000000000000000000000000000000ffff";
|
const testForeignBridgeContract = "0x000000000000000000000000000000000000000000000000000000000000ffff";
|
||||||
const testBridgedAssetChain = "0001";
|
const testBridgedAssetChain = "0001";
|
||||||
|
|
|
@ -18,6 +18,7 @@ const BridgeImplementationFullABI = jsonfile.readFileSync("build/contracts/Bridg
|
||||||
// needs to run on a mainnet fork
|
// needs to run on a mainnet fork
|
||||||
|
|
||||||
contract("Update Bridge", function (accounts) {
|
contract("Update Bridge", function (accounts) {
|
||||||
|
if (config.network === "test") return;
|
||||||
const testChainId = "2";
|
const testChainId = "2";
|
||||||
const testGovernanceChainId = "1";
|
const testGovernanceChainId = "1";
|
||||||
const testGovernanceContract = "0x0000000000000000000000000000000000000000000000000000000000000004";
|
const testGovernanceContract = "0x0000000000000000000000000000000000000000000000000000000000000004";
|
||||||
|
|
|
@ -8,6 +8,12 @@ module.exports = {
|
||||||
port: 8545,
|
port: 8545,
|
||||||
network_id: "*",
|
network_id: "*",
|
||||||
},
|
},
|
||||||
|
// test network is the same as development but allows us to omit certain migrations
|
||||||
|
test: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 8545,
|
||||||
|
network_id: "*",
|
||||||
|
},
|
||||||
mainnet: {
|
mainnet: {
|
||||||
provider: () =>
|
provider: () =>
|
||||||
new HDWalletProvider(
|
new HDWalletProvider(
|
||||||
|
@ -56,10 +62,11 @@ module.exports = {
|
||||||
gasPrice: 8000000000,
|
gasPrice: 8000000000,
|
||||||
},
|
},
|
||||||
binance_testnet: {
|
binance_testnet: {
|
||||||
provider: () => new HDWalletProvider(
|
provider: () =>
|
||||||
process.env.MNEMONIC,
|
new HDWalletProvider(
|
||||||
"https://data-seed-prebsc-1-s1.binance.org:8545/"
|
process.env.MNEMONIC,
|
||||||
),
|
"https://data-seed-prebsc-1-s1.binance.org:8545/"
|
||||||
|
),
|
||||||
network_id: "97",
|
network_id: "97",
|
||||||
gas: 70000000,
|
gas: 70000000,
|
||||||
gasPrice: 8000000000,
|
gasPrice: 8000000000,
|
||||||
|
@ -79,7 +86,8 @@ module.exports = {
|
||||||
provider: () => {
|
provider: () => {
|
||||||
return new HDWalletProvider(
|
return new HDWalletProvider(
|
||||||
process.env.MNEMONIC,
|
process.env.MNEMONIC,
|
||||||
"https://polygon-mumbai.infura.io/v3/" + process.env.INFURA_KEY)
|
"https://polygon-mumbai.infura.io/v3/" + process.env.INFURA_KEY
|
||||||
|
);
|
||||||
},
|
},
|
||||||
network_id: "80001",
|
network_id: "80001",
|
||||||
},
|
},
|
||||||
|
@ -95,10 +103,11 @@ module.exports = {
|
||||||
gasPrice: 26000000000,
|
gasPrice: 26000000000,
|
||||||
},
|
},
|
||||||
fuji: {
|
fuji: {
|
||||||
provider: () => new HDWalletProvider(
|
provider: () =>
|
||||||
process.env.MNEMONIC,
|
new HDWalletProvider(
|
||||||
"https://api.avax-test.network/ext/bc/C/rpc"
|
process.env.MNEMONIC,
|
||||||
),
|
"https://api.avax-test.network/ext/bc/C/rpc"
|
||||||
|
),
|
||||||
network_id: "43113",
|
network_id: "43113",
|
||||||
},
|
},
|
||||||
oasis: {
|
oasis: {
|
||||||
|
@ -126,7 +135,7 @@ module.exports = {
|
||||||
return new HDWalletProvider(
|
return new HDWalletProvider(
|
||||||
process.env.MNEMONIC,
|
process.env.MNEMONIC,
|
||||||
"https://testnet.aurora.dev"
|
"https://testnet.aurora.dev"
|
||||||
)
|
);
|
||||||
},
|
},
|
||||||
network_id: 0x4e454153,
|
network_id: 0x4e454153,
|
||||||
gas: 10000000,
|
gas: 10000000,
|
||||||
|
@ -137,7 +146,7 @@ module.exports = {
|
||||||
return new HDWalletProvider(
|
return new HDWalletProvider(
|
||||||
process.env.MNEMONIC,
|
process.env.MNEMONIC,
|
||||||
"https://rpc.ftm.tools/"
|
"https://rpc.ftm.tools/"
|
||||||
)
|
);
|
||||||
},
|
},
|
||||||
network_id: 250,
|
network_id: 250,
|
||||||
gas: 8000000,
|
gas: 8000000,
|
||||||
|
@ -149,7 +158,7 @@ module.exports = {
|
||||||
return new HDWalletProvider(
|
return new HDWalletProvider(
|
||||||
process.env.MNEMONIC,
|
process.env.MNEMONIC,
|
||||||
"https://rpc.testnet.fantom.network/"
|
"https://rpc.testnet.fantom.network/"
|
||||||
)
|
);
|
||||||
},
|
},
|
||||||
network_id: 0xfa2,
|
network_id: 0xfa2,
|
||||||
gas: 4465030,
|
gas: 4465030,
|
||||||
|
|
Loading…
Reference in New Issue