Skip to content
Draft
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
16 changes: 14 additions & 2 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ jobs:
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-go@v6
with:
go-version: '>=1.26.1'
cache: true

- name: Run Nigiri
uses: vulpemventures/nigiri-github-action@v1
- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Run arkade-regtest
# solver only needs the base chain + esplora (it runs its own arkd stack),
# so start just the base profile. AUTOMINE_INTERVAL=0 keeps mining explicit.
run: REGTEST_PROFILES=base AUTOMINE_INTERVAL=0 node regtest/regtest.mjs start

- name: Run arkd stack
run: make docker-run
Expand All @@ -45,3 +53,7 @@ jobs:
- name: Tear down
if: always()
run: make docker-stop

- name: Stop arkade-regtest
if: always()
run: node regtest/regtest.mjs clean
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "regtest"]
path = regtest
url = https://github.com/ArkLabsHQ/arkade-regtest.git
branch = master
25 changes: 15 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,22 @@ test:
@echo "Running unit tests..."
@go test -v -race --count=1 $(shell go list ./... | grep -v /test/e2e)

## docker-run: start arkd stack and fund wallet (assumes nigiri is running)
## docker-run: start arkd stack and fund wallet (assumes arkade-regtest is running)
docker-run:
@echo "Starting arkd stack..."
@docker compose -f test/docker-compose.yml up -d --build
@echo "Waiting for services..."
@sleep 15
@echo "Waiting for solverd-arkd to be ready..."
@# arkd exits fatally if arkd-wallet isn't listening yet, then restarts, so
@# poll (rather than a fixed sleep) until it's actually up and responding.
@for i in $$(seq 1 90); do \
docker exec solverd-arkd arkd wallet status >/dev/null 2>&1 && { echo "solverd-arkd ready"; break; }; \
sleep 2; \
done
@echo "Creating arkd wallet..."
@docker exec solverd-arkd arkd wallet create --password password || true
@docker exec solverd-arkd arkd wallet unlock --password password || true
@echo "Funding arkd..."
@for i in 1 2 3; do nigiri faucet $$(docker exec solverd-arkd arkd wallet address | tr -d '[:space:]') 1; done
@for i in 1 2 3; do node regtest/regtest.mjs faucet $$(docker exec solverd-arkd arkd wallet address | tr -d '[:space:]') 1 --confirm; done
@sleep 5
@echo "Test environment ready."

Expand All @@ -107,17 +112,17 @@ docker-stop:
@echo "Stopping arkd stack..."
@docker compose -f test/docker-compose.yml down -v --remove-orphans

## setup-test-env: start nigiri + arkd stack for integration tests
## setup-test-env: start arkade-regtest + arkd stack for integration tests
setup-test-env:
@echo "Starting nigiri..."
@nigiri start
@echo "Starting arkade-regtest (base profile only)..."
@REGTEST_PROFILES=base AUTOMINE_INTERVAL=0 node regtest/regtest.mjs start
@$(MAKE) docker-run

## teardown-test-env: stop arkd stack + nigiri
## teardown-test-env: stop arkd stack + arkade-regtest
teardown-test-env:
@$(MAKE) docker-stop
@echo "Stopping nigiri..."
@nigiri stop --delete
@echo "Stopping arkade-regtest..."
@node regtest/regtest.mjs clean

## integrationtest: run integration tests (requires setup-test-env)
integrationtest:
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,20 @@ make test # unit tests

## Integration tests

