Skip to content

Commit

Permalink
CI: Fix failing workflows (#2061)
Browse files Browse the repository at this point in the history
* Fix e2e test CI

* Refactor and clean up test ethlibs workflow

* Naming consistency

* Fix transferdomain rpc in ethlibs-fixtures

* Fix env variable naming

* Fix sudo privileges bug causing solc install to fail

* Shift ethlibs script out of test into ethlibs_test dir

* Rename fixture script to main.sh, shift to ethlibs_test dir

* Fix filepath env variables

* Remove chmod

* Revert to 2 jobs

* Clean up test-ethlibs and fix bug

* Fix fixture script bug

* Add debugging logs

* Add debug log for command not found bug

* Remove debug logs, fix bug in main.sh

* Rename main.sh

* Add bash sanity checks

---------

Co-authored-by: jouzo <[email protected]>
Co-authored-by: Prasanna Loganathar <[email protected]>
  • Loading branch information
3 people authored Jun 14, 2023
1 parent d74331a commit 69c0277
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 93 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/tests-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:

- name: Install dependencies for target
run: ./make.sh ci-setup-deps-target


- name: Install dependencies for test
run: ./make.sh ci-setup-deps-test

- name: Tests
run: ./ci/test/main.sh
33 changes: 15 additions & 18 deletions .github/workflows/tests-ethlibs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,43 @@ jobs:
- name: Setup dependencies for target
run: ./make.sh ci-setup-deps-target

- name: Install dependencies for test
run: ./make.sh ci-setup-deps-test

- name: Build binaries
run: ./make.sh build

- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: defibins
path: |
build/src/defid
build/src/defi-cli
ci/test/ethlibs-fixtures.sh
ci/ethlibs_test/main.sh
node-rpc-tests:
runs-on: ubuntu-latest
needs: build-binaries

steps:
- name: Download binaries
uses: actions/download-artifact@v3
with:
name: defibins

- name: Chores
run: |
chmod uog+x build/src/defid build/src/defi-cli ci/test/ethlibs-fixtures.sh
- name: Run defid node
run: |
./build/src/defid -regtest -daemon -debug=rpc -printtoconsole -rpcallowip=0.0.0.0/0 -rpcbind=0.0.0.0 -masternode_operator=mswsMVsyGMj1FzDMbbxw2QW3KvQAv2FKiy -masternode_owner=mwsZw8nF7pKxWH8eoKL9tPxTpaFkz7QeLU -dummypos=0 -subsidytest=1 -txnotokens=0 -txindex=1 -amkheight=0 -bayfrontheight=1 -clarkequayheight=3 -dakotaheight=4 -dakotacrescentheight=5 -eunosheight=6 -eunospayaheight=7 -fortcanningheight=8 -fortcanningmuseumheight=9 -fortcanninghillheight=10 -fortcanningroadheight=11 -fortcanningcrunchheight=12 -fortcanningspringheight=13 -fortcanninggreatworldheight=14 -fortcanningepilogueheight=15 -grandcentralheight=16 -nextnetworkupgradeheight=17
- name: Push fixtures
run: |
sleep 5
./ci/test/ethlibs-fixtures.sh
- name: Set up Go

- name: Setup permissions
run: chmod uog+x build/src/defid build/src/defi-cli build/src/defid build/src/defi-cli ci/ethlibs_test/main.sh

- name: Setup test fixtures
run: ./ci/ethlibs_test/main.sh

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '^1.17.0'

- name: Set up go eth test suites library
- name: Setup go-ethlibs test suites
uses: actions/checkout@v3
with:
repository: 'DeFiCh/go-ethlibs'
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/tests-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ on:
workflow_dispatch:
inputs:
block_ranges:
description: 'Optionally restrict to specific block ranges. Should be
formatted as multiple start block, such as "350000 50000 750000".
description: 'Optionally restrict to specific block ranges. Should be
formatted as multiple start block, such as "350000 50000 750000".
Defaults to all block ranges'
required: false
name:
Expand Down Expand Up @@ -35,6 +35,9 @@ jobs:
- name: Setup dependencies for target
run: ./make.sh ci-setup-deps-target

- name: Install dependencies for test
run: ./make.sh ci-setup-deps-test

# TODO: Switch this to a docker build later and this builds on the native
# VM toolchain and loses disparity with the CI release builds
- name: Build binaries
Expand Down Expand Up @@ -128,6 +131,9 @@ jobs:
with:
name: sync

- name: Rename Artifact
run: mv main.sh sync.sh

- name: Set Permissions
run: |
chmod 777 defid
Expand Down
129 changes: 129 additions & 0 deletions ci/ethlibs_test/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#!/usr/bin/env bash

export LC_ALL=C

set -Eeuo pipefail

setup_vars() {
# directories and binaries
WORK_DIR=${WORK_DIR:-"$(pwd)"}
BUILD_DIR=${BUILD_DIR:-"${WORK_DIR}/build/src"}
DEFID_BIN=${DEFID_BIN:-"${BUILD_DIR}/defid"}
DEFI_CLI_BIN=${DEFI_CLI_BIN:-"${BUILD_DIR}/defi-cli"}

# fixture
OWNERAUTHADDR="mwsZw8nF7pKxWH8eoKL9tPxTpaFkz7QeLU"
OWNERAUTHPRIV="cRiRQ9cHmy5evDqNDdEV8f6zfbK6epi9Fpz4CRZsmLEmkwy54dWz"
OPERATORAUTHADDR="mswsMVsyGMj1FzDMbbxw2QW3KvQAv2FKiy"
OPERATORAUTHPRIV="cPGEaz8AGiM71NGMRybbCqFNRcuUhg3uGvyY4TFE1BZC26EW2PkC"
ALICE="0x9b8a4af42140d8a4c153a822f02571a1dd037e89"
# BOB="0x6C34CBb9219d8cAa428835D2073E8ec88BA0a110"
PRIVKEY_ALICE="af990cc3ba17e776f7f57fcc59942a82846d75833fa17d2ba59ce6858d886e23"
PRIVKEY_BOB="17b8cb134958b3d8422b6c43b0732fcdb8c713b524df2d45de12f0c7e214ba35"
CONTRACT_COUNTER="0x60c0604052600760808190526621b7bab73a32b960c91b60a090815261002891600091906100ab565b50600060025534801561003a57600080fd5b50600180546001600160a01b031916331790556040517ff15da729ec5b36e9bda8b3f71979cdac5d0f3169f8590778ac0cd82cc5cc1d4a9061009e906020808252600e908201526d2432b63637961021b7bab73a32b960911b604082015260600190565b60405180910390a161017f565b8280546100b790610144565b90600052602060002090601f0160209004810192826100d9576000855561011f565b82601f106100f257805160ff191683800117855561011f565b8280016001018555821561011f579182015b8281111561011f578251825591602001919060010190610104565b5061012b92915061012f565b5090565b5b8082111561012b5760008155600101610130565b60028104600182168061015857607f821691505b6020821081141561017957634e487b7160e01b600052602260045260246000fd5b50919050565b6103e68061018e6000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c80638da5cb5b116100665780638da5cb5b146100f4578063a87d942c1461011f578063c8a4ac9c14610127578063d14e62b81461013a578063ee82ac5e1461014d5761009e565b806306fdde03146100a3578063119fbbd4146100c15780631a93d1c3146100cb578063672d5d3b146100db5780638361ff9c146100e1575b600080fd5b6100ab61015f565b6040516100b891906102d5565b60405180910390f35b6100c96101ed565b005b455b6040519081526020016100b8565b436100cd565b6100cd6100ef36600461029c565b610207565b600154610107906001600160a01b031681565b6040516001600160a01b0390911681526020016100b8565b6002546100cd565b6100cd6101353660046102b4565b61026d565b6100c961014836600461029c565b610280565b6100cd61015b36600461029c565b4090565b6000805461016c9061035f565b80601f01602080910402602001604051908101604052809291908181526020018280546101989061035f565b80156101e55780601f106101ba576101008083540402835291602001916101e5565b820191906000526020600020905b8154815290600101906020018083116101c857829003601f168201915b505050505081565b6001600260008282546102009190610328565b9091555050565b6000600a8211156102695760405162461bcd60e51b815260206004820152602260248201527f56616c7565206d757374206e6f742062652067726561746572207468616e2031604482015261181760f11b606482015260840160405180910390fd5b5090565b60006102798284610340565b9392505050565b6001546001600160a01b0316331461029757600080fd5b600255565b6000602082840312156102ad578081fd5b5035919050565b600080604083850312156102c6578081fd5b50508035926020909101359150565b6000602080835283518082850152825b81811015610301578581018301518582016040015282016102e5565b818111156103125783604083870101525b50601f01601f1916929092016040019392505050565b6000821982111561033b5761033b61039a565b500190565b600081600019048311821515161561035a5761035a61039a565b500290565b60028104600182168061037357607f821691505b6020821081141561039457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220698216ef3f0a0eede3cc4f13017b1d1699d56b3aa4aa8491a3f47fc2d37ac22164736f6c63430008020033"
CONTRACT_COUNTERCALLER="0x608060405234801561001057600080fd5b5060405161025c38038061025c83398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610082565b600060208284031215610065578081fd5b81516001600160a01b038116811461007b578182fd5b9392505050565b6101cb806100916000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806360598c0114610046578063a87d942c14610050578063c3da42b81461006b575b600080fd5b61004e610096565b005b6100586100f1565b6040519081526020015b60405180910390f35b60005461007e906001600160a01b031681565b6040516001600160a01b039091168152602001610062565b6000805460408051630467eef560e21b815290516001600160a01b039092169263119fbbd49260048084019382900301818387803b1580156100d757600080fd5b505af11580156100eb573d6000803e3d6000fd5b50505050565b60008060009054906101000a90046001600160a01b03166001600160a01b031663a87d942c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561014057600080fd5b505afa158015610154573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610178919061017d565b905090565b60006020828403121561018e578081fd5b505191905056fea2646970667358221220220b50dea2907d54fd36279d0583e05fe9868a78b29df0e8d111fabac5ef1d9564736f6c63430008020033"
}

start_node() {
$DEFID_BIN -regtest \
-daemon \
-debug=rpc \
-printtoconsole \
-rpcallowip=0.0.0.0/0 \
-rpcbind=0.0.0.0 \
-masternode_operator="$OPERATORAUTHADDR" \
-masternode_owner="$OWNERAUTHADDR" \
-dummypos=0 \
-subsidytest=1 \
-txnotokens=0 \
-txindex=1 \
-amkheight=0 \
-bayfrontheight=1 \
-clarkequayheight=3 \
-dakotaheight=4 \
-dakotacrescentheight=5 \
-eunosheight=6 \
-eunospayaheight=7 \
-fortcanningheight=8 \
-fortcanningmuseumheight=9 \
-fortcanninghillheight=10 \
-fortcanningroadheight=11 \
-fortcanningcrunchheight=12 \
-fortcanningspringheight=13 \
-fortcanninggreatworldheight=14 \
-fortcanningepilogueheight=15 \
-grandcentralheight=16 \
-nextnetworkupgradeheight=17
}

init_node() {
sleep 10
}

setup_fixtures() {
# foundation members
$DEFI_CLI_BIN -regtest importprivkey "$OWNERAUTHPRIV" owner true
$DEFI_CLI_BIN -regtest importprivkey "$OPERATORAUTHPRIV" operator true

# push fixtures
$DEFI_CLI_BIN -regtest importprivkey "$PRIVKEY_ALICE"
$DEFI_CLI_BIN -regtest importprivkey "$PRIVKEY_BOB"
$DEFI_CLI_BIN -regtest generatetoaddress 100 "$OWNERAUTHADDR"

$DEFI_CLI_BIN -regtest utxostoaccount '{"'"$OWNERAUTHADDR"'":"5000@DFI"}'
$DEFI_CLI_BIN -regtest generatetoaddress 1 "$OWNERAUTHADDR"

$DEFI_CLI_BIN -regtest setgov '{"ATTRIBUTES":{"v0/params/feature/evm":"true"}}'
$DEFI_CLI_BIN -regtest generatetoaddress 1 "$OWNERAUTHADDR"
$DEFI_CLI_BIN -regtest transferdomain '[{"src":{"address":"'"$OWNERAUTHADDR"'", "amount":"2000@DFI", "domain":2}, "dst":{"address":"'"$ALICE"'", "amount":"2000@DFI", "domain":3}}]'
$DEFI_CLI_BIN -regtest generatetoaddress 1 "$OWNERAUTHADDR"

curl http://localhost:19551 \
-H 'content-type:application/json' \
--data-binary \
'{
"jsonrpc":"2.0",
"id":"fixture",
"method":"eth_sendTransaction",
"params":[{
"data":"'"$CONTRACT_COUNTER"'",
"value":"0x00",
"gas":"0x7a120",
"gasPrice": "0x22ecb25c00"
}]
}'

$DEFI_CLI_BIN -regtest generatetoaddress 1 "$OWNERAUTHADDR"
# contract address
# 0x966aaec51a95a737d086d21f015a6991dd5559ae

curl http://localhost:19551 \
-H 'content-type:application/json' \
--data-binary \
'{
"jsonrpc":"2.0",
"id":"fixture",
"method":"eth_sendTransaction",
"params":[{
"data":"'"$CONTRACT_COUNTERCALLER"'",
"value":"0x00",
"gas":"0x7a120",
"gasPrice": "0x22ecb25c00"
}]
}'

