From 4028824b1ac3d2f163a20e24004796438243d082 Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Tue, 8 Jul 2025 10:48:22 +0100 Subject: [PATCH 1/4] feat: mprocs regtest --- MINT_RESTART_FEATURE.md | 86 ++++++ MPROCS_INTEGRATION.md | 147 ++++++++++ MPROCS_MODES.md | 132 +++++++++ REGTEST_QUICKSTART.md | 125 +++++++++ flake.nix | 3 +- justfile | 67 +++++ misc/README.md | 218 +++++++++++++++ misc/interactive_regtest.sh | 330 ++++++++++++++++++++++ misc/interactive_regtest_mprocs.sh | 320 ++++++++++++++++++++++ misc/regtest_helper.sh | 421 +++++++++++++++++++++++++++++ 10 files changed, 1848 insertions(+), 1 deletion(-) create mode 100644 MINT_RESTART_FEATURE.md create mode 100644 MPROCS_INTEGRATION.md create mode 100644 MPROCS_MODES.md create mode 100644 REGTEST_QUICKSTART.md create mode 100644 misc/README.md create mode 100755 misc/interactive_regtest.sh create mode 100755 misc/interactive_regtest_mprocs.sh create mode 100755 misc/regtest_helper.sh diff --git a/MINT_RESTART_FEATURE.md b/MINT_RESTART_FEATURE.md new file mode 100644 index 00000000..0a6180a3 --- /dev/null +++ b/MINT_RESTART_FEATURE.md @@ -0,0 +1,86 @@ +# Mint Restart Feature + +A new command has been added to restart the CDK mints after recompiling, perfect for development workflows when you're making changes to the mint code. + +## Command + +```bash +just restart-mints +``` + +or + +```bash +./misc/regtest_helper.sh restart-mints +``` + +## What It Does + +1. **Stops** both running mints (CLN and LND mints) +2. **Recompiles** the `cdk-mintd` binary with your latest changes +3. **Restarts** both mints with the same configuration +4. **Waits** for both mints to be ready and responding +5. **Updates** the state file with new process IDs + +## Development Workflow + +### Before this feature: +```bash +# Terminal 1: Start environment +just regtest + +# Terminal 2: Make code changes, then manually restart everything +# Ctrl+C in Terminal 1 (stops entire environment including Lightning network) +just regtest # Start everything again (slow) +``` + +### With this feature: +```bash +# Terminal 1: Start environment (once) +just regtest + +# Terminal 2: Make code changes, then quickly restart just the mints +just restart-mints # Fast! Keeps Lightning network running +just mint-test # Test your changes +``` + +## Benefits + +1. **Faster Development Cycle** - No need to restart the entire Lightning network +2. **Preserves Network State** - Bitcoin blockchain, Lightning channels, and node states remain intact +3. **Automatic Recompilation** - No need to manually run `cargo build` +4. **Status Validation** - Ensures mints are responding before completing +5. **State Management** - Updates process IDs for other commands to work correctly + +## Example Output + +``` +=============================== +Restarting CDK Mints +=============================== +Stopping existing mints... + Stopping CLN Mint (PID: 12345) + Stopping LND Mint (PID: 12346) +Recompiling cdk-mintd... +✓ Compilation successful +Starting CLN Mint... +Waiting for CLN mint to start... +✓ CLN Mint ready +Starting LND Mint... +Waiting for LND mint to start... +✓ LND Mint ready + +✅ Mints restarted successfully! + CLN Mint: http://127.0.0.1:8085 (PID: 54321) + LND Mint: http://127.0.0.1:8087 (PID: 54322) +=============================== +``` + +## Use Cases + +- **Testing mint code changes** without restarting the entire regtest environment +- **Debugging mint behavior** with fresh mint instances +- **Performance testing** with clean mint state but preserved Lightning network +- **Integration testing** after mint code modifications + +This feature makes the development experience much smoother when working on CDK mint functionality! diff --git a/MPROCS_INTEGRATION.md b/MPROCS_INTEGRATION.md new file mode 100644 index 00000000..79aee0fe --- /dev/null +++ b/MPROCS_INTEGRATION.md @@ -0,0 +1,147 @@ +# mprocs Integration for CDK Regtest + +The CDK regtest environment now integrates with `mprocs` to provide a beautiful TUI (Terminal User Interface) for monitoring all component logs in real-time. + +## What is mprocs? + +`mprocs` is a TUI for running multiple processes and monitoring their output. Perfect for development environments where you need to watch logs from multiple services simultaneously. + +## Features + +### Automatic Setup +- The regtest script checks for `mprocs` and offers to install it if missing +- Creates a dynamic mprocs configuration with all relevant log files +- Handles missing log files gracefully (waits for them to be created) + +### Components Monitored +- **cln-mint**: CDK mint connected to CLN +- **lnd-mint**: CDK mint connected to LND +- **bitcoind**: Bitcoin regtest node +- **cln-one**: Core Lightning node #1 +- **cln-two**: Core Lightning node #2 +- **lnd-one**: LND node #1 +- **lnd-two**: LND node #2 + +### Key Benefits +- **Real-time log monitoring** for all components +- **Side-by-side view** of related services +- **Easy navigation** between different logs +- **Scrollback** to review history +- **Search functionality** within logs +- **Process management** (start/stop/restart individual processes) + +## Usage + +### Automatic (Recommended) - Log Tailing Mode +```bash +just regtest +# After setup completes, mprocs launches automatically +# Mints start and log to files, mprocs shows log contents +``` + +### Direct Process Management Mode +```bash +just regtest-mprocs +# After setup, mprocs starts with mint processes stopped +# Use 's' key to start individual mints +# Full process control from within mprocs +``` + +### Manual Launch +```bash +# Start environment without mprocs +just regtest + +# In another terminal, launch mprocs +just regtest-logs +``` + +### Commands Available +```bash +just regtest # Starts environment and mprocs (log tailing mode) +just regtest-mprocs # Starts environment with direct process management +just regtest-logs # Manual mprocs launch (adapts to current mode) +``` + +## mprocs Controls + +### Direct Process Management Mode: +- **Arrow keys**: Navigate between processes +- **s**: Start the selected process +- **k**: Kill the selected process +- **r**: Restart the selected process +- **Enter**: Focus on selected process +- **Tab**: Switch between process list and log view +- **?**: Show help +- **q**: Quit mprocs (stops all managed processes) + +### Log Tailing Mode: +- **Arrow keys**: Navigate between processes +- **Enter**: Focus on selected process +- **Tab**: Switch between process list and log view +- **PageUp/PageDown**: Scroll through logs +- **Ctrl+C**: Interrupt current process +- **q**: Quit mprocs (processes continue running) + +## Installation + +If `mprocs` is not installed: +```bash +# Automatic installation prompt when running regtest +just regtest + +# Manual installation +cargo install mprocs + +# Or via package manager (varies by OS) +# Ubuntu/Debian: apt install mprocs +# macOS: brew install mprocs +``` + +## Configuration + +The mprocs configuration is automatically generated at `$CDK_ITESTS_DIR/mprocs.yaml`. It includes: + +- Proper log file paths for all components +- Graceful handling of missing files +- Optimized UI settings for development +- Auto-start for all monitoring processes + +## Development Workflow + +### Before mprocs: +- Start regtest environment +- Open multiple terminals to `tail -f` different log files +- Manually manage multiple windows/panes +- Switch between terminals to see different components + +### With mprocs: +- Start regtest environment → automatic log monitoring +- Single TUI shows all component logs +- Easy navigation between components +- Professional development experience + +## Example View + +``` +┌─Processes─────────┬─Output───────────────────────────────────────┐ +│ ● cln-mint │ 2024-07-08T08:30:12 INFO cdk_mintd: Starting │ +│ ● lnd-mint │ mint server on 127.0.0.1:8085 │ +│ ● bitcoind │ 2024-07-08T08:30:13 INFO: New invoice │ +│ ● cln-one │ received for 1000 sats │ +│ ● cln-two │ 2024-07-08T08:30:14 INFO: Payment │ +│ ● lnd-one │ successful │ +│ ● lnd-two │ │ +│ │ │ +└───────────────────┴──────────────────────────────────────────────┘ +``` + +## Fallback + +If mprocs is not available or fails: +- Environment continues to work normally +- Falls back to simple wait loop +- All `just` commands work as expected +- Logs still accessible via `just regtest-logs` + +This integration makes CDK development much more pleasant by providing professional-grade log monitoring out of the box! 🎉 diff --git a/MPROCS_MODES.md b/MPROCS_MODES.md new file mode 100644 index 00000000..06faea0e --- /dev/null +++ b/MPROCS_MODES.md @@ -0,0 +1,132 @@ +# mprocs Process Management Modes + +The CDK regtest environment now supports two different modes for managing processes with mprocs: + +## Mode 1: Log Tailing (Default) +**Command**: `just regtest` + +### How it works: +- Mints are started by the bash script and run in the background +- Mints write their output to log files (`mintd.log`) +- mprocs uses `tail -f` to follow these log files +- Log files persist even after mprocs exits + +### Pros: +- ✅ Log files are preserved for later analysis +- ✅ Simple setup +- ✅ Works even if mprocs crashes + +### Cons: +- ❌ Cannot restart mints from within mprocs +- ❌ Must use external commands to control mints +- ❌ mprocs shows file contents, not live processes + +## Mode 2: Direct Process Management +**Command**: `just regtest-mprocs` + +### How it works: +- mprocs directly manages the mint processes +- Mints are started/stopped by mprocs itself +- Output goes directly to mprocs (no log files by default) +- Full process control from within mprocs + +### Pros: +- ✅ Start/stop/restart mints directly from mprocs +- ✅ Live process output +- ✅ Better development workflow +- ✅ Process status indicators + +### Cons: +- ❌ Output not saved to files (unless configured) +- ❌ If mprocs crashes, you lose the processes + +## mprocs Controls + +### Direct Process Management Mode: +- **Arrow keys**: Navigate between processes +- **s**: Start the selected process +- **k**: Kill the selected process +- **r**: Restart the selected process +- **Enter**: Focus on a process (see its output) +- **Tab**: Switch between process list and output +- **?**: Show help +- **q**: Quit mprocs (stops all managed processes) + +### Log Tailing Mode: +- **Arrow keys**: Navigate between log sources +- **Enter**: Focus on a log source +- **Tab**: Switch between process list and log view +- **PageUp/PageDown**: Scroll through logs +- **q**: Quit mprocs (processes continue running) + +## Usage Examples + +### Start with Log Tailing (Original Mode) +```bash +just regtest +# Mints start automatically and log to files +# mprocs shows log contents +# Use Ctrl+C or 'q' to exit mprocs +# Processes continue running in background +``` + +### Start with Direct Process Management +```bash +just regtest-mprocs +# Only Lightning network starts automatically +# In mprocs, navigate to "cln-mint" and press 's' to start it +# Navigate to "lnd-mint" and press 's' to start it +# Use 'r' to restart mints after code changes +# Use 'q' to exit and stop all processes +``` + +### Switch Between Modes + +If you started with log tailing mode, you can access the direct management: +```bash +# In another terminal +source /tmp/cdk_regtest_env +just regtest-logs # This will detect the mode and adapt +``` + +## Development Workflow Comparison + +### Traditional (Log Tailing): +1. `just regtest` +2. Make code changes +3. In another terminal: `just restart-mints` +4. Check logs in mprocs + +### Direct Management: +1. `just regtest-mprocs` +2. Press 's' to start mints +3. Make code changes +4. In mprocs: press 'r' on each mint to restart +5. Watch live output directly + +## Technical Details + +### Project Root Handling +The direct process management mode ensures that: +- Startup scripts change to the correct project root directory +- Cargo commands run from where the `Cargo.toml` file is located +- Environment variables are properly set before starting processes + +### File Structure +``` +$CDK_ITESTS_DIR/ +├── start_cln_mint.sh # Sets PROJECT_ROOT and runs cargo from there +├── start_lnd_mint.sh # Sets PROJECT_ROOT and runs cargo from there +└── mprocs.yaml # Points to the startup scripts +``` + +Each startup script: +1. Changes to the project root directory (`cd "$PROJECT_ROOT"`) +2. Sets all required environment variables +3. Executes `cargo run --bin cdk-mintd` from the correct location + +The environment variables and helper commands work the same in both modes: +- `just ln-cln1 getinfo` +- `just btc-mine 5` +- `just mint-info` +- etc. diff --git a/REGTEST_QUICKSTART.md b/REGTEST_QUICKSTART.md new file mode 100644 index 00000000..f02bedf6 --- /dev/null +++ b/REGTEST_QUICKSTART.md @@ -0,0 +1,125 @@ +# CDK Interactive Regtest - Quick Start + +A simple guide to get up and running with the interactive regtest environment. + +## Start Environment + +```bash +# Terminal 1: Start regtest with default sqlite database +just regtest + +# Or with redb database +just regtest redb +``` + +The script will: +1. Check for `mprocs` and offer to install it if missing +2. Set up the regtest environment (Bitcoin + Lightning nodes + CDK mints) +3. Launch `mprocs` showing logs from all components +4. Press 'q' in mprocs to quit and stop the environment + +## Use Lightning Nodes (in any other terminal) + +The `just` commands work from any terminal - they automatically find the running environment. + +### Get Node Information +```bash +just ln-cln1 getinfo # CLN node 1 +just ln-cln2 getinfo # CLN node 2 +just ln-lnd1 getinfo # LND node 1 +just ln-lnd2 getinfo # LND node 2 +``` + +### Create and Pay Invoices +```bash +# Create 1000 sat invoice on CLN +just ln-cln1 invoice 1000 test_label "Test payment" + +# Pay invoice with LND (use the bolt11 from above) +just ln-lnd1 payinvoice lnbcrt10u1... + +# Check balances +just ln-cln1 listfunds +just ln-lnd1 listchannels +``` + +## Bitcoin Operations + +```bash +just btc getblockchaininfo # Blockchain status +just btc getbalance # Wallet balance +just btc-mine 5 # Mine 5 blocks +``` + +## CDK Mint Operations + +```bash +just mint-info # Show both mints' info +just mint-test # Run integration tests +just restart-mints # Stop, recompile, and restart mints +just regtest-status # Check all components +just regtest-logs # Show recent logs +just regtest-mprocs # Start mprocs TUI (if not already running) +``` + +## Stop Environment + +Press `Ctrl+C` in the terminal running `just regtest`. Everything will be cleaned up automatically. + +## Available Endpoints + +- **CLN Mint**: http://127.0.0.1:8085 +- **LND Mint**: http://127.0.0.1:8087 +- **Bitcoin RPC**: 127.0.0.1:18443 (testuser/testpass) + +## Common Workflows + +### Test Lightning Payment Flow +```bash +# Terminal 1 +just regtest + +# Terminal 2 +just ln-cln1 invoice 1000 test "Test payment" +# Copy the bolt11 invoice + +just ln-lnd1 payinvoice +just ln-cln1 listinvoices +just ln-lnd1 listpayments +``` + +### Test CDK Integration +```bash +# Terminal 1 +just regtest + +# Terminal 2 +just mint-test # Run all tests +cargo test -p cdk-integration-tests # Or specific tests +``` + +### Development with CDK CLI +```bash +# Terminal 1 +just regtest + +# Terminal 2 - use environment variables +echo $CDK_TEST_MINT_URL # CLN mint URL +echo $CDK_TEST_MINT_URL_2 # LND mint URL + +# Use with CDK CLI +cargo run --bin cdk-cli -- --mint-url $CDK_TEST_MINT_URL mint-info +``` + +### Development Workflow (Mint Code Changes) +```bash +# Terminal 1: Keep regtest running +just regtest + +# Terminal 2: Make changes to mint code, then +just restart-mints # Recompiles and restarts both mints +just mint-info # Test the changes +just mint-test # Run integration tests +``` + +That's it! The environment provides a full Lightning Network with CDK mints for testing and development. diff --git a/flake.nix b/flake.nix index 311f5307..20def631 100644 --- a/flake.nix +++ b/flake.nix @@ -81,6 +81,7 @@ bitcoind sqlx-cli cargo-outdated + mprocs # Needed for github ci libz @@ -274,7 +275,7 @@ echo "Docker is available at $(which docker)" echo "Docker version: $(docker --version)" ''; - buildInputs = buildInputs ++ [ + buildInputs = buildInputs ++ [ stable_toolchain pkgs.docker-client ]; diff --git a/justfile b/justfile index fbf3b9c1..7c403f97 100644 --- a/justfile +++ b/justfile @@ -153,6 +153,73 @@ 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.sh {{db}} + +# Start regtest with direct process management via mprocs (lets you start/stop mints) +regtest-mprocs 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 diff --git a/misc/README.md b/misc/README.md new file mode 100644 index 00000000..51b19c35 --- /dev/null +++ b/misc/README.md @@ -0,0 +1,218 @@ +# CDK Interactive Regtest Environment + +This directory contains scripts for setting up and interacting with a CDK regtest environment for development and testing. + +## Scripts + +### 1. `interactive_regtest.sh` +Sets up a complete regtest environment with: +- Bitcoin regtest node +- 2 CLN (Core Lightning) nodes with channels +- 2 LND nodes with channels +- 2 CDK mint instances (one connected to CLN, one to LND) + +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. + +### 2. `regtest_helper.sh` +Helper script providing convenient commands to interact with the running regtest environment. Automatically detects the environment using the state file. + +## Quick Start + +### Using `just` (Recommended) + +1. **Start the regtest environment:** + ```bash + just regtest [database_type] + ``` + - `database_type`: Optional, defaults to "sqlite". Can be "sqlite" or "redb" + - The script will check for `mprocs` and offer to install it if missing + - After setup, it will launch `mprocs` showing logs from all nodes and mints + - Press 'q' in mprocs to quit and stop the environment + +2. **In another terminal, interact with Lightning nodes:** + ```bash + # 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 + ``` + +### Using Scripts Directly + +1. **Start the regtest environment:** + ```bash + ./misc/interactive_regtest.sh [database_type] + ``` + - `database_type`: Optional, defaults to "sqlite". Can be "sqlite" or "redb" + - The script will build necessary binaries and set up the full environment + - Keep this terminal open - the environment runs until you press Ctrl+C + +2. **In another terminal, use the helper script:** + ```bash + ./misc/regtest_helper.sh help + ``` + +## How It Works + +The interactive regtest environment uses a state file (`/tmp/cdk_regtest_env`) to share environment information between terminal sessions: + +1. When you run `just regtest` or `./misc/interactive_regtest.sh`, it creates the state file with all necessary environment variables +2. When you run Lightning node commands in other terminals (e.g., `just ln-cln1 getinfo`), the helper script automatically sources the state file +3. When the environment shuts down (Ctrl+C), it cleans up the state file automatically + +This allows you to use `just` commands from any terminal without needing to export environment variables manually. + +## Environment Details + +When running, the environment provides: + +### Network Endpoints +- **Bitcoin RPC**: `127.0.0.1:18443` (user: `testuser`, pass: `testpass`) +- **CLN Node 1**: Unix socket at `$CDK_ITESTS_DIR/cln/one/regtest/lightning-rpc` +- **CLN Node 2**: Unix socket at `$CDK_ITESTS_DIR/cln/two/regtest/lightning-rpc` +- **LND Node 1**: HTTPS on `localhost:10009` +- **LND Node 2**: HTTPS on `localhost:10010` + +### CDK Mints +- **CLN Mint**: `http://127.0.0.1:8085` (connected to CLN node 1) +- **LND Mint**: `http://127.0.0.1:8087` (connected to LND node 2) + +### Environment Variables +The following variables are exported for easy access: +- `CDK_TEST_MINT_URL`: CLN mint URL +- `CDK_TEST_MINT_URL_2`: LND mint URL +- `CDK_ITESTS_DIR`: Temporary directory with all data + +## Usage Examples + +### Using `just` Commands (Recommended) + +```bash +# 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 + +# 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 +``` + +### Using Helper Script Directly + +```bash +# 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 + +# 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 +``` + +### Legacy Examples (for reference) + +### Direct API Access +```bash +# 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 +``` + +### Development Workflow +```bash +# 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 +``` + +## File Locations + +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 +``` + +## Cleanup + +- Press `Ctrl+C` in the terminal running `interactive_regtest.sh` +- All processes will be terminated and the temporary directory will be cleaned up automatically +- No manual cleanup is required + +## Troubleshooting + +### Environment not starting +- Check that ports 8085, 8087, 18443, 19846, 19847, 10009, 10010 are available +- Ensure you have the necessary dependencies (Bitcoin Core, CLN, LND) available +- Check the logs in `$CDK_ITESTS_DIR/cln_mint/mintd.log` and `$CDK_ITESTS_DIR/lnd_mint/mintd.log` + +### Helper script not working +- Ensure the regtest environment is running first +- The `CDK_ITESTS_DIR` environment variable must be set (done automatically by `interactive_regtest.sh`) + +### Connection issues +- Use `./misc/regtest_helper.sh show-status` to check component health +- Check mint logs with `./misc/regtest_helper.sh show-logs` diff --git a/misc/interactive_regtest.sh b/misc/interactive_regtest.sh new file mode 100755 index 00000000..e38b8fb4 --- /dev/null +++ b/misc/interactive_regtest.sh @@ -0,0 +1,330 @@ +#!/usr/bin/env bash + +# Interactive Regtest Environment for CDK +# This script sets up the regtest environment and keeps it running for interaction + +set -e + +# Function to wait for HTTP endpoint +wait_for_endpoint() { + local url=$1 + local timeout=${2:-60} + local start_time=$(date +%s) + + while true; do + local current_time=$(date +%s) + local elapsed_time=$((current_time - start_time)) + + if [ $elapsed_time -ge $timeout ]; then + echo "❌ Timeout waiting for $url" + return 1 + fi + + local http_status=$(curl -o /dev/null -s -w "%{http_code}" "$url" 2>/dev/null || echo "000") + + if [ "$http_status" -eq 200 ]; then + echo "✓ $url is ready" + return 0 + fi + + sleep 2 + done +} + +# Function to perform cleanup +cleanup() { + echo "Cleaning up..." + + # Remove state file for other sessions + rm -f "/tmp/cdk_regtest_env" + + if [ ! -z "$CDK_MINTD_PID" ] && kill -0 $CDK_MINTD_PID 2>/dev/null; then + echo "Killing the cdk mintd (CLN)" + kill -2 $CDK_MINTD_PID + wait $CDK_MINTD_PID + fi + + if [ ! -z "$CDK_MINTD_LND_PID" ] && kill -0 $CDK_MINTD_LND_PID 2>/dev/null; then + echo "Killing the cdk mintd (LND)" + kill -2 $CDK_MINTD_LND_PID + wait $CDK_MINTD_LND_PID + fi + + if [ ! -z "$CDK_REGTEST_PID" ] && kill -0 $CDK_REGTEST_PID 2>/dev/null; then + echo "Killing the cdk regtest" + kill -2 $CDK_REGTEST_PID + wait $CDK_REGTEST_PID + fi + + echo "Environment terminated" + + # Remove the temporary directory + if [ ! -z "$CDK_ITESTS_DIR" ]; then + rm -rf "$CDK_ITESTS_DIR" + echo "Temp directory removed: $CDK_ITESTS_DIR" + fi + + # Unset all environment variables + unset CDK_ITESTS_DIR + unset CDK_ITESTS_MINT_ADDR + unset CDK_ITESTS_MINT_PORT_0 + unset CDK_ITESTS_MINT_PORT_1 + unset CDK_MINTD_DATABASE + unset CDK_TEST_MINT_URL + unset CDK_TEST_MINT_URL_2 + unset CDK_MINTD_URL + unset CDK_MINTD_WORK_DIR + unset CDK_MINTD_LISTEN_HOST + unset CDK_MINTD_LISTEN_PORT + unset CDK_MINTD_LN_BACKEND + unset CDK_MINTD_MNEMONIC + unset CDK_MINTD_CLN_RPC_PATH + unset CDK_MINTD_LND_ADDRESS + unset CDK_MINTD_LND_CERT_FILE + unset CDK_MINTD_LND_MACAROON_FILE + unset CDK_MINTD_PID + unset CDK_MINTD_LND_PID + unset CDK_REGTEST_PID + unset RUST_BACKTRACE + unset CDK_TEST_REGTEST +} + +# Set up trap to call cleanup on script exit +trap cleanup EXIT + +export CDK_TEST_REGTEST=1 + +# Check for mprocs and offer to install if missing +if ! command -v mprocs >/dev/null 2>&1; then + echo "⚠️ mprocs not found - this tool provides a nice TUI for monitoring logs" + echo "Install it with: cargo install mprocs" + echo + read -p "Would you like to install mprocs now? (y/n): " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + echo "Installing mprocs..." + cargo install mprocs + if [ $? -eq 0 ]; then + echo "✓ mprocs installed successfully" + else + echo "❌ Failed to install mprocs. You can install it later with: cargo install mprocs" + fi + else + echo "Skipping mprocs installation. The environment will work without it." + fi + echo +fi + +# Parse command line arguments +CDK_MINTD_DATABASE=${1:-"sqlite"} # Default to sqlite if not specified + +# Create a temporary directory +export CDK_ITESTS_DIR=$(mktemp -d) +export CDK_ITESTS_MINT_ADDR="127.0.0.1" +export CDK_ITESTS_MINT_PORT_0=8085 +export CDK_ITESTS_MINT_PORT_1=8087 + +# Check if the temporary directory was created successfully +if [[ ! -d "$CDK_ITESTS_DIR" ]]; then + echo "Failed to create temp directory" + exit 1 +fi + +echo "==============================================" +echo "Starting Interactive CDK Regtest Environment" +echo "==============================================" +echo "Temp directory: $CDK_ITESTS_DIR" +echo "Database type: $CDK_MINTD_DATABASE" +echo + +export CDK_MINTD_DATABASE="$CDK_MINTD_DATABASE" + +# Build the necessary binaries +echo "Building binaries..." +cargo build -p cdk-integration-tests --bin start_regtest + +echo "Starting regtest network (Bitcoin + Lightning nodes)..." +cargo run --bin start_regtest & +export CDK_REGTEST_PID=$! + +# Create named pipe for progress tracking +mkfifo "$CDK_ITESTS_DIR/progress_pipe" +rm -f "$CDK_ITESTS_DIR/signal_received" + +# Start reading from pipe in background +(while read line; do + case "$line" in + "checkpoint1") + echo "✓ Regtest network is ready" + touch "$CDK_ITESTS_DIR/signal_received" + exit 0 + ;; + esac +done < "$CDK_ITESTS_DIR/progress_pipe") & + +# Wait for regtest setup (up to 120 seconds) +echo "Waiting for regtest network to be ready..." +for ((i=0; i<120; i++)); do + if [ -f "$CDK_ITESTS_DIR/signal_received" ]; then + break + fi + sleep 1 +done + +if [ ! -f "$CDK_ITESTS_DIR/signal_received" ]; then + echo "❌ Timeout waiting for regtest network" + exit 1 +fi + +echo +echo "Starting CDK Mint #1 (CLN backend)..." +export CDK_MINTD_CLN_RPC_PATH="$CDK_ITESTS_DIR/cln/one/regtest/lightning-rpc" +export CDK_MINTD_URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_0" +export CDK_MINTD_WORK_DIR="$CDK_ITESTS_DIR/cln_mint" +export CDK_MINTD_LISTEN_HOST=$CDK_ITESTS_MINT_ADDR +export CDK_MINTD_LISTEN_PORT=$CDK_ITESTS_MINT_PORT_0 +export CDK_MINTD_LN_BACKEND="cln" +export CDK_MINTD_MNEMONIC="eye survey guilt napkin crystal cup whisper salt luggage manage unveil loyal" +export RUST_BACKTRACE=1 + +mkdir -p "$CDK_MINTD_WORK_DIR" +cargo run --bin cdk-mintd > "$CDK_MINTD_WORK_DIR/mintd.log" 2>&1 & +export CDK_MINTD_PID=$! + +# Wait for CLN mint to be ready +echo "Waiting for CLN mint to be ready..." +URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_0/v1/info" +wait_for_endpoint "$URL" 60 + +echo +echo "Starting CDK Mint #2 (LND backend)..." +export CDK_MINTD_LND_ADDRESS="https://localhost:10010" +export CDK_MINTD_LND_CERT_FILE="$CDK_ITESTS_DIR/lnd/two/tls.cert" +export CDK_MINTD_LND_MACAROON_FILE="$CDK_ITESTS_DIR/lnd/two/data/chain/bitcoin/regtest/admin.macaroon" + +export CDK_MINTD_URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_1" +mkdir -p "$CDK_ITESTS_DIR/lnd_mint" +export CDK_MINTD_WORK_DIR="$CDK_ITESTS_DIR/lnd_mint" +export CDK_MINTD_LISTEN_HOST=$CDK_ITESTS_MINT_ADDR +export CDK_MINTD_LISTEN_PORT=$CDK_ITESTS_MINT_PORT_1 +export CDK_MINTD_LN_BACKEND="lnd" +export CDK_MINTD_MNEMONIC="cattle gold bind busy sound reduce tone addict baby spend february strategy" + +cargo run --bin cdk-mintd > "$CDK_MINTD_WORK_DIR/mintd.log" 2>&1 & +export CDK_MINTD_LND_PID=$! + +# Wait for LND mint to be ready +echo "Waiting for LND mint to be ready..." +URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_1/v1/info" +wait_for_endpoint "$URL" 60 + +# Set environment variables for easy access +export CDK_TEST_MINT_URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_0" +export CDK_TEST_MINT_URL_2="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_1" + +# Create state file for other terminal sessions +ENV_FILE="/tmp/cdk_regtest_env" +echo "export CDK_ITESTS_DIR=\"$CDK_ITESTS_DIR\"" > "$ENV_FILE" +echo "export CDK_TEST_MINT_URL=\"$CDK_TEST_MINT_URL\"" >> "$ENV_FILE" +echo "export CDK_TEST_MINT_URL_2=\"$CDK_TEST_MINT_URL_2\"" >> "$ENV_FILE" +echo "export CDK_MINTD_PID=\"$CDK_MINTD_PID\"" >> "$ENV_FILE" +echo "export CDK_MINTD_LND_PID=\"$CDK_MINTD_LND_PID\"" >> "$ENV_FILE" +echo "export CDK_REGTEST_PID=\"$CDK_REGTEST_PID\"" >> "$ENV_FILE" + +echo +echo "==============================================" +echo "🎉 CDK Regtest Environment is Ready!" +echo "==============================================" +echo +echo "Network Information:" +echo " • Bitcoin RPC: 127.0.0.1:18443 (user: testuser, pass: testpass)" +echo " • CLN Node 1: $CDK_ITESTS_DIR/cln/one/regtest/lightning-rpc" +echo " • CLN Node 2: $CDK_ITESTS_DIR/cln/two/regtest/lightning-rpc" +echo " • LND Node 1: https://localhost:10009" +echo " • LND Node 2: https://localhost:10010" +echo +echo "CDK Mints:" +echo " • CLN Mint: $CDK_TEST_MINT_URL" +echo " • LND Mint: $CDK_TEST_MINT_URL_2" +echo +echo "Files and Directories:" +echo " • Working Directory: $CDK_ITESTS_DIR" +echo " • CLN Mint Logs: $CDK_ITESTS_DIR/cln_mint/mintd.log" +echo " • LND Mint Logs: $CDK_ITESTS_DIR/lnd_mint/mintd.log" +echo " • LND 1 TLS Cert: $CDK_ITESTS_DIR/lnd/one/tls.cert" +echo " • LND 1 Macaroon: $CDK_ITESTS_DIR/lnd/one/data/chain/bitcoin/regtest/admin.macaroon" +echo " • LND 2 TLS Cert: $CDK_ITESTS_DIR/lnd/two/tls.cert" +echo " • LND 2 Macaroon: $CDK_ITESTS_DIR/lnd/two/data/chain/bitcoin/regtest/admin.macaroon" +echo +echo "Environment Variables (available in other terminals):" +echo " • CDK_TEST_MINT_URL=\"$CDK_TEST_MINT_URL\"" +echo " • CDK_TEST_MINT_URL_2=\"$CDK_TEST_MINT_URL_2\"" +echo " • CDK_ITESTS_DIR=\"$CDK_ITESTS_DIR\"" +echo +echo "You can now:" +echo " • Use 'just' commands in other terminals: 'just ln-cln1 getinfo'" +echo " • Run integration tests: 'just mint-test' or 'cargo test -p cdk-integration-tests'" +echo " • Use CDK CLI tools with the mint URLs above" +echo " • Interact with Lightning nodes directly" +echo " • Access Bitcoin regtest node" +echo +echo "State File: /tmp/cdk_regtest_env (allows other terminals to find this environment)" +echo +echo "Starting mprocs to monitor logs..." +echo "Press 'q' to quit mprocs and stop the environment" +echo "==============================================" + +# Create mprocs configuration +MPROCS_CONFIG="$CDK_ITESTS_DIR/mprocs.yaml" +cat > "$MPROCS_CONFIG" << EOF +procs: + cln-mint: + shell: "touch $CDK_ITESTS_DIR/cln_mint/mintd.log && tail -f $CDK_ITESTS_DIR/cln_mint/mintd.log" + autostart: true + + lnd-mint: + shell: "touch $CDK_ITESTS_DIR/lnd_mint/mintd.log && tail -f $CDK_ITESTS_DIR/lnd_mint/mintd.log" + autostart: true + + bitcoind: + shell: "touch $CDK_ITESTS_DIR/bitcoin/regtest/debug.log && tail -f $CDK_ITESTS_DIR/bitcoin/regtest/debug.log" + autostart: true + + cln-one: + shell: "while [ ! -f $CDK_ITESTS_DIR/cln/one/regtest/log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/cln/one/regtest/log" + autostart: true + + cln-two: + shell: "while [ ! -f $CDK_ITESTS_DIR/cln/two/regtest/log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/cln/two/regtest/log" + autostart: true + + lnd-one: + shell: "while [ ! -f $CDK_ITESTS_DIR/lnd/one/logs/bitcoin/regtest/lnd.log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/lnd/one/logs/bitcoin/regtest/lnd.log" + autostart: true + + lnd-two: + shell: "while [ ! -f $CDK_ITESTS_DIR/lnd/two/logs/bitcoin/regtest/lnd.log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/lnd/two/logs/bitcoin/regtest/lnd.log" + autostart: true + +settings: + mouse_scroll_speed: 3 + proc_list_width: 20 + hide_keymap_window: false +EOF + +# Wait a bit for log files to be created +sleep 2 + +# Start mprocs to show all logs +if command -v mprocs >/dev/null 2>&1; then + cd "$CDK_ITESTS_DIR" + mprocs --config "$MPROCS_CONFIG" +else + echo "⚠️ mprocs not found. Install it with: cargo install mprocs" + echo "Falling back to simple wait loop..." + echo "Press Ctrl+C to stop the environment" + # Keep the script running + while true; do + sleep 1 + done +fi diff --git a/misc/interactive_regtest_mprocs.sh b/misc/interactive_regtest_mprocs.sh new file mode 100755 index 00000000..8f486fb6 --- /dev/null +++ b/misc/interactive_regtest_mprocs.sh @@ -0,0 +1,320 @@ +#!/usr/bin/env bash + +# Interactive Regtest Environment for CDK with Direct Process Management +# This script sets up mprocs to manage the mint processes directly + +set -e + +# Function to wait for HTTP endpoint +wait_for_endpoint() { + local url=$1 + local timeout=${2:-60} + local start_time=$(date +%s) + + while true; do + local current_time=$(date +%s) + local elapsed_time=$((current_time - start_time)) + + if [ $elapsed_time -ge $timeout ]; then + echo "❌ Timeout waiting for $url" + return 1 + fi + + local http_status=$(curl -o /dev/null -s -w "%{http_code}" "$url" 2>/dev/null || echo "000") + + if [ "$http_status" -eq 200 ]; then + echo "✓ $url is ready" + return 0 + fi + + sleep 2 + done +} + +# Function to perform cleanup +cleanup() { + echo "Cleaning up..." + + # Remove state file for other sessions + rm -f "/tmp/cdk_regtest_env" + + if [ ! -z "$CDK_REGTEST_PID" ] && kill -0 $CDK_REGTEST_PID 2>/dev/null; then + echo "Killing the cdk regtest" + kill -2 $CDK_REGTEST_PID + wait $CDK_REGTEST_PID + fi + + echo "Environment terminated" + + # Remove the temporary directory + if [ ! -z "$CDK_ITESTS_DIR" ]; then + rm -rf "$CDK_ITESTS_DIR" + echo "Temp directory removed: $CDK_ITESTS_DIR" + fi + + # Unset all environment variables + unset CDK_ITESTS_DIR + unset CDK_ITESTS_MINT_ADDR + unset CDK_ITESTS_MINT_PORT_0 + unset CDK_ITESTS_MINT_PORT_1 + unset CDK_MINTD_DATABASE + unset CDK_TEST_MINT_URL + unset CDK_TEST_MINT_URL_2 + unset CDK_REGTEST_PID + unset RUST_BACKTRACE + unset CDK_TEST_REGTEST +} + +# Set up trap to call cleanup on script exit +trap cleanup EXIT + +export CDK_TEST_REGTEST=1 + +# Check for mprocs and offer to install if missing +if ! command -v mprocs >/dev/null 2>&1; then + echo "⚠️ mprocs not found - this tool is required for direct process management" + echo "Install it with: cargo install mprocs" + echo + read -p "Would you like to install mprocs now? (y/n): " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + echo "Installing mprocs..." + cargo install mprocs + if [ $? -eq 0 ]; then + echo "✓ mprocs installed successfully" + else + echo "❌ Failed to install mprocs." + exit 1 + fi + else + echo "❌ mprocs is required for this mode. Exiting." + exit 1 + fi + echo +fi + +# Parse command line arguments +CDK_MINTD_DATABASE=${1:-"sqlite"} # Default to sqlite if not specified + +# Create a temporary directory +export CDK_ITESTS_DIR=$(mktemp -d) +export CDK_ITESTS_MINT_ADDR="127.0.0.1" +export CDK_ITESTS_MINT_PORT_0=8085 +export CDK_ITESTS_MINT_PORT_1=8087 + +# Check if the temporary directory was created successfully +if [[ ! -d "$CDK_ITESTS_DIR" ]]; then + echo "Failed to create temp directory" + exit 1 +fi + +echo "==============================================" +echo "Starting CDK Regtest with Direct Process Management" +echo "==============================================" +echo "Temp directory: $CDK_ITESTS_DIR" +echo "Database type: $CDK_MINTD_DATABASE" +echo + +export CDK_MINTD_DATABASE="$CDK_MINTD_DATABASE" + +# Build the necessary binaries +echo "Building binaries..." +cargo build -p cdk-integration-tests --bin start_regtest +cargo build --bin cdk-mintd + +echo "Starting regtest network (Bitcoin + Lightning nodes)..." +cargo run --bin start_regtest & +export CDK_REGTEST_PID=$! + +# Create named pipe for progress tracking +mkfifo "$CDK_ITESTS_DIR/progress_pipe" +rm -f "$CDK_ITESTS_DIR/signal_received" + +# Start reading from pipe in background +(while read line; do + case "$line" in + "checkpoint1") + echo "✓ Regtest network is ready" + touch "$CDK_ITESTS_DIR/signal_received" + exit 0 + ;; + esac +done < "$CDK_ITESTS_DIR/progress_pipe") & + +# Wait for regtest setup (up to 120 seconds) +echo "Waiting for regtest network to be ready..." +for ((i=0; i<120; i++)); do + if [ -f "$CDK_ITESTS_DIR/signal_received" ]; then + break + fi + sleep 1 +done + +if [ ! -f "$CDK_ITESTS_DIR/signal_received" ]; then + echo "❌ Timeout waiting for regtest network" + exit 1 +fi + +# Create work directories for mints +mkdir -p "$CDK_ITESTS_DIR/cln_mint" +mkdir -p "$CDK_ITESTS_DIR/lnd_mint" + +# Set environment variables for easy access +export CDK_TEST_MINT_URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_0" +export CDK_TEST_MINT_URL_2="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_1" + +# Create state file for other terminal sessions +ENV_FILE="/tmp/cdk_regtest_env" +echo "export CDK_ITESTS_DIR=\"$CDK_ITESTS_DIR\"" > "$ENV_FILE" +echo "export CDK_TEST_MINT_URL=\"$CDK_TEST_MINT_URL\"" >> "$ENV_FILE" +echo "export CDK_TEST_MINT_URL_2=\"$CDK_TEST_MINT_URL_2\"" >> "$ENV_FILE" +echo "export CDK_REGTEST_PID=\"$CDK_REGTEST_PID\"" >> "$ENV_FILE" + +# Get the project root directory (where justfile is located) +PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +# Create environment setup scripts for mprocs to use +cat > "$CDK_ITESTS_DIR/start_cln_mint.sh" << EOF +#!/usr/bin/env bash +cd "$PROJECT_ROOT" +export CDK_MINTD_CLN_RPC_PATH="$CDK_ITESTS_DIR/cln/one/regtest/lightning-rpc" +export CDK_MINTD_URL="http://127.0.0.1:8085" +export CDK_MINTD_WORK_DIR="$CDK_ITESTS_DIR/cln_mint" +export CDK_MINTD_LISTEN_HOST="127.0.0.1" +export CDK_MINTD_LISTEN_PORT=8085 +export CDK_MINTD_LN_BACKEND="cln" +export CDK_MINTD_MNEMONIC="eye survey guilt napkin crystal cup whisper salt luggage manage unveil loyal" +export RUST_BACKTRACE=1 +export CDK_MINTD_DATABASE="$CDK_MINTD_DATABASE" + +echo "Starting CLN Mint on port 8085..." +echo "Project root: $PROJECT_ROOT" +echo "Working directory: \$CDK_MINTD_WORK_DIR" +echo "CLN RPC path: \$CDK_MINTD_CLN_RPC_PATH" +echo "Database type: \$CDK_MINTD_DATABASE" +echo "---" + +exec cargo run --bin cdk-mintd +EOF + +cat > "$CDK_ITESTS_DIR/start_lnd_mint.sh" << EOF +#!/usr/bin/env bash +cd "$PROJECT_ROOT" +export CDK_MINTD_LND_ADDRESS="https://localhost:10010" +export CDK_MINTD_LND_CERT_FILE="$CDK_ITESTS_DIR/lnd/two/tls.cert" +export CDK_MINTD_LND_MACAROON_FILE="$CDK_ITESTS_DIR/lnd/two/data/chain/bitcoin/regtest/admin.macaroon" +export CDK_MINTD_URL="http://127.0.0.1:8087" +export CDK_MINTD_WORK_DIR="$CDK_ITESTS_DIR/lnd_mint" +export CDK_MINTD_LISTEN_HOST="127.0.0.1" +export CDK_MINTD_LISTEN_PORT=8087 +export CDK_MINTD_LN_BACKEND="lnd" +export CDK_MINTD_MNEMONIC="cattle gold bind busy sound reduce tone addict baby spend february strategy" +export RUST_BACKTRACE=1 +export CDK_MINTD_DATABASE="$CDK_MINTD_DATABASE" + +echo "Starting LND Mint on port 8087..." +echo "Project root: $PROJECT_ROOT" +echo "Working directory: \$CDK_MINTD_WORK_DIR" +echo "LND address: \$CDK_MINTD_LND_ADDRESS" +echo "Database type: \$CDK_MINTD_DATABASE" +echo "---" + +exec cargo run --bin cdk-mintd +EOF + +# Make scripts executable +chmod +x "$CDK_ITESTS_DIR/start_cln_mint.sh" +chmod +x "$CDK_ITESTS_DIR/start_lnd_mint.sh" + +echo +echo "==============================================" +echo "🎉 CDK Regtest Environment is Ready!" +echo "==============================================" +echo +echo "Network Information:" +echo " • Bitcoin RPC: 127.0.0.1:18443 (user: testuser, pass: testpass)" +echo " • CLN Node 1: $CDK_ITESTS_DIR/cln/one/regtest/lightning-rpc" +echo " • CLN Node 2: $CDK_ITESTS_DIR/cln/two/regtest/lightning-rpc" +echo " • LND Node 1: https://localhost:10009" +echo " • LND Node 2: https://localhost:10010" +echo +echo "CDK Mints (will be managed by mprocs):" +echo " • CLN Mint: $CDK_TEST_MINT_URL" +echo " • LND Mint: $CDK_TEST_MINT_URL_2" +echo +echo "Files and Directories:" +echo " • Working Directory: $CDK_ITESTS_DIR" +echo " • Start Scripts: $CDK_ITESTS_DIR/start_{cln,lnd}_mint.sh" +echo +echo "Environment Variables (available in other terminals):" +echo " • CDK_TEST_MINT_URL=\"$CDK_TEST_MINT_URL\"" +echo " • CDK_TEST_MINT_URL_2=\"$CDK_TEST_MINT_URL_2\"" +echo " • CDK_ITESTS_DIR=\"$CDK_ITESTS_DIR\"" +echo +echo "Starting mprocs with direct process management..." +echo +echo "In mprocs you can:" +echo " • 's' to start a process" +echo " • 'k' to kill a process" +echo " • 'r' to restart a process" +echo " • 'Enter' to focus on a process" +echo " • 'q' to quit and stop the environment" +echo "==============================================" + +# Wait a moment for everything to settle +sleep 2 + +# Create mprocs configuration with direct process management +MPROCS_CONFIG="$CDK_ITESTS_DIR/mprocs.yaml" +cat > "$MPROCS_CONFIG" << EOF +procs: + cln-mint: + shell: "$CDK_ITESTS_DIR/start_cln_mint.sh" + autostart: false + env: + CDK_ITESTS_DIR: "$CDK_ITESTS_DIR" + CDK_MINTD_DATABASE: "$CDK_MINTD_DATABASE" + + lnd-mint: + shell: "$CDK_ITESTS_DIR/start_lnd_mint.sh" + autostart: false + env: + CDK_ITESTS_DIR: "$CDK_ITESTS_DIR" + CDK_MINTD_DATABASE: "$CDK_MINTD_DATABASE" + + bitcoind: + shell: "while [ ! -f $CDK_ITESTS_DIR/bitcoin/regtest/debug.log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/bitcoin/regtest/debug.log" + autostart: true + + cln-one: + shell: "while [ ! -f $CDK_ITESTS_DIR/cln/one/regtest/log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/cln/one/regtest/log" + autostart: true + + cln-two: + shell: "while [ ! -f $CDK_ITESTS_DIR/cln/two/regtest/log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/cln/two/regtest/log" + autostart: true + + lnd-one: + shell: "while [ ! -f $CDK_ITESTS_DIR/lnd/one/logs/bitcoin/regtest/lnd.log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/lnd/one/logs/bitcoin/regtest/lnd.log" + autostart: true + + lnd-two: + shell: "while [ ! -f $CDK_ITESTS_DIR/lnd/two/logs/bitcoin/regtest/lnd.log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/lnd/two/logs/bitcoin/regtest/lnd.log" + autostart: true + +settings: + mouse_scroll_speed: 3 + proc_list_width: 20 + hide_keymap_window: false + keymap_procs: + toggle_process: 's' + kill_process: 'k' + restart_process: 'r' + focus_process: 'Enter' + show_keymap: '?' +EOF + +# Start mprocs with direct process management +echo "Starting mprocs..." +cd "$CDK_ITESTS_DIR" +mprocs --config "$MPROCS_CONFIG" diff --git a/misc/regtest_helper.sh b/misc/regtest_helper.sh new file mode 100755 index 00000000..c0442c41 --- /dev/null +++ b/misc/regtest_helper.sh @@ -0,0 +1,421 @@ +#!/usr/bin/env bash + +# Helper script for interacting with CDK regtest environment +# Run this after starting interactive_regtest.sh + +# Check for environment state file first, then environment variable +ENV_FILE="/tmp/cdk_regtest_env" +if [ -f "$ENV_FILE" ]; then + source "$ENV_FILE" +elif [ ! -z "$CDK_ITESTS_DIR" ]; then + # Environment variable is set, create state file for other sessions + echo "export CDK_ITESTS_DIR=\"$CDK_ITESTS_DIR\"" > "$ENV_FILE" + echo "export CDK_TEST_MINT_URL=\"$CDK_TEST_MINT_URL\"" >> "$ENV_FILE" + echo "export CDK_TEST_MINT_URL_2=\"$CDK_TEST_MINT_URL_2\"" >> "$ENV_FILE" + echo "export CDK_MINTD_PID=\"$CDK_MINTD_PID\"" >> "$ENV_FILE" + echo "export CDK_MINTD_LND_PID=\"$CDK_MINTD_LND_PID\"" >> "$ENV_FILE" + echo "export CDK_REGTEST_PID=\"$CDK_REGTEST_PID\"" >> "$ENV_FILE" +else + echo "❌ CDK regtest environment not found!" + echo "Please run './misc/interactive_regtest.sh' or 'just regtest' first" + exit 1 +fi + +# Validate that the environment is actually running +if [ -z "$CDK_ITESTS_DIR" ] || [ ! -d "$CDK_ITESTS_DIR" ]; then + echo "❌ CDK regtest environment not found or directory missing!" + echo "Please run './misc/interactive_regtest.sh' or 'just regtest' first" + [ -f "$ENV_FILE" ] && rm "$ENV_FILE" # Clean up stale state file + exit 1 +fi + +show_help() { + echo "CDK Regtest Environment Helper" + echo "=============================" + echo + echo "Lightning Node Commands:" + echo " ln-cln1 - Execute command on CLN node 1" + echo " ln-cln2 - Execute command on CLN node 2" + echo " ln-lnd1 - Execute command on LND node 1" + echo " ln-lnd2 - Execute command on LND node 2" + echo + echo "Bitcoin Commands:" + echo " btc - Execute bitcoin-cli command" + echo " btc-mine [blocks] - Mine blocks (default: 10)" + echo + echo "CDK Mint Commands:" + echo " mint-info - Show mint information" + echo " mint-test - Run integration tests" + echo " restart-mints - Stop, recompile, and restart both mints (log mode)" + echo + echo "Environment Commands:" + echo " show-env - Show environment variables" + echo " show-logs - Show recent mint logs" + echo " show-status - Show status of all components" + echo " logs - Start mprocs TUI (adapts to current mode)" + echo + echo "Environment Modes:" + echo " just regtest - Log tailing mode (mints auto-start, logs to files)" + echo " just regtest-mprocs - Direct management (mprocs controls mint processes)" + echo + echo "Examples:" + echo " $0 ln-cln1 getinfo" + echo " $0 ln-lnd1 getinfo" + echo " $0 btc getblockcount" + echo " $0 btc-mine 5" + echo " $0 mint-info" + echo " $0 restart-mints # Only works in log tailing mode" + echo " $0 logs # Start mprocs viewer" +} + +# Bitcoin commands +btc_command() { + bitcoin-cli -regtest -rpcuser=testuser -rpcpassword=testpass -rpcport=18443 "$@" +} + +btc_mine() { + local blocks=${1:-10} + local address=$(btc_command getnewaddress) + btc_command generatetoaddress "$blocks" "$address" + echo "Mined $blocks blocks" +} + +# CLN commands +cln_command() { + local node=$1 + shift + lightning-cli --rpc-file="$CDK_ITESTS_DIR/cln/$node/regtest/lightning-rpc" "$@" +} + +# LND commands +lnd_command() { + local node=$1 + shift + local port + case $node in + "one") port=10009 ;; + "two") port=10010 ;; + *) echo "Unknown LND node: $node"; return 1 ;; + esac + + lncli --rpcserver=localhost:$port \ + --tlscertpath="$CDK_ITESTS_DIR/lnd/$node/tls.cert" \ + --macaroonpath="$CDK_ITESTS_DIR/lnd/$node/data/chain/bitcoin/regtest/admin.macaroon" \ + "$@" +} + +# Mint commands +mint_info() { + echo "CLN Mint (Port 8085):" + curl -s "$CDK_TEST_MINT_URL/v1/info" | jq . 2>/dev/null || curl -s "$CDK_TEST_MINT_URL/v1/info" + echo + echo "LND Mint (Port 8087):" + curl -s "$CDK_TEST_MINT_URL_2/v1/info" | jq . 2>/dev/null || curl -s "$CDK_TEST_MINT_URL_2/v1/info" +} + +mint_test() { + echo "Running integration tests..." + cargo test -p cdk-integration-tests +} + +# Environment info +show_env() { + echo "CDK Regtest Environment Variables:" + echo "=================================" + echo "CDK_ITESTS_DIR=$CDK_ITESTS_DIR" + echo "CDK_TEST_MINT_URL=$CDK_TEST_MINT_URL" + echo "CDK_TEST_MINT_URL_2=$CDK_TEST_MINT_URL_2" + echo "CDK_MINTD_PID=$CDK_MINTD_PID" + echo "CDK_MINTD_LND_PID=$CDK_MINTD_LND_PID" + echo "CDK_REGTEST_PID=$CDK_REGTEST_PID" +} + +show_logs() { + echo "=== Recent CLN Mint Logs ===" + if [ -f "$CDK_ITESTS_DIR/cln_mint/mintd.log" ]; then + tail -10 "$CDK_ITESTS_DIR/cln_mint/mintd.log" + else + echo "Log file not found" + fi + echo + echo "=== Recent LND Mint Logs ===" + if [ -f "$CDK_ITESTS_DIR/lnd_mint/mintd.log" ]; then + tail -10 "$CDK_ITESTS_DIR/lnd_mint/mintd.log" + else + echo "Log file not found" + fi +} + +start_mprocs() { + echo "Starting mprocs log viewer..." + + if ! command -v mprocs >/dev/null 2>&1; then + echo "❌ mprocs not found! Please install it with:" + echo " cargo install mprocs" + echo " or your package manager" + return 1 + fi + + # Check if we have the direct process management config + DIRECT_MPROCS_CONFIG="$CDK_ITESTS_DIR/mprocs.yaml" + FALLBACK_MPROCS_CONFIG="$CDK_ITESTS_DIR/mprocs_fallback.yaml" + + if [ -f "$DIRECT_MPROCS_CONFIG" ]; then + echo "Using direct process management mode..." + echo "In mprocs: 's' to start, 'k' to kill, 'r' to restart processes" + cd "$CDK_ITESTS_DIR" + mprocs --config "$DIRECT_MPROCS_CONFIG" + return + fi + + # Create fallback mprocs configuration for log tailing + cat > "$FALLBACK_MPROCS_CONFIG" << EOF +procs: + cln-mint: + shell: "touch $CDK_ITESTS_DIR/cln_mint/mintd.log && tail -f $CDK_ITESTS_DIR/cln_mint/mintd.log" + autostart: true + + lnd-mint: + shell: "touch $CDK_ITESTS_DIR/lnd_mint/mintd.log && tail -f $CDK_ITESTS_DIR/lnd_mint/mintd.log" + autostart: true + + bitcoind: + shell: "touch $CDK_ITESTS_DIR/bitcoin/regtest/debug.log && tail -f $CDK_ITESTS_DIR/bitcoin/regtest/debug.log" + autostart: true + + cln-one: + shell: "while [ ! -f $CDK_ITESTS_DIR/cln/one/regtest/log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/cln/one/regtest/log" + autostart: true + + cln-two: + shell: "while [ ! -f $CDK_ITESTS_DIR/cln/two/regtest/log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/cln/two/regtest/log" + autostart: true + + lnd-one: + shell: "while [ ! -f $CDK_ITESTS_DIR/lnd/one/logs/bitcoin/regtest/lnd.log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/lnd/one/logs/bitcoin/regtest/lnd.log" + autostart: true + + lnd-two: + shell: "while [ ! -f $CDK_ITESTS_DIR/lnd/two/logs/bitcoin/regtest/lnd.log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/lnd/two/logs/bitcoin/regtest/lnd.log" + autostart: true + +settings: + mouse_scroll_speed: 3 + proc_list_width: 20 + hide_keymap_window: false +EOF + + echo "Using log tailing mode..." + echo "Use 'q' to quit the log viewer" + cd "$CDK_ITESTS_DIR" + mprocs --config "$FALLBACK_MPROCS_CONFIG" +} + +show_status() { + echo "CDK Regtest Environment Status:" + echo "===============================" + + # Check processes + echo "Processes:" + if [ ! -z "$CDK_REGTEST_PID" ] && kill -0 $CDK_REGTEST_PID 2>/dev/null; then + echo " ✓ Regtest network (PID: $CDK_REGTEST_PID)" + else + echo " ❌ Regtest network" + fi + + if [ ! -z "$CDK_MINTD_PID" ] && kill -0 $CDK_MINTD_PID 2>/dev/null; then + echo " ✓ CLN Mint (PID: $CDK_MINTD_PID)" + else + echo " ❌ CLN Mint" + fi + + if [ ! -z "$CDK_MINTD_LND_PID" ] && kill -0 $CDK_MINTD_LND_PID 2>/dev/null; then + echo " ✓ LND Mint (PID: $CDK_MINTD_LND_PID)" + else + echo " ❌ LND Mint" + fi + + echo + echo "Network connectivity:" + if curl -s "$CDK_TEST_MINT_URL/v1/info" >/dev/null 2>&1; then + echo " ✓ CLN Mint responding" + else + echo " ❌ CLN Mint not responding" + fi + + if curl -s "$CDK_TEST_MINT_URL_2/v1/info" >/dev/null 2>&1; then + echo " ✓ LND Mint responding" + else + echo " ❌ LND Mint not responding" + fi +} + +restart_mints() { + echo "===============================" + echo "Restarting CDK Mints" + echo "===============================" + + # Stop existing mints + echo "Stopping existing mints..." + if [ ! -z "$CDK_MINTD_PID" ] && kill -0 $CDK_MINTD_PID 2>/dev/null; then + echo " Stopping CLN Mint (PID: $CDK_MINTD_PID)" + kill -2 $CDK_MINTD_PID + wait $CDK_MINTD_PID 2>/dev/null || true + fi + + if [ ! -z "$CDK_MINTD_LND_PID" ] && kill -0 $CDK_MINTD_LND_PID 2>/dev/null; then + echo " Stopping LND Mint (PID: $CDK_MINTD_LND_PID)" + kill -2 $CDK_MINTD_LND_PID + wait $CDK_MINTD_LND_PID 2>/dev/null || true + fi + + # Recompile + echo "Recompiling cdk-mintd..." + if ! cargo build --bin cdk-mintd; then + echo "❌ Compilation failed" + return 1 + fi + echo "✓ Compilation successful" + + # Restart CLN mint + echo "Starting CLN Mint..." + export CDK_MINTD_CLN_RPC_PATH="$CDK_ITESTS_DIR/cln/one/regtest/lightning-rpc" + export CDK_MINTD_URL="http://127.0.0.1:8085" + export CDK_MINTD_WORK_DIR="$CDK_ITESTS_DIR/cln_mint" + export CDK_MINTD_LISTEN_HOST="127.0.0.1" + export CDK_MINTD_LISTEN_PORT=8085 + export CDK_MINTD_LN_BACKEND="cln" + export CDK_MINTD_MNEMONIC="eye survey guilt napkin crystal cup whisper salt luggage manage unveil loyal" + export RUST_BACKTRACE=1 + + cargo run --bin cdk-mintd > "$CDK_MINTD_WORK_DIR/mintd.log" 2>&1 & + NEW_CLN_PID=$! + + # Wait for CLN mint to be ready + echo "Waiting for CLN mint to start..." + local start_time=$(date +%s) + while true; do + local current_time=$(date +%s) + local elapsed_time=$((current_time - start_time)) + + if [ $elapsed_time -ge 30 ]; then + echo "❌ Timeout waiting for CLN mint" + return 1 + fi + + if curl -s "http://127.0.0.1:8085/v1/info" >/dev/null 2>&1; then + echo "✓ CLN Mint ready" + break + fi + sleep 1 + done + + # Restart LND mint + echo "Starting LND Mint..." + export CDK_MINTD_LND_ADDRESS="https://localhost:10010" + export CDK_MINTD_LND_CERT_FILE="$CDK_ITESTS_DIR/lnd/two/tls.cert" + export CDK_MINTD_LND_MACAROON_FILE="$CDK_ITESTS_DIR/lnd/two/data/chain/bitcoin/regtest/admin.macaroon" + export CDK_MINTD_URL="http://127.0.0.1:8087" + export CDK_MINTD_WORK_DIR="$CDK_ITESTS_DIR/lnd_mint" + export CDK_MINTD_LISTEN_HOST="127.0.0.1" + export CDK_MINTD_LISTEN_PORT=8087 + export CDK_MINTD_LN_BACKEND="lnd" + export CDK_MINTD_MNEMONIC="cattle gold bind busy sound reduce tone addict baby spend february strategy" + + cargo run --bin cdk-mintd > "$CDK_MINTD_WORK_DIR/mintd.log" 2>&1 & + NEW_LND_PID=$! + + # Wait for LND mint to be ready + echo "Waiting for LND mint to start..." + start_time=$(date +%s) + while true; do + current_time=$(date +%s) + elapsed_time=$((current_time - start_time)) + + if [ $elapsed_time -ge 30 ]; then + echo "❌ Timeout waiting for LND mint" + return 1 + fi + + if curl -s "http://127.0.0.1:8087/v1/info" >/dev/null 2>&1; then + echo "✓ LND Mint ready" + break + fi + sleep 1 + done + + # Update PIDs in state file + CDK_MINTD_PID=$NEW_CLN_PID + CDK_MINTD_LND_PID=$NEW_LND_PID + + # Update state file + echo "export CDK_ITESTS_DIR=\"$CDK_ITESTS_DIR\"" > "$ENV_FILE" + echo "export CDK_TEST_MINT_URL=\"$CDK_TEST_MINT_URL\"" >> "$ENV_FILE" + echo "export CDK_TEST_MINT_URL_2=\"$CDK_TEST_MINT_URL_2\"" >> "$ENV_FILE" + echo "export CDK_MINTD_PID=\"$CDK_MINTD_PID\"" >> "$ENV_FILE" + echo "export CDK_MINTD_LND_PID=\"$CDK_MINTD_LND_PID\"" >> "$ENV_FILE" + echo "export CDK_REGTEST_PID=\"$CDK_REGTEST_PID\"" >> "$ENV_FILE" + + echo + echo "✅ Mints restarted successfully!" + echo " CLN Mint: http://127.0.0.1:8085 (PID: $CDK_MINTD_PID)" + echo " LND Mint: http://127.0.0.1:8087 (PID: $CDK_MINTD_LND_PID)" + echo "===============================" +} + +# Main command dispatcher +case "$1" in + "ln-cln1") + shift + cln_command "one" "$@" + ;; + "ln-cln2") + shift + cln_command "two" "$@" + ;; + "ln-lnd1") + shift + lnd_command "one" "$@" + ;; + "ln-lnd2") + shift + lnd_command "two" "$@" + ;; + "btc") + shift + btc_command "$@" + ;; + "btc-mine") + shift + btc_mine "$@" + ;; + "mint-info") + mint_info + ;; + "mint-test") + mint_test + ;; + "restart-mints") + restart_mints + ;; + "show-env") + show_env + ;; + "show-logs") + show_logs + ;; + "show-status") + show_status + ;; + "logs") + start_mprocs + ;; + "help"|"-h"|"--help"|"") + show_help + ;; + *) + echo "Unknown command: $1" + echo "Run '$0 help' for available commands" + exit 1 + ;; +esac From e76b53a6372ea7ece9535e1365e15bfcdc5ef95e Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Tue, 8 Jul 2025 11:03:40 +0100 Subject: [PATCH 2/4] feat: mprocs inter only regtest --- MINT_RESTART_FEATURE.md | 86 -------- justfile | 5 - misc/README.md | 10 +- misc/interactive_regtest.sh | 330 ----------------------------- misc/interactive_regtest_mprocs.sh | 4 +- misc/regtest_helper.sh | 6 +- 6 files changed, 10 insertions(+), 431 deletions(-) delete mode 100644 MINT_RESTART_FEATURE.md delete mode 100755 misc/interactive_regtest.sh diff --git a/MINT_RESTART_FEATURE.md b/MINT_RESTART_FEATURE.md deleted file mode 100644 index 0a6180a3..00000000 --- a/MINT_RESTART_FEATURE.md +++ /dev/null @@ -1,86 +0,0 @@ -# Mint Restart Feature - -A new command has been added to restart the CDK mints after recompiling, perfect for development workflows when you're making changes to the mint code. - -## Command - -```bash -just restart-mints -``` - -or - -```bash -./misc/regtest_helper.sh restart-mints -``` - -## What It Does - -1. **Stops** both running mints (CLN and LND mints) -2. **Recompiles** the `cdk-mintd` binary with your latest changes -3. **Restarts** both mints with the same configuration -4. **Waits** for both mints to be ready and responding -5. **Updates** the state file with new process IDs - -## Development Workflow - -### Before this feature: -```bash -# Terminal 1: Start environment -just regtest - -# Terminal 2: Make code changes, then manually restart everything -# Ctrl+C in Terminal 1 (stops entire environment including Lightning network) -just regtest # Start everything again (slow) -``` - -### With this feature: -```bash -# Terminal 1: Start environment (once) -just regtest - -# Terminal 2: Make code changes, then quickly restart just the mints -just restart-mints # Fast! Keeps Lightning network running -just mint-test # Test your changes -``` - -## Benefits - -1. **Faster Development Cycle** - No need to restart the entire Lightning network -2. **Preserves Network State** - Bitcoin blockchain, Lightning channels, and node states remain intact -3. **Automatic Recompilation** - No need to manually run `cargo build` -4. **Status Validation** - Ensures mints are responding before completing -5. **State Management** - Updates process IDs for other commands to work correctly - -## Example Output - -``` -=============================== -Restarting CDK Mints -=============================== -Stopping existing mints... - Stopping CLN Mint (PID: 12345) - Stopping LND Mint (PID: 12346) -Recompiling cdk-mintd... -✓ Compilation successful -Starting CLN Mint... -Waiting for CLN mint to start... -✓ CLN Mint ready -Starting LND Mint... -Waiting for LND mint to start... -✓ LND Mint ready - -✅ Mints restarted successfully! - CLN Mint: http://127.0.0.1:8085 (PID: 54321) - LND Mint: http://127.0.0.1:8087 (PID: 54322) -=============================== -``` - -## Use Cases - -- **Testing mint code changes** without restarting the entire regtest environment -- **Debugging mint behavior** with fresh mint instances -- **Performance testing** with clean mint state but preserved Lightning network -- **Integration testing** after mint code modifications - -This feature makes the development experience much smoother when working on CDK mint functionality! diff --git a/justfile b/justfile index 7c403f97..fe4b0f31 100644 --- a/justfile +++ b/justfile @@ -155,11 +155,6 @@ nutshell-wallet-itest: # Start interactive regtest environment (Bitcoin + 4 LN nodes + 2 CDK mints) regtest db="sqlite": - #!/usr/bin/env bash - ./misc/interactive_regtest.sh {{db}} - -# Start regtest with direct process management via mprocs (lets you start/stop mints) -regtest-mprocs db="sqlite": #!/usr/bin/env bash ./misc/interactive_regtest_mprocs.sh {{db}} diff --git a/misc/README.md b/misc/README.md index 51b19c35..a61e3242 100644 --- a/misc/README.md +++ b/misc/README.md @@ -4,7 +4,7 @@ This directory contains scripts for setting up and interacting with a CDK regtes ## Scripts -### 1. `interactive_regtest.sh` +### 1. `interactive_regtest_mprocs.sh` Sets up a complete regtest environment with: - Bitcoin regtest node - 2 CLN (Core Lightning) nodes with channels @@ -52,7 +52,7 @@ Helper script providing convenient commands to interact with the running regtest 1. **Start the regtest environment:** ```bash - ./misc/interactive_regtest.sh [database_type] + ./misc/interactive_regtest_mprocs.sh [database_type] ``` - `database_type`: Optional, defaults to "sqlite". Can be "sqlite" or "redb" - The script will build necessary binaries and set up the full environment @@ -67,7 +67,7 @@ Helper script providing convenient commands to interact with the running regtest The interactive regtest environment uses a state file (`/tmp/cdk_regtest_env`) to share environment information between terminal sessions: -1. When you run `just regtest` or `./misc/interactive_regtest.sh`, it creates the state file with all necessary environment variables +1. When you run `just regtest` or `./misc/interactive_regtest_mprocs.sh`, it creates the state file with all necessary environment variables 2. When you run Lightning node commands in other terminals (e.g., `just ln-cln1 getinfo`), the helper script automatically sources the state file 3. When the environment shuts down (Ctrl+C), it cleans up the state file automatically @@ -198,7 +198,7 @@ $CDK_ITESTS_DIR/ ## Cleanup -- Press `Ctrl+C` in the terminal running `interactive_regtest.sh` +- Press `Ctrl+C` in the terminal running `interactive_regtest_mprocs.sh` - All processes will be terminated and the temporary directory will be cleaned up automatically - No manual cleanup is required @@ -211,7 +211,7 @@ $CDK_ITESTS_DIR/ ### Helper script not working - Ensure the regtest environment is running first -- The `CDK_ITESTS_DIR` environment variable must be set (done automatically by `interactive_regtest.sh`) +- The `CDK_ITESTS_DIR` environment variable must be set (done automatically by `interactive_regtest_mprocs.sh`) ### Connection issues - Use `./misc/regtest_helper.sh show-status` to check component health diff --git a/misc/interactive_regtest.sh b/misc/interactive_regtest.sh deleted file mode 100755 index e38b8fb4..00000000 --- a/misc/interactive_regtest.sh +++ /dev/null @@ -1,330 +0,0 @@ -#!/usr/bin/env bash - -# Interactive Regtest Environment for CDK -# This script sets up the regtest environment and keeps it running for interaction - -set -e - -# Function to wait for HTTP endpoint -wait_for_endpoint() { - local url=$1 - local timeout=${2:-60} - local start_time=$(date +%s) - - while true; do - local current_time=$(date +%s) - local elapsed_time=$((current_time - start_time)) - - if [ $elapsed_time -ge $timeout ]; then - echo "❌ Timeout waiting for $url" - return 1 - fi - - local http_status=$(curl -o /dev/null -s -w "%{http_code}" "$url" 2>/dev/null || echo "000") - - if [ "$http_status" -eq 200 ]; then - echo "✓ $url is ready" - return 0 - fi - - sleep 2 - done -} - -# Function to perform cleanup -cleanup() { - echo "Cleaning up..." - - # Remove state file for other sessions - rm -f "/tmp/cdk_regtest_env" - - if [ ! -z "$CDK_MINTD_PID" ] && kill -0 $CDK_MINTD_PID 2>/dev/null; then - echo "Killing the cdk mintd (CLN)" - kill -2 $CDK_MINTD_PID - wait $CDK_MINTD_PID - fi - - if [ ! -z "$CDK_MINTD_LND_PID" ] && kill -0 $CDK_MINTD_LND_PID 2>/dev/null; then - echo "Killing the cdk mintd (LND)" - kill -2 $CDK_MINTD_LND_PID - wait $CDK_MINTD_LND_PID - fi - - if [ ! -z "$CDK_REGTEST_PID" ] && kill -0 $CDK_REGTEST_PID 2>/dev/null; then - echo "Killing the cdk regtest" - kill -2 $CDK_REGTEST_PID - wait $CDK_REGTEST_PID - fi - - echo "Environment terminated" - - # Remove the temporary directory - if [ ! -z "$CDK_ITESTS_DIR" ]; then - rm -rf "$CDK_ITESTS_DIR" - echo "Temp directory removed: $CDK_ITESTS_DIR" - fi - - # Unset all environment variables - unset CDK_ITESTS_DIR - unset CDK_ITESTS_MINT_ADDR - unset CDK_ITESTS_MINT_PORT_0 - unset CDK_ITESTS_MINT_PORT_1 - unset CDK_MINTD_DATABASE - unset CDK_TEST_MINT_URL - unset CDK_TEST_MINT_URL_2 - unset CDK_MINTD_URL - unset CDK_MINTD_WORK_DIR - unset CDK_MINTD_LISTEN_HOST - unset CDK_MINTD_LISTEN_PORT - unset CDK_MINTD_LN_BACKEND - unset CDK_MINTD_MNEMONIC - unset CDK_MINTD_CLN_RPC_PATH - unset CDK_MINTD_LND_ADDRESS - unset CDK_MINTD_LND_CERT_FILE - unset CDK_MINTD_LND_MACAROON_FILE - unset CDK_MINTD_PID - unset CDK_MINTD_LND_PID - unset CDK_REGTEST_PID - unset RUST_BACKTRACE - unset CDK_TEST_REGTEST -} - -# Set up trap to call cleanup on script exit -trap cleanup EXIT - -export CDK_TEST_REGTEST=1 - -# Check for mprocs and offer to install if missing -if ! command -v mprocs >/dev/null 2>&1; then - echo "⚠️ mprocs not found - this tool provides a nice TUI for monitoring logs" - echo "Install it with: cargo install mprocs" - echo - read -p "Would you like to install mprocs now? (y/n): " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - echo "Installing mprocs..." - cargo install mprocs - if [ $? -eq 0 ]; then - echo "✓ mprocs installed successfully" - else - echo "❌ Failed to install mprocs. You can install it later with: cargo install mprocs" - fi - else - echo "Skipping mprocs installation. The environment will work without it." - fi - echo -fi - -# Parse command line arguments -CDK_MINTD_DATABASE=${1:-"sqlite"} # Default to sqlite if not specified - -# Create a temporary directory -export CDK_ITESTS_DIR=$(mktemp -d) -export CDK_ITESTS_MINT_ADDR="127.0.0.1" -export CDK_ITESTS_MINT_PORT_0=8085 -export CDK_ITESTS_MINT_PORT_1=8087 - -# Check if the temporary directory was created successfully -if [[ ! -d "$CDK_ITESTS_DIR" ]]; then - echo "Failed to create temp directory" - exit 1 -fi - -echo "==============================================" -echo "Starting Interactive CDK Regtest Environment" -echo "==============================================" -echo "Temp directory: $CDK_ITESTS_DIR" -echo "Database type: $CDK_MINTD_DATABASE" -echo - -export CDK_MINTD_DATABASE="$CDK_MINTD_DATABASE" - -# Build the necessary binaries -echo "Building binaries..." -cargo build -p cdk-integration-tests --bin start_regtest - -echo "Starting regtest network (Bitcoin + Lightning nodes)..." -cargo run --bin start_regtest & -export CDK_REGTEST_PID=$! - -# Create named pipe for progress tracking -mkfifo "$CDK_ITESTS_DIR/progress_pipe" -rm -f "$CDK_ITESTS_DIR/signal_received" - -# Start reading from pipe in background -(while read line; do - case "$line" in - "checkpoint1") - echo "✓ Regtest network is ready" - touch "$CDK_ITESTS_DIR/signal_received" - exit 0 - ;; - esac -done < "$CDK_ITESTS_DIR/progress_pipe") & - -# Wait for regtest setup (up to 120 seconds) -echo "Waiting for regtest network to be ready..." -for ((i=0; i<120; i++)); do - if [ -f "$CDK_ITESTS_DIR/signal_received" ]; then - break - fi - sleep 1 -done - -if [ ! -f "$CDK_ITESTS_DIR/signal_received" ]; then - echo "❌ Timeout waiting for regtest network" - exit 1 -fi - -echo -echo "Starting CDK Mint #1 (CLN backend)..." -export CDK_MINTD_CLN_RPC_PATH="$CDK_ITESTS_DIR/cln/one/regtest/lightning-rpc" -export CDK_MINTD_URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_0" -export CDK_MINTD_WORK_DIR="$CDK_ITESTS_DIR/cln_mint" -export CDK_MINTD_LISTEN_HOST=$CDK_ITESTS_MINT_ADDR -export CDK_MINTD_LISTEN_PORT=$CDK_ITESTS_MINT_PORT_0 -export CDK_MINTD_LN_BACKEND="cln" -export CDK_MINTD_MNEMONIC="eye survey guilt napkin crystal cup whisper salt luggage manage unveil loyal" -export RUST_BACKTRACE=1 - -mkdir -p "$CDK_MINTD_WORK_DIR" -cargo run --bin cdk-mintd > "$CDK_MINTD_WORK_DIR/mintd.log" 2>&1 & -export CDK_MINTD_PID=$! - -# Wait for CLN mint to be ready -echo "Waiting for CLN mint to be ready..." -URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_0/v1/info" -wait_for_endpoint "$URL" 60 - -echo -echo "Starting CDK Mint #2 (LND backend)..." -export CDK_MINTD_LND_ADDRESS="https://localhost:10010" -export CDK_MINTD_LND_CERT_FILE="$CDK_ITESTS_DIR/lnd/two/tls.cert" -export CDK_MINTD_LND_MACAROON_FILE="$CDK_ITESTS_DIR/lnd/two/data/chain/bitcoin/regtest/admin.macaroon" - -export CDK_MINTD_URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_1" -mkdir -p "$CDK_ITESTS_DIR/lnd_mint" -export CDK_MINTD_WORK_DIR="$CDK_ITESTS_DIR/lnd_mint" -export CDK_MINTD_LISTEN_HOST=$CDK_ITESTS_MINT_ADDR -export CDK_MINTD_LISTEN_PORT=$CDK_ITESTS_MINT_PORT_1 -export CDK_MINTD_LN_BACKEND="lnd" -export CDK_MINTD_MNEMONIC="cattle gold bind busy sound reduce tone addict baby spend february strategy" - -cargo run --bin cdk-mintd > "$CDK_MINTD_WORK_DIR/mintd.log" 2>&1 & -export CDK_MINTD_LND_PID=$! - -# Wait for LND mint to be ready -echo "Waiting for LND mint to be ready..." -URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_1/v1/info" -wait_for_endpoint "$URL" 60 - -# Set environment variables for easy access -export CDK_TEST_MINT_URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_0" -export CDK_TEST_MINT_URL_2="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_1" - -# Create state file for other terminal sessions -ENV_FILE="/tmp/cdk_regtest_env" -echo "export CDK_ITESTS_DIR=\"$CDK_ITESTS_DIR\"" > "$ENV_FILE" -echo "export CDK_TEST_MINT_URL=\"$CDK_TEST_MINT_URL\"" >> "$ENV_FILE" -echo "export CDK_TEST_MINT_URL_2=\"$CDK_TEST_MINT_URL_2\"" >> "$ENV_FILE" -echo "export CDK_MINTD_PID=\"$CDK_MINTD_PID\"" >> "$ENV_FILE" -echo "export CDK_MINTD_LND_PID=\"$CDK_MINTD_LND_PID\"" >> "$ENV_FILE" -echo "export CDK_REGTEST_PID=\"$CDK_REGTEST_PID\"" >> "$ENV_FILE" - -echo -echo "==============================================" -echo "🎉 CDK Regtest Environment is Ready!" -echo "==============================================" -echo -echo "Network Information:" -echo " • Bitcoin RPC: 127.0.0.1:18443 (user: testuser, pass: testpass)" -echo " • CLN Node 1: $CDK_ITESTS_DIR/cln/one/regtest/lightning-rpc" -echo " • CLN Node 2: $CDK_ITESTS_DIR/cln/two/regtest/lightning-rpc" -echo " • LND Node 1: https://localhost:10009" -echo " • LND Node 2: https://localhost:10010" -echo -echo "CDK Mints:" -echo " • CLN Mint: $CDK_TEST_MINT_URL" -echo " • LND Mint: $CDK_TEST_MINT_URL_2" -echo -echo "Files and Directories:" -echo " • Working Directory: $CDK_ITESTS_DIR" -echo " • CLN Mint Logs: $CDK_ITESTS_DIR/cln_mint/mintd.log" -echo " • LND Mint Logs: $CDK_ITESTS_DIR/lnd_mint/mintd.log" -echo " • LND 1 TLS Cert: $CDK_ITESTS_DIR/lnd/one/tls.cert" -echo " • LND 1 Macaroon: $CDK_ITESTS_DIR/lnd/one/data/chain/bitcoin/regtest/admin.macaroon" -echo " • LND 2 TLS Cert: $CDK_ITESTS_DIR/lnd/two/tls.cert" -echo " • LND 2 Macaroon: $CDK_ITESTS_DIR/lnd/two/data/chain/bitcoin/regtest/admin.macaroon" -echo -echo "Environment Variables (available in other terminals):" -echo " • CDK_TEST_MINT_URL=\"$CDK_TEST_MINT_URL\"" -echo " • CDK_TEST_MINT_URL_2=\"$CDK_TEST_MINT_URL_2\"" -echo " • CDK_ITESTS_DIR=\"$CDK_ITESTS_DIR\"" -echo -echo "You can now:" -echo " • Use 'just' commands in other terminals: 'just ln-cln1 getinfo'" -echo " • Run integration tests: 'just mint-test' or 'cargo test -p cdk-integration-tests'" -echo " • Use CDK CLI tools with the mint URLs above" -echo " • Interact with Lightning nodes directly" -echo " • Access Bitcoin regtest node" -echo -echo "State File: /tmp/cdk_regtest_env (allows other terminals to find this environment)" -echo -echo "Starting mprocs to monitor logs..." -echo "Press 'q' to quit mprocs and stop the environment" -echo "==============================================" - -# Create mprocs configuration -MPROCS_CONFIG="$CDK_ITESTS_DIR/mprocs.yaml" -cat > "$MPROCS_CONFIG" << EOF -procs: - cln-mint: - shell: "touch $CDK_ITESTS_DIR/cln_mint/mintd.log && tail -f $CDK_ITESTS_DIR/cln_mint/mintd.log" - autostart: true - - lnd-mint: - shell: "touch $CDK_ITESTS_DIR/lnd_mint/mintd.log && tail -f $CDK_ITESTS_DIR/lnd_mint/mintd.log" - autostart: true - - bitcoind: - shell: "touch $CDK_ITESTS_DIR/bitcoin/regtest/debug.log && tail -f $CDK_ITESTS_DIR/bitcoin/regtest/debug.log" - autostart: true - - cln-one: - shell: "while [ ! -f $CDK_ITESTS_DIR/cln/one/regtest/log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/cln/one/regtest/log" - autostart: true - - cln-two: - shell: "while [ ! -f $CDK_ITESTS_DIR/cln/two/regtest/log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/cln/two/regtest/log" - autostart: true - - lnd-one: - shell: "while [ ! -f $CDK_ITESTS_DIR/lnd/one/logs/bitcoin/regtest/lnd.log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/lnd/one/logs/bitcoin/regtest/lnd.log" - autostart: true - - lnd-two: - shell: "while [ ! -f $CDK_ITESTS_DIR/lnd/two/logs/bitcoin/regtest/lnd.log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/lnd/two/logs/bitcoin/regtest/lnd.log" - autostart: true - -settings: - mouse_scroll_speed: 3 - proc_list_width: 20 - hide_keymap_window: false -EOF - -# Wait a bit for log files to be created -sleep 2 - -# Start mprocs to show all logs -if command -v mprocs >/dev/null 2>&1; then - cd "$CDK_ITESTS_DIR" - mprocs --config "$MPROCS_CONFIG" -else - echo "⚠️ mprocs not found. Install it with: cargo install mprocs" - echo "Falling back to simple wait loop..." - echo "Press Ctrl+C to stop the environment" - # Keep the script running - while true; do - sleep 1 - done -fi diff --git a/misc/interactive_regtest_mprocs.sh b/misc/interactive_regtest_mprocs.sh index 8f486fb6..a81a7c31 100755 --- a/misc/interactive_regtest_mprocs.sh +++ b/misc/interactive_regtest_mprocs.sh @@ -270,14 +270,14 @@ cat > "$MPROCS_CONFIG" << EOF procs: cln-mint: shell: "$CDK_ITESTS_DIR/start_cln_mint.sh" - autostart: false + autostart: true env: CDK_ITESTS_DIR: "$CDK_ITESTS_DIR" CDK_MINTD_DATABASE: "$CDK_MINTD_DATABASE" lnd-mint: shell: "$CDK_ITESTS_DIR/start_lnd_mint.sh" - autostart: false + autostart: true env: CDK_ITESTS_DIR: "$CDK_ITESTS_DIR" CDK_MINTD_DATABASE: "$CDK_MINTD_DATABASE" diff --git a/misc/regtest_helper.sh b/misc/regtest_helper.sh index c0442c41..5e366825 100755 --- a/misc/regtest_helper.sh +++ b/misc/regtest_helper.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Helper script for interacting with CDK regtest environment -# Run this after starting interactive_regtest.sh +# Run this after starting interactive_regtest_mprocs.sh # Check for environment state file first, then environment variable ENV_FILE="/tmp/cdk_regtest_env" @@ -17,14 +17,14 @@ elif [ ! -z "$CDK_ITESTS_DIR" ]; then echo "export CDK_REGTEST_PID=\"$CDK_REGTEST_PID\"" >> "$ENV_FILE" else echo "❌ CDK regtest environment not found!" - echo "Please run './misc/interactive_regtest.sh' or 'just regtest' first" + echo "Please run './misc/interactive_regtest_mprocs.sh' or 'just regtest' first" exit 1 fi # Validate that the environment is actually running if [ -z "$CDK_ITESTS_DIR" ] || [ ! -d "$CDK_ITESTS_DIR" ]; then echo "❌ CDK regtest environment not found or directory missing!" - echo "Please run './misc/interactive_regtest.sh' or 'just regtest' first" + echo "Please run './misc/interactive_regtest_mprocs.sh' or 'just regtest' first" [ -f "$ENV_FILE" ] && rm "$ENV_FILE" # Clean up stale state file exit 1 fi From a97eb84db6b79fee3657e47e36a0471cb491ab85 Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Tue, 8 Jul 2025 11:09:20 +0100 Subject: [PATCH 3/4] chore: update docs --- DEVELOPMENT.md | 23 ++++ MPROCS_INTEGRATION.md | 147 ----------------------- MPROCS_MODES.md | 132 --------------------- REGTEST_GUIDE.md | 267 ++++++++++++++++++++++++++++++++++++++++++ REGTEST_QUICKSTART.md | 125 -------------------- misc/README.md | 218 ---------------------------------- 6 files changed, 290 insertions(+), 622 deletions(-) delete mode 100644 MPROCS_INTEGRATION.md delete mode 100644 MPROCS_MODES.md create mode 100644 REGTEST_GUIDE.md delete mode 100644 REGTEST_QUICKSTART.md delete mode 100644 misc/README.md diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 1306fbc9..0d24c69d 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -69,6 +69,29 @@ If the Nix installation is in multi-user mode, don’t forget to restart the nix nix develop -c $SHELL ``` +## Regtest Environment + +For testing and development, CDK provides a complete regtest environment with Bitcoin, Lightning Network nodes, and CDK mints. + +### Quick Start +```bash +just regtest # Starts full environment with mprocs TUI +``` + +This provides: +- Bitcoin regtest node +- 4 Lightning Network nodes (2 CLN + 2 LND) +- 2 CDK mints (one connected to CLN, one to LND) +- Real-time log monitoring via mprocs +- Helper commands for testing Lightning payments and CDK operations + +### Comprehensive Guide +See [REGTEST_GUIDE.md](REGTEST_GUIDE.md) for complete documentation including: +- Detailed setup and usage instructions +- Development workflows and testing scenarios +- mprocs TUI interface guide +- Troubleshooting and advanced usage + ## Common Development Tasks ### Building the Project diff --git a/MPROCS_INTEGRATION.md b/MPROCS_INTEGRATION.md deleted file mode 100644 index 79aee0fe..00000000 --- a/MPROCS_INTEGRATION.md +++ /dev/null @@ -1,147 +0,0 @@ -# mprocs Integration for CDK Regtest - -The CDK regtest environment now integrates with `mprocs` to provide a beautiful TUI (Terminal User Interface) for monitoring all component logs in real-time. - -## What is mprocs? - -`mprocs` is a TUI for running multiple processes and monitoring their output. Perfect for development environments where you need to watch logs from multiple services simultaneously. - -## Features - -### Automatic Setup -- The regtest script checks for `mprocs` and offers to install it if missing -- Creates a dynamic mprocs configuration with all relevant log files -- Handles missing log files gracefully (waits for them to be created) - -### Components Monitored -- **cln-mint**: CDK mint connected to CLN -- **lnd-mint**: CDK mint connected to LND -- **bitcoind**: Bitcoin regtest node -- **cln-one**: Core Lightning node #1 -- **cln-two**: Core Lightning node #2 -- **lnd-one**: LND node #1 -- **lnd-two**: LND node #2 - -### Key Benefits -- **Real-time log monitoring** for all components -- **Side-by-side view** of related services -- **Easy navigation** between different logs -- **Scrollback** to review history -- **Search functionality** within logs -- **Process management** (start/stop/restart individual processes) - -## Usage - -### Automatic (Recommended) - Log Tailing Mode -```bash -just regtest -# After setup completes, mprocs launches automatically -# Mints start and log to files, mprocs shows log contents -``` - -### Direct Process Management Mode -```bash -just regtest-mprocs -# After setup, mprocs starts with mint processes stopped -# Use 's' key to start individual mints -# Full process control from within mprocs -``` - -### Manual Launch -```bash -# Start environment without mprocs -just regtest - -# In another terminal, launch mprocs -just regtest-logs -``` - -### Commands Available -```bash -just regtest # Starts environment and mprocs (log tailing mode) -just regtest-mprocs # Starts environment with direct process management -just regtest-logs # Manual mprocs launch (adapts to current mode) -``` - -## mprocs Controls - -### Direct Process Management Mode: -- **Arrow keys**: Navigate between processes -- **s**: Start the selected process -- **k**: Kill the selected process -- **r**: Restart the selected process -- **Enter**: Focus on selected process -- **Tab**: Switch between process list and log view -- **?**: Show help -- **q**: Quit mprocs (stops all managed processes) - -### Log Tailing Mode: -- **Arrow keys**: Navigate between processes -- **Enter**: Focus on selected process -- **Tab**: Switch between process list and log view -- **PageUp/PageDown**: Scroll through logs -- **Ctrl+C**: Interrupt current process -- **q**: Quit mprocs (processes continue running) - -## Installation - -If `mprocs` is not installed: -```bash -# Automatic installation prompt when running regtest -just regtest - -# Manual installation -cargo install mprocs - -# Or via package manager (varies by OS) -# Ubuntu/Debian: apt install mprocs -# macOS: brew install mprocs -``` - -## Configuration - -The mprocs configuration is automatically generated at `$CDK_ITESTS_DIR/mprocs.yaml`. It includes: - -- Proper log file paths for all components -- Graceful handling of missing files -- Optimized UI settings for development -- Auto-start for all monitoring processes - -## Development Workflow - -### Before mprocs: -- Start regtest environment -- Open multiple terminals to `tail -f` different log files -- Manually manage multiple windows/panes -- Switch between terminals to see different components - -### With mprocs: -- Start regtest environment → automatic log monitoring -- Single TUI shows all component logs -- Easy navigation between components -- Professional development experience - -## Example View - -``` -┌─Processes─────────┬─Output───────────────────────────────────────┐ -│ ● cln-mint │ 2024-07-08T08:30:12 INFO cdk_mintd: Starting │ -│ ● lnd-mint │ mint server on 127.0.0.1:8085 │ -│ ● bitcoind │ 2024-07-08T08:30:13 INFO: New invoice │ -│ ● cln-one │ received for 1000 sats │ -│ ● cln-two │ 2024-07-08T08:30:14 INFO: Payment │ -│ ● lnd-one │ successful │ -│ ● lnd-two │ │ -│ │ │ -└───────────────────┴──────────────────────────────────────────────┘ -``` - -## Fallback - -If mprocs is not available or fails: -- Environment continues to work normally -- Falls back to simple wait loop -- All `just` commands work as expected -- Logs still accessible via `just regtest-logs` - -This integration makes CDK development much more pleasant by providing professional-grade log monitoring out of the box! 🎉 diff --git a/MPROCS_MODES.md b/MPROCS_MODES.md deleted file mode 100644 index 06faea0e..00000000 --- a/MPROCS_MODES.md +++ /dev/null @@ -1,132 +0,0 @@ -# mprocs Process Management Modes - -The CDK regtest environment now supports two different modes for managing processes with mprocs: - -## Mode 1: Log Tailing (Default) -**Command**: `just regtest` - -### How it works: -- Mints are started by the bash script and run in the background -- Mints write their output to log files (`mintd.log`) -- mprocs uses `tail -f` to follow these log files -- Log files persist even after mprocs exits - -### Pros: -- ✅ Log files are preserved for later analysis -- ✅ Simple setup -- ✅ Works even if mprocs crashes - -### Cons: -- ❌ Cannot restart mints from within mprocs -- ❌ Must use external commands to control mints -- ❌ mprocs shows file contents, not live processes - -## Mode 2: Direct Process Management -**Command**: `just regtest-mprocs` - -### How it works: -- mprocs directly manages the mint processes -- Mints are started/stopped by mprocs itself -- Output goes directly to mprocs (no log files by default) -- Full process control from within mprocs - -### Pros: -- ✅ Start/stop/restart mints directly from mprocs -- ✅ Live process output -- ✅ Better development workflow -- ✅ Process status indicators - -### Cons: -- ❌ Output not saved to files (unless configured) -- ❌ If mprocs crashes, you lose the processes - -## mprocs Controls - -### Direct Process Management Mode: -- **Arrow keys**: Navigate between processes -- **s**: Start the selected process -- **k**: Kill the selected process -- **r**: Restart the selected process -- **Enter**: Focus on a process (see its output) -- **Tab**: Switch between process list and output -- **?**: Show help -- **q**: Quit mprocs (stops all managed processes) - -### Log Tailing Mode: -- **Arrow keys**: Navigate between log sources -- **Enter**: Focus on a log source -- **Tab**: Switch between process list and log view -- **PageUp/PageDown**: Scroll through logs -- **q**: Quit mprocs (processes continue running) - -## Usage Examples - -### Start with Log Tailing (Original Mode) -```bash -just regtest -# Mints start automatically and log to files -# mprocs shows log contents -# Use Ctrl+C or 'q' to exit mprocs -# Processes continue running in background -``` - -### Start with Direct Process Management -```bash -just regtest-mprocs -# Only Lightning network starts automatically -# In mprocs, navigate to "cln-mint" and press 's' to start it -# Navigate to "lnd-mint" and press 's' to start it -# Use 'r' to restart mints after code changes -# Use 'q' to exit and stop all processes -``` - -### Switch Between Modes - -If you started with log tailing mode, you can access the direct management: -```bash -# In another terminal -source /tmp/cdk_regtest_env -just regtest-logs # This will detect the mode and adapt -``` - -## Development Workflow Comparison - -### Traditional (Log Tailing): -1. `just regtest` -2. Make code changes -3. In another terminal: `just restart-mints` -4. Check logs in mprocs - -### Direct Management: -1. `just regtest-mprocs` -2. Press 's' to start mints -3. Make code changes -4. In mprocs: press 'r' on each mint to restart -5. Watch live output directly - -## Technical Details - -### Project Root Handling -The direct process management mode ensures that: -- Startup scripts change to the correct project root directory -- Cargo commands run from where the `Cargo.toml` file is located -- Environment variables are properly set before starting processes - -### File Structure -``` -$CDK_ITESTS_DIR/ -├── start_cln_mint.sh # Sets PROJECT_ROOT and runs cargo from there -├── start_lnd_mint.sh # Sets PROJECT_ROOT and runs cargo from there -└── mprocs.yaml # Points to the startup scripts -``` - -Each startup script: -1. Changes to the project root directory (`cd "$PROJECT_ROOT"`) -2. Sets all required environment variables -3. Executes `cargo run --bin cdk-mintd` from the correct location - -The environment variables and helper commands work the same in both modes: -- `just ln-cln1 getinfo` -- `just btc-mine 5` -- `just mint-info` -- etc. diff --git a/REGTEST_GUIDE.md b/REGTEST_GUIDE.md new file mode 100644 index 00000000..91958648 --- /dev/null +++ b/REGTEST_GUIDE.md @@ -0,0 +1,267 @@ +# CDK Regtest Environment Guide + +A comprehensive guide for setting up and using the CDK regtest environment for development and testing. + +## Quick Start + +### Start the Environment +```bash +# Start regtest with SQLite database (default) +just regtest + +# Or with REDB database +just regtest redb +``` + +The script will: +1. Check for `mprocs` and offer to install it if missing +2. Build necessary binaries +3. Set up Bitcoin regtest + 4 Lightning nodes + 2 CDK mints +4. Launch `mprocs` TUI showing all component logs +5. Both mints start automatically + +### Stop the Environment +Press `q` in mprocs or `Ctrl+C` in the terminal. Everything cleans up automatically. + +## Network Components + +When running, you get a complete Lightning Network environment: + +### Bitcoin Network +- **Bitcoin RPC**: `127.0.0.1:18443` (user: `testuser`, pass: `testpass`) + +### Lightning Nodes +- **CLN Node 1**: `$CDK_ITESTS_DIR/cln/one/regtest/lightning-rpc` +- **CLN Node 2**: `$CDK_ITESTS_DIR/cln/two/regtest/lightning-rpc` +- **LND Node 1**: `https://localhost:10009` +- **LND Node 2**: `https://localhost:10010` + +### CDK Mints +- **CLN Mint**: `http://127.0.0.1:8085` (connected to CLN node 1) +- **LND Mint**: `http://127.0.0.1:8087` (connected to LND node 2) + +### Environment Variables +Available in all terminals automatically: +- `CDK_TEST_MINT_URL`: CLN mint URL +- `CDK_TEST_MINT_URL_2`: LND mint URL +- `CDK_ITESTS_DIR`: Temporary directory with all data + +## Using the Environment + +All commands work from any terminal - they automatically find the running environment. + +### Lightning Node Operations +```bash +# Get node information +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 "Test payment" +just ln-lnd1 payinvoice + +# Check balances and channels +just ln-cln1 listfunds +just ln-lnd1 listchannels +``` + +### Bitcoin Operations +```bash +just btc getblockchaininfo # Blockchain status +just btc getbalance # Wallet balance +just btc-mine 5 # Mine 5 blocks +``` + +### CDK Mint Operations +```bash +just mint-info # Show both mints' info +just mint-test # Run integration tests +just restart-mints # Recompile and restart mints +just regtest-status # Check all components +just regtest-logs # Show recent logs +``` + +## mprocs TUI Interface + +The `mprocs` interface shows all component logs in real-time: + +### Controls +- **Arrow keys**: Navigate between processes +- **Enter**: Focus on a process to see its output +- **Tab**: Switch between process list and output view +- **s**: Start a process (if stopped) +- **k**: Kill a process +- **r**: Restart a process +- **PageUp/PageDown**: Scroll through logs +- **?**: Show help +- **q**: Quit and stop environment + +### Process List +- `cln-mint`: CDK mint connected to CLN (auto-started) +- `lnd-mint`: CDK mint connected to LND (auto-started) +- `bitcoind`: Bitcoin regtest node logs +- `cln-one`: CLN node 1 logs +- `cln-two`: CLN node 2 logs +- `lnd-one`: LND node 1 logs +- `lnd-two`: LND node 2 logs + +## Development Workflows + +### Testing Lightning Payment Flow +```bash +# Terminal 1: Start environment +just regtest + +# Terminal 2: Create invoice and pay +just ln-cln1 invoice 1000 test "Test payment" +just ln-lnd1 payinvoice +just ln-cln1 listinvoices +just ln-lnd1 listpayments +``` + +### Developing Mint Code +```bash +# Terminal 1: Keep regtest running +just regtest + +# Terminal 2: After making code changes +just restart-mints # Recompiles and restarts both mints +just mint-info # Test the changes +just mint-test # Run integration tests +``` + +### Using CDK CLI Tools +```bash +# Terminal 1: Start environment +just regtest + +# Terminal 2: Use environment variables +cargo run --bin cdk-cli -- --mint-url $CDK_TEST_MINT_URL mint-info +cargo run --bin cdk-cli -- --mint-url $CDK_TEST_MINT_URL_2 mint-info +``` + +### Direct API Testing +```bash +# Query mint info directly +curl $CDK_TEST_MINT_URL/v1/info | jq +curl $CDK_TEST_MINT_URL/v1/keysets | jq + +# Test both mints +curl http://127.0.0.1:8085/v1/info | jq +curl http://127.0.0.1:8087/v1/info | jq +``` + +## File Structure + +All components run in a temporary directory: + +``` +$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 +├── cln_mint/ # CLN mint working directory +├── lnd_mint/ # LND mint working directory +├── start_cln_mint.sh # Mint startup scripts +├── start_lnd_mint.sh +└── mprocs.yaml # mprocs configuration +``` + +## Installation Requirements + +### mprocs (TUI Interface) +If not installed, the script will offer to install it: +```bash +# Automatic installation during regtest setup +just regtest + +# Manual installation +cargo install mprocs + +# Or via package manager +# Ubuntu/Debian: apt install mprocs +# macOS: brew install mprocs +``` + +### System Dependencies +Managed automatically via Nix development shell: +- Bitcoin Core +- Core Lightning (CLN) +- LND (Lightning Network Daemon) +- Rust toolchain + +## Advanced Usage + +### Manual mprocs Launch +```bash +# If you need to restart just the mprocs interface +source /tmp/cdk_regtest_env +just regtest-logs +``` + +### Environment State +The environment creates a state file at `/tmp/cdk_regtest_env` that: +- Shares environment variables between terminals +- Allows `just` commands to work from anywhere +- Automatically cleaned up when environment stops + +### Process Management +From within mprocs: +- Restart individual mints after code changes +- Monitor specific component logs +- Start/stop services for testing scenarios + +## Troubleshooting + +### Environment Not Starting +- Check that ports are available: 8085, 8087, 18443, 19846, 19847, 10009, 10010 +- Ensure the Nix development shell is active: `nix develop` +- Check individual component logs in mprocs + +### Helper Commands Not Working +- Ensure the regtest environment is running +- Check that `/tmp/cdk_regtest_env` file exists +- Verify environment variables are set: `echo $CDK_TEST_MINT_URL` + +### Connection Issues +- Use `just regtest-status` to check component health +- Check mint logs with `just regtest-logs` +- Verify Lightning node status with `just ln-cln1 getinfo` + +### mprocs Issues +- If mprocs crashes, processes continue running +- Use `Ctrl+C` in the original terminal to clean up +- Restart with `just regtest-logs` + +## Common Error Solutions + +### "Port already in use" +```bash +# Find and kill processes using ports +sudo lsof -ti:8085 | xargs kill -9 +sudo lsof -ti:8087 | xargs kill -9 +``` + +### "Environment not found" +```bash +# Clean up and restart +rm -f /tmp/cdk_regtest_env +just regtest +``` + +### "Binary not found" +```bash +# Rebuild binaries +just build +just regtest +``` + +This environment provides everything needed for CDK development and testing in a single, easy-to-use interface! 🎉 diff --git a/REGTEST_QUICKSTART.md b/REGTEST_QUICKSTART.md deleted file mode 100644 index f02bedf6..00000000 --- a/REGTEST_QUICKSTART.md +++ /dev/null @@ -1,125 +0,0 @@ -# CDK Interactive Regtest - Quick Start - -A simple guide to get up and running with the interactive regtest environment. - -## Start Environment - -```bash -# Terminal 1: Start regtest with default sqlite database -just regtest - -# Or with redb database -just regtest redb -``` - -The script will: -1. Check for `mprocs` and offer to install it if missing -2. Set up the regtest environment (Bitcoin + Lightning nodes + CDK mints) -3. Launch `mprocs` showing logs from all components -4. Press 'q' in mprocs to quit and stop the environment - -## Use Lightning Nodes (in any other terminal) - -The `just` commands work from any terminal - they automatically find the running environment. - -### Get Node Information -```bash -just ln-cln1 getinfo # CLN node 1 -just ln-cln2 getinfo # CLN node 2 -just ln-lnd1 getinfo # LND node 1 -just ln-lnd2 getinfo # LND node 2 -``` - -### Create and Pay Invoices -```bash -# Create 1000 sat invoice on CLN -just ln-cln1 invoice 1000 test_label "Test payment" - -# Pay invoice with LND (use the bolt11 from above) -just ln-lnd1 payinvoice lnbcrt10u1... - -# Check balances -just ln-cln1 listfunds -just ln-lnd1 listchannels -``` - -## Bitcoin Operations - -```bash -just btc getblockchaininfo # Blockchain status -just btc getbalance # Wallet balance -just btc-mine 5 # Mine 5 blocks -``` - -## CDK Mint Operations - -```bash -just mint-info # Show both mints' info -just mint-test # Run integration tests -just restart-mints # Stop, recompile, and restart mints -just regtest-status # Check all components -just regtest-logs # Show recent logs -just regtest-mprocs # Start mprocs TUI (if not already running) -``` - -## Stop Environment - -Press `Ctrl+C` in the terminal running `just regtest`. Everything will be cleaned up automatically. - -## Available Endpoints - -- **CLN Mint**: http://127.0.0.1:8085 -- **LND Mint**: http://127.0.0.1:8087 -- **Bitcoin RPC**: 127.0.0.1:18443 (testuser/testpass) - -## Common Workflows - -### Test Lightning Payment Flow -```bash -# Terminal 1 -just regtest - -# Terminal 2 -just ln-cln1 invoice 1000 test "Test payment" -# Copy the bolt11 invoice - -just ln-lnd1 payinvoice -just ln-cln1 listinvoices -just ln-lnd1 listpayments -``` - -### Test CDK Integration -```bash -# Terminal 1 -just regtest - -# Terminal 2 -just mint-test # Run all tests -cargo test -p cdk-integration-tests # Or specific tests -``` - -### Development with CDK CLI -```bash -# Terminal 1 -just regtest - -# Terminal 2 - use environment variables -echo $CDK_TEST_MINT_URL # CLN mint URL -echo $CDK_TEST_MINT_URL_2 # LND mint URL - -# Use with CDK CLI -cargo run --bin cdk-cli -- --mint-url $CDK_TEST_MINT_URL mint-info -``` - -### Development Workflow (Mint Code Changes) -```bash -# Terminal 1: Keep regtest running -just regtest - -# Terminal 2: Make changes to mint code, then -just restart-mints # Recompiles and restarts both mints -just mint-info # Test the changes -just mint-test # Run integration tests -``` - -That's it! The environment provides a full Lightning Network with CDK mints for testing and development. diff --git a/misc/README.md b/misc/README.md deleted file mode 100644 index a61e3242..00000000 --- a/misc/README.md +++ /dev/null @@ -1,218 +0,0 @@ -# CDK Interactive Regtest Environment - -This directory contains scripts for setting up and interacting with a CDK regtest environment for development and testing. - -## Scripts - -### 1. `interactive_regtest_mprocs.sh` -Sets up a complete regtest environment with: -- Bitcoin regtest node -- 2 CLN (Core Lightning) nodes with channels -- 2 LND nodes with channels -- 2 CDK mint instances (one connected to CLN, one to LND) - -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. - -### 2. `regtest_helper.sh` -Helper script providing convenient commands to interact with the running regtest environment. Automatically detects the environment using the state file. - -## Quick Start - -### Using `just` (Recommended) - -1. **Start the regtest environment:** - ```bash - just regtest [database_type] - ``` - - `database_type`: Optional, defaults to "sqlite". Can be "sqlite" or "redb" - - The script will check for `mprocs` and offer to install it if missing - - After setup, it will launch `mprocs` showing logs from all nodes and mints - - Press 'q' in mprocs to quit and stop the environment - -2. **In another terminal, interact with Lightning nodes:** - ```bash - # 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 - ``` - -### Using Scripts Directly - -1. **Start the regtest environment:** - ```bash - ./misc/interactive_regtest_mprocs.sh [database_type] - ``` - - `database_type`: Optional, defaults to "sqlite". Can be "sqlite" or "redb" - - The script will build necessary binaries and set up the full environment - - Keep this terminal open - the environment runs until you press Ctrl+C - -2. **In another terminal, use the helper script:** - ```bash - ./misc/regtest_helper.sh help - ``` - -## How It Works - -The interactive regtest environment uses a state file (`/tmp/cdk_regtest_env`) to share environment information between terminal sessions: - -1. When you run `just regtest` or `./misc/interactive_regtest_mprocs.sh`, it creates the state file with all necessary environment variables -2. When you run Lightning node commands in other terminals (e.g., `just ln-cln1 getinfo`), the helper script automatically sources the state file -3. When the environment shuts down (Ctrl+C), it cleans up the state file automatically - -This allows you to use `just` commands from any terminal without needing to export environment variables manually. - -## Environment Details - -When running, the environment provides: - -### Network Endpoints -- **Bitcoin RPC**: `127.0.0.1:18443` (user: `testuser`, pass: `testpass`) -- **CLN Node 1**: Unix socket at `$CDK_ITESTS_DIR/cln/one/regtest/lightning-rpc` -- **CLN Node 2**: Unix socket at `$CDK_ITESTS_DIR/cln/two/regtest/lightning-rpc` -- **LND Node 1**: HTTPS on `localhost:10009` -- **LND Node 2**: HTTPS on `localhost:10010` - -### CDK Mints -- **CLN Mint**: `http://127.0.0.1:8085` (connected to CLN node 1) -- **LND Mint**: `http://127.0.0.1:8087` (connected to LND node 2) - -### Environment Variables -The following variables are exported for easy access: -- `CDK_TEST_MINT_URL`: CLN mint URL -- `CDK_TEST_MINT_URL_2`: LND mint URL -- `CDK_ITESTS_DIR`: Temporary directory with all data - -## Usage Examples - -### Using `just` Commands (Recommended) - -```bash -# 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 - -# 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 -``` - -### Using Helper Script Directly - -```bash -# 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 - -# 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 -``` - -### Legacy Examples (for reference) - -### Direct API Access -```bash -# 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 -``` - -### Development Workflow -```bash -# 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 -``` - -## File Locations - -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 -``` - -## Cleanup - -- Press `Ctrl+C` in the terminal running `interactive_regtest_mprocs.sh` -- All processes will be terminated and the temporary directory will be cleaned up automatically -- No manual cleanup is required - -## Troubleshooting - -### Environment not starting -- Check that ports 8085, 8087, 18443, 19846, 19847, 10009, 10010 are available -- Ensure you have the necessary dependencies (Bitcoin Core, CLN, LND) available -- Check the logs in `$CDK_ITESTS_DIR/cln_mint/mintd.log` and `$CDK_ITESTS_DIR/lnd_mint/mintd.log` - -### Helper script not working -- Ensure the regtest environment is running first -- The `CDK_ITESTS_DIR` environment variable must be set (done automatically by `interactive_regtest_mprocs.sh`) - -### Connection issues -- Use `./misc/regtest_helper.sh show-status` to check component health -- Check mint logs with `./misc/regtest_helper.sh show-logs` From ea0b696db9eeac0ddf6e31ad8c53b6d34562c19b Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Tue, 8 Jul 2025 11:33:21 +0100 Subject: [PATCH 4/4] fix: cln mprocs logging --- crates/cdk-integration-tests/Cargo.toml | 2 +- misc/interactive_regtest_mprocs.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/cdk-integration-tests/Cargo.toml b/crates/cdk-integration-tests/Cargo.toml index a824321a..26a9da98 100644 --- a/crates/cdk-integration-tests/Cargo.toml +++ b/crates/cdk-integration-tests/Cargo.toml @@ -35,7 +35,7 @@ uuid.workspace = true serde.workspace = true serde_json.workspace = true # ln-regtest-rs = { path = "../../../../ln-regtest-rs" } -ln-regtest-rs = { git = "https://github.com/thesimplekid/ln-regtest-rs", rev = "ed24716" } +ln-regtest-rs = { git = "https://github.com/thesimplekid/ln-regtest-rs", rev = "df81424" } lightning-invoice.workspace = true tracing.workspace = true tracing-subscriber.workspace = true diff --git a/misc/interactive_regtest_mprocs.sh b/misc/interactive_regtest_mprocs.sh index a81a7c31..72aceef7 100755 --- a/misc/interactive_regtest_mprocs.sh +++ b/misc/interactive_regtest_mprocs.sh @@ -287,11 +287,11 @@ procs: autostart: true cln-one: - shell: "while [ ! -f $CDK_ITESTS_DIR/cln/one/regtest/log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/cln/one/regtest/log" + shell: "while [ ! -f $CDK_ITESTS_DIR/cln/one/debug.log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/cln/one/debug.log" autostart: true cln-two: - shell: "while [ ! -f $CDK_ITESTS_DIR/cln/two/regtest/log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/cln/two/regtest/log" + shell: "while [ ! -f $CDK_ITESTS_DIR/cln/two/debug.log ]; do sleep 1; done && tail -f $CDK_ITESTS_DIR/cln/two/debug.log" autostart: true lnd-one: