Skip to content

Commit b38b802

Browse files
committed
test: add l1 reorg tests
1 parent 14ccd64 commit b38b802

File tree

2 files changed

+85
-16
lines changed

2 files changed

+85
-16
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
3+
# 脚本:发送所有 commitBatch 交易到 Anvil
4+
# 用法: ./send_commit_batch.sh
5+
6+
RPC_URL="http://localhost:8544"
7+
JSON_FILE="test_transactions.json"
8+
9+
# 检查 JSON 文件是否存在
10+
if [ ! -f "$JSON_FILE" ]; then
11+
echo "错误: 找不到文件 $JSON_FILE"
12+
exit 1
13+
fi
14+
15+
# 检查是否安装了 jq 和 cast
16+
if ! command -v jq &> /dev/null; then
17+
echo "错误: 需要安装 jq"
18+
exit 1
19+
fi
20+
21+
if ! command -v cast &> /dev/null; then
22+
echo "错误: 需要安装 cast (foundry)"
23+
exit 1
24+
fi
25+
26+
echo "开始发送 commitBatch 交易..."
27+
echo "RPC URL: $RPC_URL"
28+
echo ""
29+
30+
# 获取所有 commitBatch 的键
31+
keys=$(jq -r '.commitBatch | keys[]' "$JSON_FILE")
32+
33+
# 计数器
34+
count=0
35+
success=0
36+
failed=0
37+
38+
# 遍历所有 commitBatch 交易
39+
for key in $keys; do
40+
count=$((count + 1))
41+
echo "[$count] 发送 commitBatch[$key]..."
42+
43+
# 获取原始交易数据
44+
raw_tx=$(jq -r ".commitBatch[\"$key\"]" "$JSON_FILE")
45+
46+
# 发送交易
47+
if tx_hash=$(cast rpc --rpc-url "$RPC_URL" eth_sendRawTransaction "$raw_tx" 2>&1); then
48+
# 提取交易哈希(去掉可能的引号)
49+
tx_hash=$(echo "$tx_hash" | tr -d '"')
50+
echo " ✓ 成功! 交易哈希: $tx_hash"
51+
success=$((success + 1))
52+
else
53+
echo " ✗ 失败! 错误: $tx_hash"
54+
failed=$((failed + 1))
55+
fi
56+
57+
echo ""
58+
59+
# 可选:添加延迟以避免请求过快
60+
# sleep 0.1
61+
done
62+
63+
echo "================================"
64+
echo "完成!"
65+
echo "总交易数: $count"
66+
echo "成功: $success"
67+
echo "失败: $failed"
68+
echo "================================"
69+
70+

crates/node/tests/testdata/test_transactions.json

Lines changed: 15 additions & 16 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)