$DEFI_CLI_BIN -regtest generatetoaddress 1 "$OWNERAUTHADDR"
# contract address
# 0x007138e9d5bdb3f0b7f3abf2d46ad4f9184ef99d
}

main() {
setup_vars
print_info
start_node
init_node
setup_fixtures
}

main "$@"

69 changes: 0 additions & 69 deletions ci/test/ethlibs-fixtures.sh

This file was deleted.

1 change: 1 addition & 0 deletions contrib/dockerfiles/aarch64-linux-gnu.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ COPY ./make.sh .
ENV PATH=/root/.cargo/bin:$PATH
RUN ./make.sh ci-setup-deps
RUN ./make.sh ci-setup-deps-target
RUN ./make.sh ci-setup-deps-test

COPY . .
RUN ./make.sh build-deps
Expand Down
1 change: 1 addition & 0 deletions contrib/dockerfiles/arm-linux-gnueabihf.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ COPY ./make.sh .
ENV PATH=/root/.cargo/bin:$PATH
RUN ./make.sh ci-setup-deps
RUN ./make.sh ci-setup-deps-target
RUN ./make.sh ci-setup-deps-test

COPY . .
RUN ./make.sh build-deps
Expand Down
1 change: 1 addition & 0 deletions contrib/dockerfiles/noarch.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ COPY ./make.sh .
ENV PATH=/root/.cargo/bin:$PATH
RUN ./make.sh ci-setup-deps
RUN ./make.sh ci-setup-deps-target
RUN ./make.sh ci-setup-deps-test

