-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbatch-verification.bats
More file actions
executable file
·68 lines (55 loc) · 2.24 KB
/
batch-verification.bats
File metadata and controls
executable file
·68 lines (55 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bats
# bats file_tags=zkevm
setup() {
load "$PROJECT_ROOT/core/helpers/agglayer-cdk-common-setup.bash"
_agglayer_cdk_common_setup # ✅ Standardized setup (wallet, funding, RPC, etc.)
}
# bats test_tags=zkevm-batch
@test "Verify batches" {
# ✅ Ensure Foundry's `cast` is available
if ! command -v cast &> /dev/null; then
echo "❌ ERROR: Foundry $(cast) not installed. Install with: curl -L https://foundry.paradigm.xyz | bash"
exit 1
fi
# ✅ Test Parameters
local VERIFIED_BATCHES_TARGET=0
local TIMEOUT=600 # 10 minutes
local START_TIME
local END_TIME
local CURRENT_TIME
START_TIME=$(date +%s)
END_TIME=$((START_TIME + TIMEOUT))
echo "📡 Using L2_RPC_URL: $L2_RPC_URL"
echo "🔑 Using Private Key: (hidden for security)"
while true; do
# ✅ Get the verified batch count
local VERIFIED_BATCHES
VERIFIED_BATCHES=$(cast rpc --rpc-url "$L2_RPC_URL" zkevm_verifiedBatchNumber | tr -d '"')
# ✅ Check for errors
if [[ -z "$VERIFIED_BATCHES" || "$VERIFIED_BATCHES" == "null" ]]; then
echo "❌ ERROR: Failed to fetch batch number from RPC."
return 1
fi
echo "[$(date '+%Y-%m-%d %H:%M:%S')] 🔢 Verified Batches: $VERIFIED_BATCHES"
# ✅ Send a dummy transaction to advance the network
echo "🚀 Sending dummy transaction to push batch verification forward..."
run cast send \
--legacy \
--rpc-url "$L2_RPC_URL" \
--private-key "$PRIVATE_KEY" \
--gas-limit 100000 \
--create 0x600160015B810190630000000456
assert_success # ✅ Ensure transaction was sent successfully
# ✅ Timeout & Progress Check
CURRENT_TIME=$(date +%s)
if ((CURRENT_TIME > END_TIME)); then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ⏳ ❌ Timeout reached! Exiting..."
return 1 # ✅ Fail test if timeout occurs
fi
if ((VERIFIED_BATCHES > VERIFIED_BATCHES_TARGET)); then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ✅ Success! $VERIFIED_BATCHES batches verified."
return 0 # ✅ Test succeeds
fi
sleep 10 # 🕒 Wait before retrying
done
}