Skip to content

Commit

Permalink
refactor: do not depend on external testing scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
vcastellm committed Aug 13, 2024
1 parent e4b5bb8 commit 87b7561
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ kurtosis clean --all
kurtosis run --enclave cdk-v1 --args-file $DEST_KURTOSIS_PARAMS_YML --image-download always $KURTOSIS_FOLDER
#[ $? -ne 0 ] && echo "Error running kurtosis" && exit 1
echo "Waiting 10 minutes to get some verified batch...."
$KURTOSIS_FOLDER/.github/actions/monitor-cdk-verified-batches/batch_verification_monitor.sh 0 600
scripts/batch_verification_monitor.sh 0 600
47 changes: 47 additions & 0 deletions test/scripts/batch_verification_monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# This script monitors the verification progress of zkEVM batches.

# Check if the required arguments are provided.
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <verified_batches_target> <timeout>"
exit 1
fi

# The number of batches to be verified.
verified_batches_target="$1"

# The script timeout (in seconds).
timeout="$2"

start_time=$(date +%s)
end_time=$((start_time + timeout))

rpc_url="$(kurtosis port print cdk-v1 cdk-erigon-node-001 http-rpc)"

while true; do
verified_batches="$(cast to-dec "$(cast rpc --rpc-url "$rpc_url" zkevm_verifiedBatchNumber | sed 's/"//g')")"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Verified Batches: $verified_batches"

# The aim is to take up some space in the batch, so that the number of batches actually increases during the test.
cast send \
--legacy \
--rpc-url "$rpc_url" \
--private-key "0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625" \
--gas-limit 100_000 \
--create 0x600160015B810190630000000456 \
>/dev/null 2>&1

current_time=$(date +%s)
if ((current_time > end_time)); then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ❌ Exiting... Timeout reached!"
exit 1
fi

if ((verified_batches > verified_batches_target)); then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ✅ Exiting... $verified_batches batches were verified!"
exit 0
fi

sleep 10
done

0 comments on commit 87b7561

Please sign in to comment.