COPY . .
RUN ./make.sh build-deps
Expand Down
1 change: 1 addition & 0 deletions contrib/dockerfiles/x86_64-pc-linux-gnu.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ COPY ./make.sh .
ENV PATH=/root/.cargo/bin:$PATH
RUN ./make.sh ci-setup-deps
RUN ./make.sh ci-setup-deps-target
RUN ./make.sh ci-setup-deps-test

COPY . .
RUN ./make.sh build-deps
Expand Down
5 changes: 4 additions & 1 deletion make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,6 @@ ci_setup_deps() {
DEBIAN_FRONTEND=noninteractive pkg_install_deps
DEBIAN_FRONTEND=noninteractive pkg_install_llvm
DEBIAN_FRONTEND=noninteractive pkg_install_rust
pkg_install_web3_deps
}

_ci_setup_deps_target() {
Expand Down Expand Up @@ -899,6 +898,10 @@ ci_setup_deps_target() {
pkg_setup_rust
}

ci_setup_deps_test() {
pkg_install_web3_deps
}

get_rust_target() {
local target=${TARGET}
local rust_target
Expand Down
5 changes: 3 additions & 2 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,13 @@
'feature_loan_priceupdate.py',
'feature_loan_vaultstate.py',
'feature_loan.py',
'feature_evm.py',
'feature_evm_rpc.py',
'feature_evm_contracts.py',
'feature_evm_fee.py',
'feature_evm_rollback.py',
'feature_evm_rpc_transaction.py',
'feature_evm_rpc.py',
'feature_evm_smart_contract.py',
'feature_evm.py',
'feature_loan_low_interest.py',
'feature_loan_estimatecollateral.py',
'feature_vault_pct_check_factor.py',
Expand Down

0 comments on commit 69c0277

Please sign in to comment.