-
Notifications
You must be signed in to change notification settings - Fork 1
288 lines (212 loc) · 7.46 KB
/
ci.yml
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
name: CI
on:
push:
workflow_dispatch:
schedule:
- cron: "42 3 * * *"
jobs:
fmt_and_clippy:
name: Fmt and clippy
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Check generation
run: |
cd crates/erc20_rpc_pool/src/rpc_pool
python gen_methods.py
git diff --exit-code
- name: Fmt
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy -- -D warnings
- name: Clippy all
run: cargo clippy --all-targets --all-features --all -- -D warnings
erc20_processor:
name: ERC20 processor build only
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Build erc20 processor
run: cargo build --profile=release-lto
build_tests_and_cache:
name: Build and cache all tests
timeout-minutes: 20
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
profile: [release-fast, release-lto, dev]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "test-cache-${{ matrix.profile }}"
- name: Build tests
run: cargo test --profile=${{ matrix.profile }} --test custom_long --no-run
library_tests:
name: Payment lib unit test run
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "test-cache-release-fast"
save-if: false
- name: Run tests
run: cargo test -p erc20_payment_lib --profile=release-fast
payment_tests:
name: Payment tests (basic + multi)
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "test-cache-release-fast"
save-if: false
- name: Build tests
run: cargo test --test docker_01_basic --test docker_04_multi --profile=release-fast --no-run
- name: Run tests (docker_01_basic)
run: cargo test --test docker_01_basic --profile=release-fast -- --test-threads=10
- name: Run tests (docker_04_multi)
run: cargo test --test docker_04_multi --profile=release-fast -- --test-threads=10
payment_tests_2:
name: Payment tests (errors)
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "test-cache-release-fast"
save-if: false
- name: Build tests
run: cargo test --test docker_02_errors --profile=release-fast --no-run
- name: Run tests (docker_02_errors)
run: cargo test --test docker_02_errors --profile=release-fast -- --test-threads=10
payment_tests_pool:
name: Payment tests (rpc pool)
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "test-cache-release-fast"
save-if: false
- name: Build tests
run: cargo test --test docker_05_rpc_pool --profile=release-fast --no-run
- name: Run tests (docker_05_rpc_pool)
run: cargo test --test docker_05_rpc_pool --profile=release-fast -- --test-threads=10
payment_tests_multi:
name: Payment tests (multi)
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "test-cache-release-fast"
save-if: false
- name: Build tests
run: cargo test --test docker_03_problems --profile=release-fast --no-run
- name: Run tests (docker_03_problems)
run: cargo test --test docker_03_problems --profile=release-fast -- --test-threads=10
test_faucet_holesky:
name: Test Holesky faucet
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "dev-build-cache"
- name: Build
run: cargo build
- name: Run tests (faucet)
run: cargo run -- generate-key -n 1 > .env
- name: Check if balance is 0
run: |
[ $(cargo run -- balance -c holesky | jq -r '.[] | .gasDecimal') == "0" ]
[ $(cargo run -- balance -c holesky | jq -r '.[] | .tokenDecimal') == "0" ]
- name: Get ETH from faucet
run: cargo run -- get-dev-eth -c holesky
- name: Check ETH balance after getting funds from faucet (should be 0.01)
run: |
sleep 60 # give time for the blockchain to propagate info about the transaction
[ $(cargo run -- balance -c holesky | jq -r '.[] | .gasDecimal') == "0.01" ]
- name: Mint tokens
run: |
cargo run -- mint-test-tokens -c holesky
cargo run -- run
- name: Check token balance
run: |
[ $(cargo run -- balance -c holesky | jq -r '.[] | .tokenDecimal') == "1000" ]
- name: Transfer 166.6 GLM tokens
run: |
cargo run -- transfer -c holesky --recipient 0x5b984629E2Cc7570cBa7dD745b83c3dD23Ba6d0f --token glm --amount 166.6
cargo run -- run
- name: Transfer all GLM tokens
run: |
cargo run -- transfer -c holesky --recipient 0x5b984629E2Cc7570cBa7dD745b83c3dD23Ba6d0f --token glm --all
cargo run -- run
- name: Check token balance zero
run: |
[ $(cargo run -- balance -c holesky | jq -r '.[] | .tokenDecimal') == "0" ]
- name: Transfer all left ETH tokens
run: |
cargo run -- transfer -c holesky --recipient 0x5b984629E2Cc7570cBa7dD745b83c3dD23Ba6d0f --token eth --all
cargo run -- run
payment_tests_custom:
name: Payment tests (custom)
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "test-cache-release-fast"
save-if: false
- name: Build tests
run: cargo test --profile=release-fast --no-run
- name: Run test custom (200 transfers)
run: cargo test --profile=release-fast --test custom_long -- --test-threads=1
env:
ERC20_TESTS_USE_DISK_DB: 1
ERC20_TESTS_OVERRIDE_DB_NAME: erc20lib.sqlite
ERC20_LIB_SQLITE_JOURNAL_MODE: wal
ERC20_TEST_RECEIVER_POOL_SIZE: 300
ERC20_TEST_MAX_IN_TX: 15
ERC20_TEST_TRANSFER_COUNT: 200
ERC20_TEST_TRANSFER_INTERVAL: 0.1
- name: Reopen db cleaning wal logs
run: cargo run --profile=release-fast -- --sqlite-db-file erc20lib.sqlite --sqlite-journal delete cleanup
- uses: actions/upload-artifact@v3
with:
name: erc20lib_custom
path: erc20lib.sqlite