Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ To build from a worktree instead of `../bitkit-android` / `../bitkit-ios` (dirty

---

### Spark receive on local regtest
### Spark tests on local regtest

The `@spark_1` spec uses the Spark operators and Lightning payer from the repository's `BITKIT_DOCKER_REVISION`. Start the fixture before building either app so both builds embed the fixture's Spark settings.
The Spark spec uses the operators, Lightning node, and Bitcoin miner from `BITKIT_DOCKER_REVISION`. It covers receiving Lightning into Spark (`@spark_1`), sending Lightning from Spark (`@spark_2`), and confirming an on-chain deposit (`@spark_3`). Start the fixture before building either app so both builds embed its Spark settings.

```bash
./scripts/local-backend spark-up
Expand All @@ -125,10 +125,10 @@ BACKEND=local ./scripts/build-ios-sim.sh
./scripts/run-spark-e2e.sh ios
```

Use a dedicated emulator and simulator because the test reinstalls Bitkit and creates a new wallet. Set `SIMULATOR_NAME` to the dedicated simulator's unique name and `SIMULATOR_OS_VERSION` to its installed runtime so Appium requests the matching capability. The Docker images build from source on the first start. Run `./scripts/local-backend spark-down` to stop the Spark services when done.
Use a dedicated emulator and simulator because each case reinstalls Bitkit and creates a new wallet. Set `SIMULATOR_NAME` to the dedicated simulator's unique name and `SIMULATOR_OS_VERSION` to its installed runtime so Appium requests the matching capability. The Docker images build from source on the first start. Run `./scripts/local-backend spark-down` to stop the Spark services when done.

The **Local E2E Nightly** workflows run this case on Android and iOS at 05:35 UTC against E2E `main`. To run it on demand, dispatch the workflow in the app repository. Set `e2e_branch` if the spec is on another ref. The job makes up to three attempts and uploads logs and diagnostics by attempt.
CI caches the Spark images by Docker pin and runner architecture. The iOS workflow prepares ARM64 images and wallet settings on hosted Linux, then builds the app on hosted macOS. The self-hosted Mac reuses matching Docker images when available, starts a fresh fixture, and verifies its wallet settings before running the test.
The **Local E2E Nightly** workflows run the Spark spec on Android and iOS at 05:35 UTC against E2E `main`. To run it on demand, dispatch the workflow in the app repository. Set `e2e_branch` if the spec is on another ref. The job makes up to three attempts and uploads logs and diagnostics by attempt.
CI caches the Spark images by Docker pin and runner architecture. The iOS workflow prepares ARM64 images and wallet settings on hosted Linux, then builds the app on hosted macOS. The self-hosted Mac reuses matching Docker images when available, starts a fresh fixture, and verifies its wallet settings before running the tests.

### USDT local execution

Expand Down
50 changes: 49 additions & 1 deletion scripts/local-backend
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,54 @@ case "${1:-}" in
}
spark pay "$2"
;;
spark-invoice)
check_revision
[[ "$#" -eq 2 && "${2:-}" =~ ^[1-9][0-9]*$ ]] || {
echo 'Usage: ./scripts/local-backend spark-invoice <sats>' >&2
exit 2
}
spark invoice "$2" | jq -e '{invoice, payment_hash}'
;;
spark-payment-details)
check_revision
[[ "$#" -eq 2 && "${2:-}" =~ ^[a-f0-9]{64}$ ]] || {
echo 'Usage: ./scripts/local-backend spark-payment-details <payment-hash>' >&2
exit 2
}
compose --profile spark exec -T spark-ldk-alice ldk-server-cli \
--config /local/ldk-alice.toml --base-url localhost:3536 get-payment-details "$2" |
jq -e '.payment | {amount_msat, direction, status}'
;;
spark-fund)
check_revision
[[ "$#" -eq 3 && "${2:-}" =~ ^bcrt1[qp][02-9ac-hj-np-z]+$ && "${3:-}" =~ ^[1-9][0-9]*$ ]] || {
echo 'Usage: ./scripts/local-backend spark-fund <regtest-address> <sats>' >&2
exit 2
}
funding="$(spark send "$2" "$3" -m 0)"
[[ "$funding" =~ ([a-f0-9]{64})$ ]] || {
echo 'The Spark miner did not report a transaction ID.' >&2
exit 1
}
printf '%s\n' "${BASH_REMATCH[1]}"
;;
spark-tx)
check_revision
[[ "$#" -eq 2 && "${2:-}" =~ ^[a-f0-9]{64}$ ]] || {
echo 'Usage: ./scripts/local-backend spark-tx <txid>' >&2
exit 2
}
# The pinned CLI prints the transaction first, followed by its output spend records.
spark tx "$2" | jq -cse '.[0]'
;;
spark-mine)
check_revision
[[ "$#" -eq 1 ]] || {
echo 'Usage: ./scripts/local-backend spark-mine' >&2
exit 2
}
spark mine 1
;;
spark-down)
check_revision
spark down
Expand Down Expand Up @@ -279,7 +327,7 @@ case "${1:-}" in
exec "$@"
;;
*)
echo 'Usage: ./scripts/local-backend {prepare|path|up|down|ps|logs|github-env|run <command>|spark-pack <image-archive>|spark-up|spark-image-fingerprint|spark-init-env|spark-env|spark-pay <invoice>|spark-down|spark-logs}' >&2
echo 'Usage: ./scripts/local-backend {prepare|path|up|down|ps|logs|github-env|run <command>|spark-pack <image-archive>|spark-up|spark-image-fingerprint|spark-init-env|spark-env|spark-pay <invoice>|spark-invoice <sats>|spark-payment-details <payment-hash>|spark-fund <address> <sats>|spark-tx <txid>|spark-mine|spark-down|spark-logs}' >&2
exit 2
;;
esac
4 changes: 2 additions & 2 deletions scripts/run-spark-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ if [[ "$1" == android ]]; then
done
fi

# Each dedicated run must execute the payment even on a reused runner.
# Run fresh wallets on every attempt, including on a reused runner.
exec ./scripts/local-backend run env -u CI BITKIT_LOCAL_SPARK=1 "./ci_run_$1.sh" \
--spec ./test/specs/spark.e2e.ts --mochaOpts.grep '@spark_1\b'
--spec ./test/specs/spark.e2e.ts
Loading