This directory contains scripts for setting up and interacting with a CDK regtest environment for development and testing.
interactive_regtest_mprocs.sh
Sets up a complete regtest environment with:
Unlike itests.sh
, this script keeps the environment running for interactive use and creates a state file (/tmp/cdk_regtest_env
) that allows other terminal sessions to find and interact with the environment.
regtest_helper.sh
Helper script providing convenient commands to interact with the running regtest environment. Automatically detects the environment using the state file.
just
(Recommended)Start the regtest environment:
just regtest [database_type]
database_type
: Optional, defaults to "sqlite". Can be "sqlite" or "redb"mprocs
and offer to install it if missingmprocs
showing logs from all nodes and mintsIn another terminal, interact with Lightning nodes:
# Get node information
just ln-cln1 getinfo
just ln-lnd1 getinfo
# Mine some blocks
just btc-mine 5
# Check mint status
just mint-info
# Start mprocs log viewer in another terminal
just regtest-mprocs
# See all available commands
just --list
Start the regtest environment:
./misc/interactive_regtest_mprocs.sh [database_type]
database_type
: Optional, defaults to "sqlite". Can be "sqlite" or "redb"In another terminal, use the helper script:
./misc/regtest_helper.sh help
The interactive regtest environment uses a state file (/tmp/cdk_regtest_env
) to share environment information between terminal sessions:
just regtest
or ./misc/interactive_regtest_mprocs.sh
, it creates the state file with all necessary environment variablesjust ln-cln1 getinfo
), the helper script automatically sources the state fileThis allows you to use just
commands from any terminal without needing to export environment variables manually.
When running, the environment provides:
127.0.0.1:18443
(user: testuser
, pass: testpass
)$CDK_ITESTS_DIR/cln/one/regtest/lightning-rpc
$CDK_ITESTS_DIR/cln/two/regtest/lightning-rpc
localhost:10009
localhost:10010
http://127.0.0.1:8085
(connected to CLN node 1)http://127.0.0.1:8087
(connected to LND node 2)The following variables are exported for easy access:
CDK_TEST_MINT_URL
: CLN mint URLCDK_TEST_MINT_URL_2
: LND mint URLCDK_ITESTS_DIR
: Temporary directory with all datajust
Commands (Recommended)# Start the environment
just regtest
# In another terminal:
# Get Lightning node info
just ln-cln1 getinfo
just ln-cln2 getinfo
just ln-lnd1 getinfo
just ln-lnd2 getinfo
# Create and pay invoices
just ln-cln1 invoice 1000 label description
just ln-lnd1 payinvoice <bolt11>
# Bitcoin operations
just btc getblockchaininfo
just btc-mine 10
just btc getbalance
# CDK operations
just mint-info
just mint-test
just restart-mints # Stop, recompile, and restart mints
just regtest-status
just regtest-logs # Show recent logs
just regtest-mprocs # Start mprocs TUI log viewer
# Lightning Node Operations
./misc/regtest_helper.sh ln-cln1 getinfo
./misc/regtest_helper.sh ln-lnd1 getinfo
./misc/regtest_helper.sh ln-cln1 invoice 1000 label description
./misc/regtest_helper.sh ln-lnd1 payinvoice <bolt11>
# Bitcoin Operations
./misc/regtest_helper.sh btc getblockchaininfo
./misc/regtest_helper.sh btc-mine 10
./misc/regtest_helper.sh btc getbalance
# CDK Mint Operations
./misc/regtest_helper.sh mint-info
./misc/regtest_helper.sh mint-test
./misc/regtest_helper.sh restart-mints
./misc/regtest_helper.sh show-status
# Query mint info directly
curl http://127.0.0.1:8085/v1/info | jq
# Get mint keysets
curl http://127.0.0.1:8085/v1/keysets | jq
# Terminal 1: Start environment
just regtest
# Terminal 2: Development and testing
just ln-cln1 getinfo # Check CLN status
just mint-info # Check mint status
just mint-test # Run integration tests
# Or use CDK CLI tools directly with the mint URLs
# The environment sets CDK_TEST_MINT_URL and CDK_TEST_MINT_URL_2
cargo run --bin cdk-cli -- --mint-url $CDK_TEST_MINT_URL mint-info
All files are stored in a temporary directory ($CDK_ITESTS_DIR
):
$CDK_ITESTS_DIR/
├── bitcoin/ # Bitcoin regtest data
├── cln/
│ ├── one/ # CLN node 1 data
│ └── two/ # CLN node 2 data
├── lnd/
│ ├── one/ # LND node 1 data
│ │ ├── tls.cert
│ │ └── data/chain/bitcoin/regtest/admin.macaroon
│ └── two/ # LND node 2 data
│ ├── tls.cert
│ └── data/chain/bitcoin/regtest/admin.macaroon
├── cln_mint/ # CLN mint working directory
│ └── mintd.log
└── lnd_mint/ # LND mint working directory
└── mintd.log
Ctrl+C
in the terminal running interactive_regtest_mprocs.sh
$CDK_ITESTS_DIR/cln_mint/mintd.log
and $CDK_ITESTS_DIR/lnd_mint/mintd.log
CDK_ITESTS_DIR
environment variable must be set (done automatically by interactive_regtest_mprocs.sh
)./misc/regtest_helper.sh show-status
to check component health./misc/regtest_helper.sh show-logs