diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 36a55cc3..ff9b326f 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -1,24 +1,56 @@ name: Integration Tests on: + workflow_dispatch: + inputs: + scriptName: + type: choice + description: "Script to run" + options: + - omnichain_swap + - omnichain_staking + - omnichain_multioutput + - messaging_counter + - messaging_message + - messaging_value + - messaging_warriors schedule: - cron: "0 0 * * *" # Runs every day at midnight - workflow_dispatch: jobs: - integration: + scheduled_integration_tests: + if: github.event_name == 'schedule' runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v2 - name: Install jq + run: sudo apt-get update && sudo apt-get install -y jq + + - name: Run All Scripts in scripts/test Directory run: | - sudo apt-get update - sudo apt-get install -y jq + for script in scripts/test/*; do + if [ -f "$script" ] && [ -x "$script" ]; then + echo "Running $script..." + ./$script + fi + done + env: + PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} + + manual_integration_tests: + if: github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 - - name: Integration - run: ./scripts/integration.sh + - name: Install jq + run: sudo apt-get update && sudo apt-get install -y jq + + - name: Run Script + run: | + sh ${{ github.workspace }}/scripts/test/${{ github.event.inputs.scriptName }}.sh env: PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} diff --git a/scripts/common.sh b/scripts/common.sh new file mode 100644 index 00000000..1bd2ae8c --- /dev/null +++ b/scripts/common.sh @@ -0,0 +1,2 @@ +#!/bin/bash +SENDER=0x2cD3D070aE1BD365909dD859d29F387AA96911e1 \ No newline at end of file diff --git a/scripts/integration.sh b/scripts/integration.sh deleted file mode 100755 index 975d0e0f..00000000 --- a/scripts/integration.sh +++ /dev/null @@ -1,160 +0,0 @@ -#!/bin/bash - -set -e - -SENDER=0x2cD3D070aE1BD365909dD859d29F387AA96911e1 - -pushd "./omnichain/swap" - -yarn - -npx hardhat compile --force - -echo "Testing omnichain Swap" - -OMNI_SWAP_CONTRACT=$(npx hardhat deploy --network zeta_testnet --json | jq -r '.address') -# echo "omnichain.swap.zeta_testnet=$OMNI_SWAP_CONTRACT" >> contracts.toml -OMNI_SWAP_TX=$(npx hardhat interact --contract $OMNI_SWAP_CONTRACT --network goerli_testnet --amount 0.01 --recipient $SENDER --destination mumbai_testnet --json | jq -r '.hash') -echo $OMNI_SWAP_TX -OMNI_SWAP_CCTX=$(npx hardhat cctx $OMNI_SWAP_TX --json) -echo $OMNI_SWAP_CCTX - -popd - -pushd "./omnichain/staking" - -yarn - -npx hardhat compile --force - -echo "Testing omnichain Staking" - -OMNI_STAKING_CONTRACT=$(npx hardhat deploy --network zeta_testnet --chain goerli_testnet --json | jq -r '.address') - -echo $OMNI_STAKING_CONTRACT - -echo "Setting beneficiary" -OMNI_STAKING_BENEFICIARY_TX=$(npx hardhat set-beneficiary $SENDER --contract $OMNI_STAKING_CONTRACT --network goerli_testnet --json | jq -r '.hash') -echo $OMNI_STAKING_BENEFICIARY_TX -OMNI_STAKING_BENEFICIARY_CCTX=$(npx hardhat cctx $OMNI_STAKING_BENEFICIARY_TX --json) -echo $OMNI_STAKING_BENEFICIARY_CCTX - -echo "Setting withdraw" -OMNI_STAKING_WITHDRAW_TX=$(npx hardhat set-withdraw --contract $OMNI_STAKING_CONTRACT --network goerli_testnet --json | jq -r '.hash') -echo $OMNI_STAKING_WITHDRAW_TX -OMNI_STAKING_WITHDRAW_CCTX=$(npx hardhat cctx $OMNI_STAKING_WITHDRAW_TX --json) -echo $OMNI_STAKING_WITHDRAW_CCTX - -echo "Stake" -OMNI_STAKING_STAKE_TX=$(npx hardhat stake --amount 0.01 --contract $OMNI_STAKING_CONTRACT --network goerli_testnet --json | jq -r '.hash') -echo $OMNI_STAKING_STAKE_TX -OMNI_STAKING_STAKE_CCTX=$(npx hardhat cctx $OMNI_STAKING_STAKE_TX --json) -echo $OMNI_STAKING_STAKE_CCTX - -echo "Unstake" -OMNI_STAKING_UNSTAKE_TX=$(npx hardhat unstake --contract $OMNI_STAKING_CONTRACT --network goerli_testnet --json | jq -r '.hash') -echo $OMNI_STAKING_UNSTAKE_TX -OMNI_STAKING_UNSTAKE_CCTX=$(npx hardhat cctx $OMNI_STAKING_UNSTAKE_TX --json) -echo $OMNI_STAKING_UNSTAKE_CCTX - -popd - -pushd "./messaging/message" - -yarn - -npx hardhat compile --force - -echo "Testing CCM Message" - -CCM_MESSAGE_CONTRACT=$(npx hardhat deploy --networks goerli_testnet,mumbai_testnet --json) -CCM_MESSAGE_TX_OUT=$(npx hardhat interact --network goerli_testnet --contract $(echo $CCM_MESSAGE_CONTRACT | jq -r '.goerli_testnet') --message "Hello World" --destination mumbai_testnet --amount 0.01 --json ) -echo $CCM_MESSAGE_TX_OUT -CCM_MESSAGE_TX=$(echo $CCM_MESSAGE_TX_OUT | jq -r '.hash') -echo $CCM_MESSAGE_TX -CCM_MESSAGE_CCTX=$(npx hardhat cctx $CCM_MESSAGE_TX --json) -echo $CCM_MESSAGE_CCTX - -popd - -pushd "./messaging/warriors" - -yarn - -npx hardhat compile --force - -echo "Testing CCM Warriors" - -CCM_NFT_CONTRACT=$(npx hardhat deploy --networks goerli_testnet,mumbai_testnet --json | jq -r '.goerli_testnet') -echo $CCM_NFT_CONTRACT - -CCM_NFT_MINT=$(npx hardhat mint --network goerli_testnet --contract $CCM_NFT_CONTRACT --json) -CCM_NFT_TX_OUT=$(npx hardhat interact --network goerli_testnet --contract $CCM_NFT_CONTRACT --token $CCM_NFT_MINT --destination mumbai_testnet --amount 0.01 --to $SENDER --json) -echo $CCM_NFT_TX_OUT -CCM_NFT_TX=$(echo $CCM_NFT_TX_OUT | jq -r '.hash') -echo $CCM_NFT_TX -CCM_NFT_CCTX=$(npx hardhat cctx $CCM_NFT_TX --json) -echo $CCM_NFT_CCTX - -popd - -pushd "./messaging/counter" - -yarn - -npx hardhat compile --force - -echo "Testing CCM Counter" - -CCM_COUNTER_CONTRACT=$(npx hardhat deploy --networks goerli_testnet,mumbai_testnet --json | jq -r '.goerli_testnet') -echo $CCM_COUNTER_CONTRACT -CCM_COUNTER_TX_OUT=$(npx hardhat interact --network goerli_testnet --contract $CCM_COUNTER_CONTRACT --destination mumbai_testnet --amount 0.01 --json) -echo $CCM_COUNTER_TX_OUT -CCM_COUNTER_TX=$(echo $CCM_COUNTER_TX_OUT | jq -r '.hash') -echo $CCM_COUNTER_TX -CCM_COUNTER_CCTX=$(npx hardhat cctx $CCM_COUNTER_TX --json) -echo $CCM_COUNTER_CCTX - -popd - -pushd "./messaging/value" - -yarn - -npx hardhat compile --force - -echo "Testing CCM Value" - -CCM_VALUE_CONTRACT=$(npx hardhat deploy --networks goerli_testnet,mumbai_testnet --json | jq -r '.goerli_testnet') -echo $CCM_VALUE_CONTRACT -PROTOCOL_FEE=$(npx hardhat fees --json | jq -r ".feesCCM.mumbai_testnet.protocolFee") -GAS_FEE=$(npx hardhat fees --json | jq -r ".feesCCM.mumbai_testnet.gasFee") -# Multiply to be on the safe side -CCM_FEE=$(echo "$PROTOCOL_FEE + $GAS_FEE * 3" | bc -l) -CCM_VALUE_TX_OUT=$(npx hardhat interact --network goerli_testnet --contract $CCM_VALUE_CONTRACT --destination mumbai_testnet --amount $CCM_FEE --json) -echo $CCM_VALUE_TX_OUT -CCM_VALUE_TX=$(echo $CCM_VALUE_TX_OUT | jq -r '.hash') -echo $CCM_VALUE_TX -CCM_VALUE_CCTX=$(npx hardhat cctx $CCM_VALUE_TX --json) -echo $CCM_VALUE_CCTX - -popd - -pushd "./omnichain/multioutput" - -yarn - -npx hardhat compile --force - -echo "Testing omnichain Multioutput" - -OMNI_MULTIOUTPUT_CONTRACT=$(npx hardhat deploy --network zeta_testnet --json | jq -r '.address') -echo $OMNI_MULTIOUTPUT_CONTRACT - -npx hardhat destination --contract $OMNI_MULTIOUTPUT_CONTRACT --network zeta_testnet --destination mumbai_testnet -OMNI_MULTIOUTPUT_TX=$(npx hardhat interact --contract $OMNI_MULTIOUTPUT_CONTRACT --network goerli_testnet --amount 0.01 --recipient $SENDER --json | jq -r '.hash') -echo $OMNI_MULTIOUTPUT_TX -OMNI_MULTIOUTPUT_CCTX=$(npx hardhat cctx $OMNI_MULTIOUTPUT_TX --json) -echo $OMNI_MULTIOUTPUT_CCTX - -popd \ No newline at end of file diff --git a/scripts/test/messaging_counter.sh b/scripts/test/messaging_counter.sh new file mode 100644 index 00000000..4f3ca8e3 --- /dev/null +++ b/scripts/test/messaging_counter.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +source "$(dirname "$0")/../common.sh" + +pushd "./messaging/counter" + +yarn + +npx hardhat compile --force + +echo "Testing CCM Counter" + +CCM_COUNTER_CONTRACT=$(npx hardhat deploy --networks goerli_testnet,mumbai_testnet --json | jq -r '.goerli_testnet') +echo $CCM_COUNTER_CONTRACT +CCM_COUNTER_TX_OUT=$(npx hardhat interact --network goerli_testnet --contract $CCM_COUNTER_CONTRACT --destination mumbai_testnet --amount 0.01 --json) +echo $CCM_COUNTER_TX_OUT +CCM_COUNTER_TX=$(echo $CCM_COUNTER_TX_OUT | jq -r '.hash') +echo $CCM_COUNTER_TX +CCM_COUNTER_CCTX=$(npx hardhat cctx $CCM_COUNTER_TX --json) +echo $CCM_COUNTER_CCTX + +popd \ No newline at end of file diff --git a/scripts/test/messaging_message.sh b/scripts/test/messaging_message.sh new file mode 100644 index 00000000..c595b339 --- /dev/null +++ b/scripts/test/messaging_message.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +source "$(dirname "$0")/../common.sh" + +pushd "./messaging/message" + +yarn + +npx hardhat compile --force + +echo "Testing CCM Message" + +CCM_MESSAGE_CONTRACT=$(npx hardhat deploy --networks goerli_testnet,mumbai_testnet --json) +CCM_MESSAGE_TX_OUT=$(npx hardhat interact --network goerli_testnet --contract $(echo $CCM_MESSAGE_CONTRACT | jq -r '.goerli_testnet') --message "Hello World" --destination mumbai_testnet --amount 0.01 --json ) +echo $CCM_MESSAGE_TX_OUT +CCM_MESSAGE_TX=$(echo $CCM_MESSAGE_TX_OUT | jq -r '.hash') +echo $CCM_MESSAGE_TX +CCM_MESSAGE_CCTX=$(npx hardhat cctx $CCM_MESSAGE_TX --json) +echo $CCM_MESSAGE_CCTX + +popd \ No newline at end of file diff --git a/scripts/test/messaging_value.sh b/scripts/test/messaging_value.sh new file mode 100644 index 00000000..dadd40bb --- /dev/null +++ b/scripts/test/messaging_value.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -e + +source "$(dirname "$0")/../common.sh" + +pushd "./messaging/value" + +yarn + +npx hardhat compile --force + +echo "Testing CCM Value" + +CCM_VALUE_CONTRACT=$(npx hardhat deploy --networks goerli_testnet,mumbai_testnet --json | jq -r '.goerli_testnet') +echo $CCM_VALUE_CONTRACT +PROTOCOL_FEE=$(npx hardhat fees --json | jq -r ".feesCCM.mumbai_testnet.protocolFee") +GAS_FEE=$(npx hardhat fees --json | jq -r ".feesCCM.mumbai_testnet.gasFee") +# Multiply to be on the safe side +CCM_FEE=$(echo "$PROTOCOL_FEE + $GAS_FEE * 3" | bc -l) +CCM_VALUE_TX_OUT=$(npx hardhat interact --network goerli_testnet --contract $CCM_VALUE_CONTRACT --destination mumbai_testnet --amount $CCM_FEE --json) +echo $CCM_VALUE_TX_OUT +CCM_VALUE_TX=$(echo $CCM_VALUE_TX_OUT | jq -r '.hash') +echo $CCM_VALUE_TX +CCM_VALUE_CCTX=$(npx hardhat cctx $CCM_VALUE_TX --json) +echo $CCM_VALUE_CCTX + +popd \ No newline at end of file diff --git a/scripts/test/messaging_warriors.sh b/scripts/test/messaging_warriors.sh new file mode 100755 index 00000000..ff30fb5d --- /dev/null +++ b/scripts/test/messaging_warriors.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -e + +source "$(dirname "$0")/../common.sh" + +pushd "./messaging/warriors" + +yarn + +npx hardhat compile --force + +echo "Testing CCM Warriors" + +CCM_NFT_CONTRACT=$(npx hardhat deploy --networks goerli_testnet,mumbai_testnet --json | jq -r '.goerli_testnet') +echo $CCM_NFT_CONTRACT + +CCM_NFT_MINT=$(npx hardhat mint --network goerli_testnet --contract $CCM_NFT_CONTRACT --json) +CCM_NFT_TX_OUT=$(npx hardhat interact --network goerli_testnet --contract $CCM_NFT_CONTRACT --token $CCM_NFT_MINT --destination mumbai_testnet --amount 0.01 --to $SENDER --json) +echo $CCM_NFT_TX_OUT +CCM_NFT_TX=$(echo $CCM_NFT_TX_OUT | jq -r '.hash') +echo $CCM_NFT_TX +CCM_NFT_CCTX=$(npx hardhat cctx $CCM_NFT_TX --json) +echo $CCM_NFT_CCTX + +popd \ No newline at end of file diff --git a/scripts/test/omnichain_mutlioutput.sh b/scripts/test/omnichain_mutlioutput.sh new file mode 100755 index 00000000..75586b9a --- /dev/null +++ b/scripts/test/omnichain_mutlioutput.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +source "$(dirname "$0")/../common.sh" + +pushd "./omnichain/multioutput" + +yarn + +npx hardhat compile --force + +echo "Testing omnichain Multioutput" + +OMNI_MULTIOUTPUT_CONTRACT=$(npx hardhat deploy --network zeta_testnet --json | jq -r '.address') +echo $OMNI_MULTIOUTPUT_CONTRACT + +npx hardhat destination --contract $OMNI_MULTIOUTPUT_CONTRACT --network zeta_testnet --destination mumbai_testnet +OMNI_MULTIOUTPUT_TX=$(npx hardhat interact --contract $OMNI_MULTIOUTPUT_CONTRACT --network goerli_testnet --amount 0.01 --recipient $SENDER --json | jq -r '.hash') +echo $OMNI_MULTIOUTPUT_TX +OMNI_MULTIOUTPUT_CCTX=$(npx hardhat cctx $OMNI_MULTIOUTPUT_TX --json) +echo $OMNI_MULTIOUTPUT_CCTX + +popd \ No newline at end of file diff --git a/scripts/test/omnichain_staking.sh b/scripts/test/omnichain_staking.sh new file mode 100755 index 00000000..825201df --- /dev/null +++ b/scripts/test/omnichain_staking.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -e + +source "$(dirname "$0")/../common.sh" + +pushd "./omnichain/staking" + +yarn + +npx hardhat compile --force + +echo "Testing omnichain Staking" + +OMNI_STAKING_CONTRACT=$(npx hardhat deploy --network zeta_testnet --chain goerli_testnet --json | jq -r '.address') + +echo $OMNI_STAKING_CONTRACT + +echo "Setting beneficiary" +OMNI_STAKING_BENEFICIARY_TX=$(npx hardhat set-beneficiary $SENDER --contract $OMNI_STAKING_CONTRACT --network goerli_testnet --json | jq -r '.hash') +echo $OMNI_STAKING_BENEFICIARY_TX +OMNI_STAKING_BENEFICIARY_CCTX=$(npx hardhat cctx $OMNI_STAKING_BENEFICIARY_TX --json) +echo $OMNI_STAKING_BENEFICIARY_CCTX + +echo "Setting withdraw" +OMNI_STAKING_WITHDRAW_TX=$(npx hardhat set-withdraw --contract $OMNI_STAKING_CONTRACT --network goerli_testnet --json | jq -r '.hash') +echo $OMNI_STAKING_WITHDRAW_TX +OMNI_STAKING_WITHDRAW_CCTX=$(npx hardhat cctx $OMNI_STAKING_WITHDRAW_TX --json) +echo $OMNI_STAKING_WITHDRAW_CCTX + +echo "Stake" +OMNI_STAKING_STAKE_TX=$(npx hardhat stake --amount 0.01 --contract $OMNI_STAKING_CONTRACT --network goerli_testnet --json | jq -r '.hash') +echo $OMNI_STAKING_STAKE_TX +OMNI_STAKING_STAKE_CCTX=$(npx hardhat cctx $OMNI_STAKING_STAKE_TX --json) +echo $OMNI_STAKING_STAKE_CCTX + +echo "Unstake" +OMNI_STAKING_UNSTAKE_TX=$(npx hardhat unstake --contract $OMNI_STAKING_CONTRACT --network goerli_testnet --json | jq -r '.hash') +echo $OMNI_STAKING_UNSTAKE_TX +OMNI_STAKING_UNSTAKE_CCTX=$(npx hardhat cctx $OMNI_STAKING_UNSTAKE_TX --json) +echo $OMNI_STAKING_UNSTAKE_CCTX + +popd \ No newline at end of file diff --git a/scripts/test/omnichain_swap.sh b/scripts/test/omnichain_swap.sh new file mode 100755 index 00000000..c849d37c --- /dev/null +++ b/scripts/test/omnichain_swap.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +source ./scripts/common.sh + +cd ./omnichain/swap + +yarn + +npx hardhat compile --force + +echo "Testing omnichain Swap" + +OMNI_SWAP_CONTRACT=$(npx hardhat deploy --network zeta_testnet --json | jq -r '.address') +# echo "omnichain.swap.zeta_testnet=$OMNI_SWAP_CONTRACT" >> contracts.toml +OMNI_SWAP_TX=$(npx hardhat interact --contract $OMNI_SWAP_CONTRACT --network goerli_testnet --amount 0.01 --recipient $SENDER --destination mumbai_testnet --json | jq -r '.hash') +echo $OMNI_SWAP_TX +OMNI_SWAP_CCTX=$(npx hardhat cctx $OMNI_SWAP_TX --json) +echo $OMNI_SWAP_CCTX \ No newline at end of file