-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathpolycli-loadtests.bats
More file actions
159 lines (135 loc) · 5.76 KB
/
polycli-loadtests.bats
File metadata and controls
159 lines (135 loc) · 5.76 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env bats
# bats file_tags=standard-kurtosis,polycli-loadtests
# We're going to try to tune these tests to so that they're targeting
# 30M gas per second. When testing these cases with kurtosis it's
# likely that some local network issues might come up due to the
# implementation of the docker proxy. In this case, I'm bypassing the
# proxy all together to directly connect to the sequencer's native IP.
setup_file() {
# shellcheck source=core/helpers/common.bash
source "$BATS_TEST_DIRNAME/../../core/helpers/common.bash"
_setup_vars
}
setup() {
legacy_flag=""
run cast rpc zkevm_getForkId --rpc-url "$l2_rpc_url"
if [[ "$status" -eq 0 ]]; then
legacy_flag="--legacy"
echo "legacy mode enabled"
else
echo "Skipping legacy mode: zkevm_getForkId failed, indicating non-CDK-Erigon client." >&2
fi
tmp_output=${TMP_OUTPUT:-"/tmp/loadtest.out"}
# source existing helper functions for ephemeral account setup
# shellcheck disable=SC1091
source "$BATS_TEST_DIRNAME/../lxly/bridge-tests-suite-assets/helpers/bridge-tests-helper.bash"
}
# bats test_tags=loadtest,transaction-eoa
@test "send 85,700 EOA transfers and confirm mined in 60 seconds" {
ephemeral_data=$(_generate_ephemeral_account "polycli-eoa")
ephemeral_private_key=$(echo "$ephemeral_data" | cut -d' ' -f1)
ephemeral_address=$(echo "$ephemeral_data" | cut -d' ' -f2)
echo "ephemeral_address: $ephemeral_address" >&3
# Fund the ephemeral account using imported function
_fund_ephemeral_account "$ephemeral_address" "$l2_rpc_url" "$l2_private_key" "10000000000000000"
sleep 1
start=$(date +%s)
polycli loadtest \
$legacy_flag \
--rpc-url "$l2_rpc_url" \
--concurrency 1 \
--requests 854 \
--private-key "$ephemeral_private_key" \
--verbosity 600 \
--gas-price-multiplier 1.0 \
--rate-limit 5000 &>> "$tmp_output"
end=$(date +%s)
duration=$((end-start))
if [[ $duration -gt 60 ]]; then
echo "The test ended up taking $duration seconds to complete. This is below the expected performance target" >&3
cat $tmp_output >&3
fi
}
# bats test_tags=loadtest,transaction-erc20
@test "send 41,200 ERC20 transfers and confirm mined in 240 seconds" {
ephemeral_data=$(_generate_ephemeral_account "polycli-erc20")
ephemeral_private_key=$(echo "$ephemeral_data" | cut -d' ' -f1)
ephemeral_address=$(echo "$ephemeral_data" | cut -d' ' -f2)
echo "ephemeral_address: $ephemeral_address" >&3
# Fund the ephemeral account using imported function
_fund_ephemeral_account "$ephemeral_address" "$l2_rpc_url" "$l2_private_key" "10000000000000000"
sleep 1
start=$(date +%s)
polycli loadtest \
$legacy_flag \
--rpc-url "$l2_rpc_url" \
--concurrency 100 \
--requests 412 \
--private-key "$ephemeral_private_key" \
--rate-limit 5000 \
--verbosity 600 \
--gas-price-multiplier 1.0 \
--mode erc20 &>> "$tmp_output"
end=$(date +%s)
duration=$((end-start))
if [[ $duration -gt 240 ]]; then
echo "The test ended up taking $duration seconds to complete. This is below the expected performance target" >&3
cat $tmp_output >&3
fi
}
# bats test_tags=loadtest,transaction-erc721
@test "send 20,800 ERC721 mints and confirm mined in 240 seconds" {
ephemeral_data=$(_generate_ephemeral_account "polycli-erc721")
ephemeral_private_key=$(echo "$ephemeral_data" | cut -d' ' -f1)
ephemeral_address=$(echo "$ephemeral_data" | cut -d' ' -f2)
echo "ephemeral_address: $ephemeral_address" >&3
# Fund the ephemeral account using imported function
_fund_ephemeral_account "$ephemeral_address" "$l2_rpc_url" "$l2_private_key" "10000000000000000"
sleep 1
start=$(date +%s)
polycli loadtest \
$legacy_flag \
--rpc-url "$l2_rpc_url" \
--concurrency 100 \
--requests 208 \
--private-key "$ephemeral_private_key" \
--rate-limit 5000 \
--mode erc721 \
--verbosity 600 \
--gas-price-multiplier 1.0 \
--iterations 1 &>> "$tmp_output"
end=$(date +%s)
duration=$((end-start))
if [[ $duration -gt 240 ]]; then
echo "The test ended up taking $duration seconds to complete. This is below the expected performance target" >&3
cat $tmp_output >&3
fi
}
# TODO this one is a little tricky because 1/2 of the time is deploying contracts.. Maybe adding a timeout parameter would be helpful or we should pre deploy the contracts
# bats test_tags=loadtest,transaction-uniswap
@test "send 10,200 Uniswapv3 swaps sent and mined in 300 seconds" {
ephemeral_data=$(_generate_ephemeral_account "polycli-uniswap")
ephemeral_private_key=$(echo "$ephemeral_data" | cut -d' ' -f1)
ephemeral_address=$(echo "$ephemeral_data" | cut -d' ' -f2)
echo "ephemeral_address: $ephemeral_address" >&3
# Fund the ephemeral account using imported function
_fund_ephemeral_account "$ephemeral_address" "$l2_rpc_url" "$l2_private_key" "10000000000000000"
sleep 1
start=$(date +%s)
polycli loadtest \
$legacy_flag \
--rpc-url "$l2_rpc_url" \
--concurrency 100 \
--requests 102 \
--private-key "$ephemeral_private_key" \
--rate-limit 5000 \
--verbosity 600 \
--gas-price-multiplier 1.0 \
--mode uniswapv3 &>> "$tmp_output"
end=$(date +%s)
duration=$((end-start))
if [[ $duration -gt 300 ]]; then
echo "The test ended up taking $duration seconds to complete. This is below the expected performance target" >&3
cat $tmp_output >&3
fi
}