End-to-end tests run against a local nigiri + arkd stack:
End-to-end tests run against a local [arkade-regtest](https://github.com/ArkLabsHQ/arkade-regtest)
+ arkd stack. arkade-regtest is vendored as a git submodule at `regtest/` and driven by its
zero-dependency Node CLI (`regtest.mjs`, requires Node >= 18). Make sure submodules are checked
out first: `git submodule update --init --recursive`.

```sh
make setup-test-env # boot nigiri + arkd + emulator, fund arkd wallet
make setup-test-env # boot arkade-regtest + arkd + emulator, fund arkd wallet
make integrationtest # run ./test/e2e/...
make teardown-test-env
```

If nigiri is already running (e.g. in CI, where the `vulpemventures/nigiri-github-action`
sets it up), use `make docker-run` and `make docker-stop` instead — they bring up
the solverd-side stack and fund the arkd wallet without touching nigiri.
If arkade-regtest is already running, use `make docker-run` and `make docker-stop` instead —
they bring up the solverd-side stack (which joins arkade-regtest's `arkade-regtest_default`
network) and fund the arkd wallet without touching arkade-regtest itself.

> Mining note: arkade-regtest's `faucet` does not auto-mine the way nigiri did. The funding
> and faucet helpers pass `--confirm` so the funding tx is mined into a block immediately.
1 change: 1 addition & 0 deletions regtest
Submodule regtest added at 20c085
14 changes: 9 additions & 5 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
nbxplorer:
restart: unless-stopped
container_name: solverd-nbxplorer
image: nicolasdorier/nbxplorer:2.5.30
image: nicolasdorier/nbxplorer:2.6.7
environment:
- NBXPLORER_NETWORK=regtest
- NBXPLORER_CHAINS=btc
Expand All @@ -41,7 +41,7 @@ services:

arkd-wallet:
restart: unless-stopped
image: ghcr.io/arkade-os/arkd-wallet:v0.9.3
image: ghcr.io/arkade-os/arkd-wallet:v0.9.6
container_name: solverd-arkd-wallet
depends_on:
- nbxplorer
Expand All @@ -57,7 +57,7 @@ services:
target: /app/data

arkd:
image: ghcr.io/arkade-os/arkd:v0.9.3
image: ghcr.io/arkade-os/arkd:v0.9.6
container_name: solverd-arkd
restart: unless-stopped
depends_on:
Expand All @@ -74,7 +74,7 @@ services:
- ARKD_BOARDING_EXIT_DELAY=30
- ARKD_CHECKPOINT_EXIT_DELAY=10
- ARKD_WALLET_ADDR=solverd-arkd-wallet:6060
- ARKD_ESPLORA_URL=http://chopsticks:3000
- ARKD_ESPLORA_URL=http://mempool_web/api
- ARKD_VTXO_MIN_AMOUNT=1
- ARKD_LIVE_STORE_TYPE=inmemory
- ARKD_EVENT_DB_TYPE=badger
Expand Down Expand Up @@ -102,6 +102,10 @@ services:
target: /app/data

networks:
# Join the arkade-regtest stack's network so this solverd-side stack can reach
# the shared bitcoin node + mempool esplora (`mempool_web/api`) by service name.
# `node regtest/regtest.mjs start` creates the compose project `arkade-regtest`,
# whose default network is `arkade-regtest_default`.
default:
name: nigiri
name: arkade-regtest_default
external: true
15 changes: 14 additions & 1 deletion test/e2e/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"fmt"
"net/http"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -162,8 +164,19 @@ func runCommand(ctx context.Context, command string) (string, error) {
return strings.TrimSpace(string(out)), nil
}

// repoRoot resolves the solver repository root from this source file's location
// (test/e2e/), so the arkade-regtest CLI can be invoked by its repo-relative
// path regardless of `go test`'s working directory.
func repoRoot() string {
_, file, _, _ := runtime.Caller(0)
return filepath.Clean(filepath.Join(filepath.Dir(file), "..", ".."))
}

func faucet(ctx context.Context, address string, amount float64) error {
command := fmt.Sprintf("nigiri faucet %s %.8f", address, amount)
// --confirm mines a block immediately after the send so the tx confirms
// right away (arkade-regtest's faucet does not auto-mine like nigiri did).
regtest := filepath.Join(repoRoot(), "regtest", "regtest.mjs")
command := fmt.Sprintf("node %q faucet %s %.8f --confirm", regtest, address, amount)
_, err := runCommand(ctx, command)
return err
}
Expand Down
Loading