Skip to content

Commit

Permalink
Fix Availability tests (#431)
Browse files Browse the repository at this point in the history
* Fix JSON-RPC URL

* Change Premined Key
  • Loading branch information
bane authored Nov 14, 2024
1 parent 6e0147e commit 7276187
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/availability-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ on:
method_get_status:
value: ${{ jobs.availability_test.outputs.method_get_status }}
secrets:
FAUCET_PRIVATE_KEY:
PREMINED_PRIVATE_KEY:
required: true
ACCOUNT_PRIVATE_KEY:
required: true
Expand All @@ -84,24 +84,31 @@ jobs:
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9
- name: Fix JSON-RPC URL
run: |
if [[ ! ${{ inputs.rpc_url }} =~ ^https?:// ]]; then
echo "rpc_url=http://${{ inputs.rpc_url }}" >> $GITHUB_ENV
else
echo "rpc_url=${{ inputs.rpc_url }}" >> $GITHUB_ENV
fi
- name: Get latest block number
id: latest_block_number
run: |
current_block_number=$(cast to-dec `cast rpc --rpc-url ${{ inputs.rpc_url }} eth_blockNumber | sed 's/"//g'`)
current_block_number=$(cast to-dec `cast rpc --rpc-url $rpc_url eth_blockNumber | sed 's/"//g'`)
sleep 15
latest_block_number=$(cast to-dec `cast rpc --rpc-url ${{ inputs.rpc_url }} eth_blockNumber | sed 's/"//g'`)
latest_block_number=$(cast to-dec `cast rpc --rpc-url $rpc_url eth_blockNumber | sed 's/"//g'`)
if [ $current_block_number != $latest_block_number ]; then
echo "produce_blocks=true" >> $GITHUB_OUTPUT
fi
- name: Fund account
id: fund
run: |
public_address=$(cast wallet address --private-key ${{ secrets.ACCOUNT_PRIVATE_KEY }})
current_balance=$(cast rpc --rpc-url ${{ inputs.rpc_url }} eth_getBalance $public_address latest | sed 's/"//g')
current_balance=$(cast rpc --rpc-url $rpc_url eth_getBalance $public_address latest | sed 's/"//g')
current_balance_converted=$(echo "`cast to-dec $current_balance`/1000000000000000000" | bc -l)
fund=$(cast send --rpc-url ${{ inputs.rpc_url }} --private-key ${{ secrets.FAUCET_PRIVATE_KEY }} --value ${{ inputs.fund_amount }}ether $public_address `[[ ${{ inputs.london }} == false ]] && echo --legacy`)
fund=$(cast send --rpc-url $rpc_url --private-key ${{ secrets.PREMINED_PRIVATE_KEY }} --value ${{ inputs.fund_amount }}ether $public_address `[[ ${{ inputs.london }} == false ]] && echo --legacy`)
if [ $(echo "$fund" | grep -c "transactionHash") -eq 1 ]; then
new_balance=$(cast rpc --rpc-url ${{ inputs.rpc_url }} eth_getBalance $public_address latest | sed 's/"//g')
new_balance=$(cast rpc --rpc-url $rpc_url eth_getBalance $public_address latest | sed 's/"//g')
new_balance_converted=$(echo "`cast to-dec $new_balance`/1000000000000000000" | bc -l)
if [ $current_balance_converted != $new_balance_converted ]; then
echo "status=true" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -134,30 +141,30 @@ jobs:
id: deploy_smart_contract
if: steps.fund.outputs.status
run: |
output=$(forge create SimpleContract --rpc-url ${{ inputs.rpc_url }} --private-key ${{ secrets.ACCOUNT_PRIVATE_KEY }} `[[ ${{ inputs.london }} == false ]] && echo --legacy`)
output=$(forge create SimpleContract --rpc-url $rpc_url --private-key ${{ secrets.ACCOUNT_PRIVATE_KEY }} `[[ ${{ inputs.london }} == false ]] && echo --legacy`)
address=$(echo "$output" | awk -F "Deployed to: | Transaction hash:" '{print $2}')
echo "hash=$(jq -Rn --arg value $address '$value')" >> $GITHUB_OUTPUT
- name: Check if Smart Contract deployed successfully
id: check_deployed_smart_contract
if: steps.fund.outputs.status
run: |
bytecode=$(cast rpc --rpc-url ${{ inputs.rpc_url }} eth_getCode ${{ steps.deploy_smart_contract.outputs.hash }} latest | sed 's/"//g')
bytecode=$(cast rpc --rpc-url $rpc_url eth_getCode ${{ steps.deploy_smart_contract.outputs.hash }} latest | sed 's/"//g')
if [ $bytecode != "0x" ] && [ $bytecode != "" ]; then
echo "status=true" >> $GITHUB_OUTPUT
fi
- name: Call set() method from Smart Contract
id: method_set
if: steps.check_deployed_smart_contract.outputs.status
run: |
output=$(cast send --rpc-url ${{ inputs.rpc_url }} --private-key ${{ secrets.ACCOUNT_PRIVATE_KEY }} ${{ steps.deploy_smart_contract.outputs.hash }} "function set(uint256)" 100 `[[ ${{ inputs.london }} == false ]] && echo --legacy`)
output=$(cast send --rpc-url $rpc_url --private-key ${{ secrets.ACCOUNT_PRIVATE_KEY }} ${{ steps.deploy_smart_contract.outputs.hash }} "function set(uint256)" 100 `[[ ${{ inputs.london }} == false ]] && echo --legacy`)
if [ $(echo "$output" | grep -c "transactionHash") -eq 1 ]; then
echo "status=true" >> $GITHUB_OUTPUT
fi
- name: Call get() method from Smart Contract
id: method_get
if: steps.check_deployed_smart_contract.outputs.status && steps.method_set.outputs.status
run: |
output=$(cast call --rpc-url ${{ inputs.rpc_url }} ${{ steps.deploy_smart_contract.outputs.hash }} "function get()" `[[ ${{ inputs.london }} == false ]] && echo --legacy`)
output=$(cast call --rpc-url $rpc_url ${{ steps.deploy_smart_contract.outputs.hash }} "function get()" `[[ ${{ inputs.london }} == false ]] && echo --legacy`)
if [ $(cast to-dec `echo $output`) -eq 100 ]; then
echo "status=true" >> $GITHUB_OUTPUT
fi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
london: true
notification: false
secrets:
FAUCET_PRIVATE_KEY: ${{ secrets.FAUCET_PRIVATE_KEY }}
PREMINED_PRIVATE_KEY: ${{ secrets.LOADTEST_PRIVATE_KEY }}
ACCOUNT_PRIVATE_KEY: ${{ secrets.ACCOUNT_PRIVATE_KEY }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
sanity_check_tests:
Expand Down

0 comments on commit 7276187

Please sign in to comment.