Skip to content

Commit

Permalink
revert scripts for cp issue
Browse files Browse the repository at this point in the history
  • Loading branch information
marcello33 committed Feb 18, 2025
1 parent d0c1d9f commit 40e4802
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 3 deletions.
19 changes: 19 additions & 0 deletions .github/integration-tests/fund_ganache_accounts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

host='localhost'

echo "Transferring 1 ETH from ganache account[0] to all others..."

signersFile="matic-cli/devnet/devnet/signer-dump.json"
signersDump=$(jq . $signersFile)
signersLength=$(jq '. | length' $signersFile)

rootChainWeb3="http://${host}:9545"

for ((i = 1; i < signersLength; i++)); do
to_address=$(echo "$signersDump" | jq -r ".[$i].address")
from_address=$(echo "$signersDump" | jq -r ".[0].address")
txReceipt=$(curl $rootChainWeb3 -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"to":"'"$to_address"'","from":"'"$from_address"'","value":"0xDE0B6B3A7640000"}],"id":1}' -H "Content-Type: application/json")
txHash=$(echo "$txReceipt" | jq -r '.result')
echo "Funds transferred from $from_address to $to_address with txHash: $txHash"
done
44 changes: 44 additions & 0 deletions .github/integration-tests/smoke_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
set -e

balanceInit=$(docker exec bor0 bash -c "bor attach /var/lib/bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'")

stateSyncFound="false"
checkpointFound="false"
SECONDS=0
start_time=$SECONDS

while true
do

balance=$(docker exec bor0 bash -c "bor attach /var/lib/bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'")

if ! [[ "$balance" =~ ^[0-9]+$ ]]; then
echo "Something is wrong! Can't find the balance of first account in bor network."
exit 1
fi

if (( balance > balanceInit )); then
if [ "$stateSyncFound" != "true" ]; then
stateSyncTime=$(( SECONDS - start_time ))
stateSyncFound="true"
fi
fi

checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id)

if [ "$checkpointID" != "null" ]; then
if [ "$checkpointFound" != "true" ]; then
checkpointTime=$(( SECONDS - start_time ))
checkpointFound="true"
fi
fi

if [ "$stateSyncFound" == "true" ] && [ "$checkpointFound" == "true" ]; then
break
fi

done
echo "Both state sync and checkpoint went through. All tests have passed!"
echo "Time taken for state sync: $(printf '%02dm:%02ds\n' $((stateSyncTime%3600/60)) $((stateSyncTime%60)))"
echo "Time taken for checkpoint: $(printf '%02dm:%02ds\n' $((checkpointTime%3600/60)) $((checkpointTime%60)))"
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,13 @@ jobs:
- name: Run smoke tests
run: |
cd matic-cli/devnet
timeout 10m bash ../util-scripts/docker/fund_ganache_accounts.sh
timeout 60m bash ../util-scripts/docker/smoke_test.sh
echo "Funding ganache accounts..."
timeout 10m bash bor/integration-tests/fund_ganache_accounts.sh
echo "Deposit 100 matic for each account to bor network"
cd matic-cli/devnet/code/contracts
npm run truffle exec scripts/deposit.js -- --network development $(jq -r .root.tokens.MaticToken contractAddresses.json) 100000000000000000000
cd -
timeout 60m bash bor/integration-tests/smoke_test.sh
- name: Upload logs
if: always()
Expand Down

0 comments on commit 40e4802

Please sign in to comment.