forked from cashubtc/cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
326 lines (271 loc) · 7.3 KB
/
justfile
File metadata and controls
326 lines (271 loc) · 7.3 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
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
alias b := build
alias c := check
alias t := test
default:
@just --list
# Create a new SQL migration file
new-migration target name:
#!/usr/bin/env bash
if [ "{{target}}" != "mint" ] && [ "{{target}}" != "wallet" ]; then
echo "Error: target must be either 'mint' or 'wallet'"
exit 1
fi
timestamp=$(date +%Y%m%d%H%M%S)
migration_path="./crates/cdk-sqlite/src/{{target}}/migrations/${timestamp}_{{name}}.sql"
# Create the file
mkdir -p "$(dirname "$migration_path")"
touch "$migration_path"
echo "Created new migration: $migration_path"
final-check: typos format clippy test
# run `cargo build` on everything
build *ARGS="--workspace --all-targets":
#!/usr/bin/env bash
set -euo pipefail
if [ ! -f Cargo.toml ]; then
cd {{invocation_directory()}}
fi
cargo build {{ARGS}}
# run `cargo check` on everything
check *ARGS="--workspace --all-targets":
#!/usr/bin/env bash
set -euo pipefail
if [ ! -f Cargo.toml ]; then
cd {{invocation_directory()}}
fi
cargo check {{ARGS}}
# run code formatters
format:
#!/usr/bin/env bash
set -euo pipefail
if [ ! -f Cargo.toml ]; then
cd {{invocation_directory()}}
fi
cargo fmt --all
nixpkgs-fmt $(echo **.nix)
# run doc tests
test: build
#!/usr/bin/env bash
set -euo pipefail
if [ ! -f Cargo.toml ]; then
cd {{invocation_directory()}}
fi
cargo test --lib
# Run pure integration tests
cargo test -p cdk-integration-tests --test mint
# run doc tests
test-pure db="memory": build
#!/usr/bin/env bash
set -euo pipefail
if [ ! -f Cargo.toml ]; then
cd {{invocation_directory()}}
fi
# Run pure integration tests
CDK_TEST_DB_TYPE={{db}} cargo test -p cdk-integration-tests --test integration_tests_pure -- --test-threads 1
test-all db="memory":
#!/usr/bin/env bash
just test {{db}}
./misc/itests.sh "{{db}}"
./misc/fake_itests.sh "{{db}}" external_signatory
./misc/fake_itests.sh "{{db}}"
test-nutshell:
#!/usr/bin/env bash
docker run -d -p 3338:3338 --name nutshell -e MINT_LIGHTNING_BACKEND=FakeWallet -e MINT_LISTEN_HOST=0.0.0.0 -e MINT_LISTEN_PORT=3338 -e MINT_PRIVATE_KEY=TEST_PRIVATE_KEY -e MINT_INPUT_FEE_PPK=100 cashubtc/nutshell:latest poetry run mint
# Wait for the Nutshell service to be ready
echo "Waiting for Nutshell to start..."
max_attempts=30
attempt=0
while ! curl -s http://127.0.0.1:3338/v1/info > /dev/null; do
attempt=$((attempt+1))
if [ $attempt -ge $max_attempts ]; then
echo "Nutshell failed to start after $max_attempts attempts"
docker stop nutshell
docker rm nutshell
exit 1
fi
echo "Waiting for Nutshell to start (attempt $attempt/$max_attempts)..."
sleep 1
done
echo "Nutshell is ready!"
export CDK_TEST_MINT_URL=http://127.0.0.1:3338
export LN_BACKEND=FAKEWALLET
cargo test -p cdk-integration-tests --test happy_path_mint_wallet
cargo test -p cdk-integration-tests --test test_fees
unset CDK_TEST_MINT_URL
unset LN_BACKEND
docker stop nutshell
docker rm nutshell
# run `cargo clippy` on everything
clippy *ARGS="--locked --offline --workspace --all-targets":
cargo clippy {{ARGS}}
# run `cargo clippy --fix` on everything
clippy-fix *ARGS="--locked --offline --workspace --all-targets":
cargo clippy {{ARGS}} --fix
typos:
typos
# fix all typos
[no-exit-message]
typos-fix:
just typos -w
itest db:
#!/usr/bin/env bash
./misc/itests.sh "{{db}}"
fake-mint-itest db:
#!/usr/bin/env bash
./misc/fake_itests.sh "{{db}}" external_signatory
./misc/fake_itests.sh "{{db}}"
itest-payment-processor ln:
#!/usr/bin/env bash
./misc/mintd_payment_processor.sh "{{ln}}"
fake-auth-mint-itest db openid_discovery:
#!/usr/bin/env bash
./misc/fake_auth_itests.sh "{{db}}" "{{openid_discovery}}"
nutshell-wallet-itest:
#!/usr/bin/env bash
./misc/nutshell_wallet_itest.sh
# Start interactive regtest environment (Bitcoin + 4 LN nodes + 2 CDK mints)
regtest db="sqlite":
#!/usr/bin/env bash
./misc/interactive_regtest_mprocs.sh {{db}}
# Lightning Network Commands (require regtest environment to be running)
# Get CLN node 1 info
ln-cln1 *ARGS:
#!/usr/bin/env bash
./misc/regtest_helper.sh ln-cln1 {{ARGS}}
# Get CLN node 2 info
ln-cln2 *ARGS:
#!/usr/bin/env bash
./misc/regtest_helper.sh ln-cln2 {{ARGS}}
# Get LND node 1 info
ln-lnd1 *ARGS:
#!/usr/bin/env bash
./misc/regtest_helper.sh ln-lnd1 {{ARGS}}
# Get LND node 2 info
ln-lnd2 *ARGS:
#!/usr/bin/env bash
./misc/regtest_helper.sh ln-lnd2 {{ARGS}}
# Bitcoin regtest commands
btc *ARGS:
#!/usr/bin/env bash
./misc/regtest_helper.sh btc {{ARGS}}
# Mine blocks in regtest
btc-mine blocks="10":
#!/usr/bin/env bash
./misc/regtest_helper.sh btc-mine {{blocks}}
# Show mint information
mint-info:
#!/usr/bin/env bash
./misc/regtest_helper.sh mint-info
# Run integration tests against regtest environment
mint-test:
#!/usr/bin/env bash
./misc/regtest_helper.sh mint-test
# Restart mints after recompiling (useful for development)
restart-mints:
#!/usr/bin/env bash
./misc/regtest_helper.sh restart-mints
# Show regtest environment status
regtest-status:
#!/usr/bin/env bash
./misc/regtest_helper.sh show-status
# Show regtest environment logs
regtest-logs:
#!/usr/bin/env bash
./misc/regtest_helper.sh show-logs
run-examples:
cargo r --example p2pk
cargo r --example mint-token
cargo r --example melt-token
cargo r --example proof_selection
cargo r --example wallet
check-wasm *ARGS="--target wasm32-unknown-unknown":
#!/usr/bin/env bash
set -euo pipefail
if [ ! -f Cargo.toml ]; then
cd {{invocation_directory()}}
fi
buildargs=(
"-p cdk"
"-p cdk --no-default-features"
"-p cdk --no-default-features --features wallet"
"-p cdk --no-default-features --features mint"
)
for arg in "${buildargs[@]}"; do
echo "Checking '$arg'"
cargo check $arg {{ARGS}}
echo
done
release m="":
#!/usr/bin/env bash
set -euo pipefail
args=(
"-p cashu"
"-p cdk-common"
"-p cdk-sqlite"
"-p cdk-redb"
"-p cdk-signatory"
"-p cdk"
"-p cdk-axum"
"-p cdk-mint-rpc"
"-p cdk-cln"
"-p cdk-lnd"
"-p cdk-lnbits"
"-p cdk-fake-wallet"
"-p cdk-payment-processor"
"-p cdk-cli"
"-p cdk-mintd"
)
for arg in "${args[@]}";
do
echo "Publishing '$arg'"
cargo publish $arg {{m}}
echo
done
check-docs:
#!/usr/bin/env bash
set -euo pipefail
args=(
"-p cashu"
"-p cdk-common"
"-p cdk"
"-p cdk-redb"
"-p cdk-sqlite"
"-p cdk-axum"
"-p cdk-cln"
"-p cdk-lnd"
"-p cdk-lnbits"
"-p cdk-fake-wallet"
"-p cdk-mint-rpc"
"-p cdk-signatory"
"-p cdk-cli"
"-p cdk-mintd"
)
for arg in "${args[@]}"; do
echo "Checking '$arg' docs"
cargo doc $arg --all-features
echo
done
# Build docs for all crates and error on warnings
docs-strict:
#!/usr/bin/env bash
set -euo pipefail
args=(
"-p cashu"
"-p cdk-common"
"-p cdk"
"-p cdk-redb"
"-p cdk-sqlite"
"-p cdk-axum"
"-p cdk-cln"
"-p cdk-lnd"
"-p cdk-lnbits"
"-p cdk-fake-wallet"
"-p cdk-mint-rpc"
"-p cdk-payment-processor"
"-p cdk-cli"
"-p cdk-mintd"
)
for arg in "${args[@]}"; do
echo "Building docs for $arg with strict warnings"
RUSTDOCFLAGS="-D warnings" cargo doc $arg --all-features --no-deps
echo
done