mirror of
https://github.com/aljazceru/cdk.git
synced 2026-01-01 03:55:22 +01:00
Mintd lib (#914)
* feat(cdk-integration-tests): refactor regtest setup and mintd integration - Replace shell-based regtest setup with Rust binary (start_regtest_mints) - Add cdk-mintd crate to workspace and integration tests - Improve environment variable handling for test configurations - Update integration tests to use proper temp directory management - Remove deprecated start_regtest.rs binary - Enhance CLN client connection with retry logic - Simplify regtest shell script (itests.sh) to use new binary - Fix tracing filters and improve error handling in setup - Update dependencies and configurations for integration tests fix: killing chore: comment tests for ci debugging chore: compile Revert "chore: comment tests for ci debugging" This reverts commit bfc594c11cf37caeaa6445cb854ae5567d2da6bd. * chore: sql cipher * fix: removal of sqlite cipher * fix: auth password * refactor(cdk-mintd): improve database password handling and function signatures - Pass database password as parameter instead of parsing CLI args in setup_database - Update function signatures for run_mintd and run_mintd_with_shutdown to accept db_password - Remove direct CLI parsing from database setup logic - Fix auth database initialization to use correct type when sqlcipher feature enabled
This commit is contained in:
@@ -1,31 +1,37 @@
|
||||
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Function to perform cleanup
|
||||
cleanup() {
|
||||
echo "Cleaning up..."
|
||||
|
||||
echo "Killing the cdk mintd"
|
||||
kill -2 $cdk_mintd_pid
|
||||
wait $cdk_mintd_pid
|
||||
if [ -n "$FAKE_AUTH_MINT_PID" ]; then
|
||||
echo "Killing the fake auth mint process"
|
||||
kill -2 $FAKE_AUTH_MINT_PID 2>/dev/null || true
|
||||
wait $FAKE_AUTH_MINT_PID 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo "Mint binary terminated"
|
||||
|
||||
# Remove the temporary directory
|
||||
rm -rf "$CDK_ITESTS_DIR"
|
||||
echo "Temp directory removed: $CDK_ITESTS_DIR"
|
||||
if [ -n "$CDK_ITESTS_DIR" ] && [ -d "$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
|
||||
unset FAKE_AUTH_MINT_PID
|
||||
}
|
||||
|
||||
# Set up trap to call cleanup on script exit
|
||||
trap cleanup EXIT
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
# Create a temporary directory
|
||||
export CDK_ITESTS_DIR=$(mktemp -d)
|
||||
export CDK_ITESTS_MINT_ADDR="127.0.0.1";
|
||||
export CDK_ITESTS_MINT_PORT=8087;
|
||||
export CDK_ITESTS_MINT_ADDR="127.0.0.1"
|
||||
export CDK_ITESTS_MINT_PORT=8087
|
||||
|
||||
# Check if the temporary directory was created successfully
|
||||
if [[ ! -d "$CDK_ITESTS_DIR" ]]; then
|
||||
@@ -34,72 +40,41 @@ if [[ ! -d "$CDK_ITESTS_DIR" ]]; then
|
||||
fi
|
||||
|
||||
echo "Temp directory created: $CDK_ITESTS_DIR"
|
||||
export MINT_DATABASE="$1";
|
||||
export OPENID_DISCOVERY="$2";
|
||||
|
||||
# Check if a database type was provided as first argument, default to sqlite
|
||||
export MINT_DATABASE="${1:-sqlite}"
|
||||
|
||||
# Check if OPENID_DISCOVERY was provided as second argument, default to a test value
|
||||
export OPENID_DISCOVERY="${2:-http://127.0.0.1:8080/realms/cdk-test-realm/.well-known/openid-configuration}"
|
||||
|
||||
# Build the project
|
||||
cargo build -p cdk-integration-tests
|
||||
|
||||
export CDK_MINTD_URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT";
|
||||
export CDK_MINTD_WORK_DIR="$CDK_ITESTS_DIR";
|
||||
export CDK_MINTD_LISTEN_HOST=$CDK_ITESTS_MINT_ADDR;
|
||||
export CDK_MINTD_LISTEN_PORT=$CDK_ITESTS_MINT_PORT;
|
||||
export CDK_MINTD_LN_BACKEND="fakewallet";
|
||||
export CDK_MINTD_FAKE_WALLET_SUPPORTED_UNITS="sat";
|
||||
export CDK_MINTD_MNEMONIC="eye survey guilt napkin crystal cup whisper salt luggage manage unveil loyal";
|
||||
export CDK_MINTD_FAKE_WALLET_FEE_PERCENT="0";
|
||||
export CDK_MINTD_FAKE_WALLET_RESERVE_FEE_MIN="1";
|
||||
export CDK_MINTD_DATABASE=$MINT_DATABASE;
|
||||
|
||||
# Auth configuration
|
||||
export CDK_TEST_OIDC_USER="cdk-test";
|
||||
export CDK_TEST_OIDC_PASSWORD="cdkpassword";
|
||||
export CDK_TEST_OIDC_USER="cdk-test"
|
||||
export CDK_TEST_OIDC_PASSWORD="cdkpassword"
|
||||
|
||||
export CDK_MINTD_AUTH_OPENID_DISCOVERY=$OPENID_DISCOVERY;
|
||||
export CDK_MINTD_AUTH_OPENID_CLIENT_ID="cashu-client";
|
||||
export CDK_MINTD_AUTH_MINT_MAX_BAT="50";
|
||||
export CDK_MINTD_AUTH_ENABLED_MINT="true";
|
||||
export CDK_MINTD_AUTH_ENABLED_MELT="true";
|
||||
export CDK_MINTD_AUTH_ENABLED_SWAP="true";
|
||||
export CDK_MINTD_AUTH_ENABLED_CHECK_MINT_QUOTE="true";
|
||||
export CDK_MINTD_AUTH_ENABLED_CHECK_MELT_QUOTE="true";
|
||||
export CDK_MINTD_AUTH_ENABLED_RESTORE="true";
|
||||
export CDK_MINTD_AUTH_ENABLED_CHECK_PROOF_STATE="true";
|
||||
# Start the fake auth mint in the background
|
||||
echo "Starting fake auth mint with discovery URL: $OPENID_DISCOVERY"
|
||||
echo "Using temp directory: $CDK_ITESTS_DIR"
|
||||
cargo run -p cdk-integration-tests --bin start_fake_auth_mint -- --enable-logging "$MINT_DATABASE" "$CDK_ITESTS_DIR" "$OPENID_DISCOVERY" "$CDK_ITESTS_MINT_PORT" &
|
||||
|
||||
echo "Starting auth mintd";
|
||||
cargo run --bin cdk-mintd --features redb &
|
||||
cdk_mintd_pid=$!
|
||||
# Store the PID of the mint process
|
||||
FAKE_AUTH_MINT_PID=$!
|
||||
|
||||
URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT/v1/info"
|
||||
TIMEOUT=100
|
||||
START_TIME=$(date +%s)
|
||||
# Loop until the endpoint returns a 200 OK status or timeout is reached
|
||||
while true; do
|
||||
# Get the current time
|
||||
CURRENT_TIME=$(date +%s)
|
||||
|
||||
# Calculate the elapsed time
|
||||
ELAPSED_TIME=$((CURRENT_TIME - START_TIME))
|
||||
# Wait a moment for the mint to start
|
||||
sleep 5
|
||||
|
||||
# Check if the elapsed time exceeds the timeout
|
||||
if [ $ELAPSED_TIME -ge $TIMEOUT ]; then
|
||||
echo "Timeout of $TIMEOUT seconds reached. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
# Check if the mint is running
|
||||
if ! kill -0 $FAKE_AUTH_MINT_PID 2>/dev/null; then
|
||||
echo "Failed to start fake auth mint"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make a request to the endpoint and capture the HTTP status code
|
||||
HTTP_STATUS=$(curl -o /dev/null -s -w "%{http_code}" $URL)
|
||||
|
||||
# Check if the HTTP status is 200 OK
|
||||
if [ "$HTTP_STATUS" -eq 200 ]; then
|
||||
echo "Received 200 OK from $URL"
|
||||
break
|
||||
else
|
||||
echo "Waiting for 200 OK response, current status: $HTTP_STATUS"
|
||||
sleep 2 # Wait for 2 seconds before retrying
|
||||
fi
|
||||
done
|
||||
echo "Fake auth mint started with PID: $FAKE_AUTH_MINT_PID"
|
||||
|
||||
# Run cargo test
|
||||
echo "Running fake auth integration tests..."
|
||||
cargo test -p cdk-integration-tests --test fake_auth
|
||||
|
||||
# Capture the exit status of cargo test
|
||||
|
||||
@@ -1,46 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Script to run fake mint tests with proper handling of race conditions
|
||||
# This script ensures the .env file is properly created and available
|
||||
# before running tests
|
||||
|
||||
# Function to perform cleanup
|
||||
cleanup() {
|
||||
echo "Cleaning up..."
|
||||
|
||||
echo "Killing the cdk mintd"
|
||||
kill -2 $CDK_MINTD_PID
|
||||
wait $CDK_MINTD_PID
|
||||
kill -9 $CDK_SIGNATORY_PID
|
||||
wait $CDK_SIGNATORY_PID
|
||||
if [ -n "$FAKE_MINT_PID" ]; then
|
||||
echo "Killing the fake mint process"
|
||||
kill -2 $FAKE_MINT_PID 2>/dev/null || true
|
||||
wait $FAKE_MINT_PID 2>/dev/null || true
|
||||
fi
|
||||
|
||||
if [ -n "$CDK_SIGNATORY_PID" ]; then
|
||||
echo "Killing the signatory process"
|
||||
kill -9 $CDK_SIGNATORY_PID 2>/dev/null || true
|
||||
wait $CDK_SIGNATORY_PID 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo "Mint binary terminated"
|
||||
|
||||
# Remove the temporary directory
|
||||
rm -rf "$CDK_ITESTS_DIR"
|
||||
echo "Temp directory removed: $CDK_ITESTS_DIR"
|
||||
if [ -n "$CDK_ITESTS_DIR" ] && [ -d "$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
|
||||
unset CDK_MINTD_DATABASE
|
||||
unset CDK_TEST_MINT_URL
|
||||
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_FAKE_WALLET_SUPPORTED_UNITS
|
||||
unset CDK_MINTD_MNEMONIC
|
||||
unset CDK_MINTD_FAKE_WALLET_FEE_PERCENT
|
||||
unset CDK_MINTD_FAKE_WALLET_RESERVE_FEE_MIN
|
||||
unset CDK_MINTD_PID
|
||||
unset FAKE_MINT_PID
|
||||
unset CDK_SIGNATORY_PID
|
||||
}
|
||||
|
||||
# Set up trap to call cleanup on script exit
|
||||
trap cleanup EXIT
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
# Create a temporary directory
|
||||
export CDK_ITESTS_DIR=$(mktemp -d)
|
||||
export CDK_ITESTS_MINT_ADDR="127.0.0.1"
|
||||
export CDK_ITESTS_MINT_PORT=8086
|
||||
|
||||
# Check if the temporary directory was created successfully
|
||||
if [[ ! -d "$CDK_ITESTS_DIR" ]]; then
|
||||
@@ -49,36 +48,74 @@ if [[ ! -d "$CDK_ITESTS_DIR" ]]; then
|
||||
fi
|
||||
|
||||
echo "Temp directory created: $CDK_ITESTS_DIR"
|
||||
export CDK_MINTD_DATABASE="$1"
|
||||
|
||||
# Check if a database type was provided as first argument, default to sqlite
|
||||
export CDK_MINTD_DATABASE="${1:-sqlite}"
|
||||
|
||||
cargo build -p cdk-integration-tests
|
||||
|
||||
|
||||
export CDK_MINTD_URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT"
|
||||
export CDK_MINTD_WORK_DIR="$CDK_ITESTS_DIR"
|
||||
export CDK_MINTD_LISTEN_HOST=$CDK_ITESTS_MINT_ADDR
|
||||
export CDK_MINTD_LISTEN_PORT=$CDK_ITESTS_MINT_PORT
|
||||
export CDK_MINTD_LN_BACKEND="fakewallet"
|
||||
export CDK_MINTD_FAKE_WALLET_SUPPORTED_UNITS="sat,usd"
|
||||
export CDK_MINTD_MNEMONIC="eye survey guilt napkin crystal cup whisper salt luggage manage unveil loyal"
|
||||
export CDK_MINTD_FAKE_WALLET_FEE_PERCENT="0"
|
||||
export CDK_MINTD_FAKE_WALLET_RESERVE_FEE_MIN="1"
|
||||
|
||||
# Start the fake mint binary with the new Rust-based approach
|
||||
echo "Starting fake mint using Rust binary..."
|
||||
if [ "$2" = "external_signatory" ]; then
|
||||
export CDK_MINTD_SIGNATORY_URL="https://127.0.0.1:15060"
|
||||
export CDK_MINTD_SIGNATORY_CERTS="$CDK_ITESTS_DIR"
|
||||
echo "Starting with external signatory support"
|
||||
|
||||
bash -x `dirname $0`/../crates/cdk-signatory/generate_certs.sh $CDK_ITESTS_DIR
|
||||
cargo build --bin signatory
|
||||
cargo run --bin signatory -- -w $CDK_ITESTS_DIR -u "sat" -u "usd" &
|
||||
export CDK_SIGNATORY_PID=$!
|
||||
sleep 5
|
||||
|
||||
cargo run --bin start_fake_mint -- --enable-logging --external-signatory "$CDK_MINTD_DATABASE" "$CDK_ITESTS_DIR" &
|
||||
else
|
||||
cargo run --bin start_fake_mint -- --enable-logging "$CDK_MINTD_DATABASE" "$CDK_ITESTS_DIR" &
|
||||
fi
|
||||
export FAKE_MINT_PID=$!
|
||||
|
||||
# Give the mint a moment to start
|
||||
sleep 3
|
||||
|
||||
# Look for the .env file in the temp directory
|
||||
ENV_FILE_PATH="$CDK_ITESTS_DIR/.env"
|
||||
|
||||
# Wait for the .env file to be created (with longer timeout)
|
||||
max_wait=200
|
||||
wait_count=0
|
||||
while [ $wait_count -lt $max_wait ]; do
|
||||
if [ -f "$ENV_FILE_PATH" ]; then
|
||||
echo ".env file found at: $ENV_FILE_PATH"
|
||||
break
|
||||
fi
|
||||
echo "Waiting for .env file to be created... ($wait_count/$max_wait)"
|
||||
wait_count=$((wait_count + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Check if we found the .env file
|
||||
if [ ! -f "$ENV_FILE_PATH" ]; then
|
||||
echo "ERROR: Could not find .env file at $ENV_FILE_PATH after $max_wait seconds"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Starting fake mintd"
|
||||
cargo run --bin cdk-mintd &
|
||||
export CDK_MINTD_PID=$!
|
||||
# Source the environment variables from the .env file
|
||||
echo "Sourcing environment variables from $ENV_FILE_PATH"
|
||||
source "$ENV_FILE_PATH"
|
||||
|
||||
URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT/v1/info"
|
||||
TIMEOUT=100
|
||||
echo "Sourced environment variables:"
|
||||
echo "CDK_TEST_MINT_URL=$CDK_TEST_MINT_URL"
|
||||
echo "CDK_ITESTS_DIR=$CDK_ITESTS_DIR"
|
||||
|
||||
# Validate that we sourced the variables
|
||||
if [ -z "$CDK_TEST_MINT_URL" ] || [ -z "$CDK_ITESTS_DIR" ]; then
|
||||
echo "ERROR: Failed to source environment variables from the .env file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Export all variables so they're available to the tests
|
||||
export CDK_TEST_MINT_URL
|
||||
|
||||
URL="$CDK_TEST_MINT_URL/v1/info"
|
||||
|
||||
TIMEOUT=120
|
||||
START_TIME=$(date +%s)
|
||||
# Loop until the endpoint returns a 200 OK status or timeout is reached
|
||||
while true; do
|
||||
@@ -107,10 +144,8 @@ while true; do
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
export CDK_TEST_MINT_URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT"
|
||||
|
||||
# Run first test
|
||||
echo "Running fake_wallet test"
|
||||
cargo test -p cdk-integration-tests --test fake_wallet
|
||||
status1=$?
|
||||
|
||||
@@ -121,6 +156,7 @@ if [ $status1 -ne 0 ]; then
|
||||
fi
|
||||
|
||||
# Run second test only if the first one succeeded
|
||||
echo "Running happy_path_mint_wallet test"
|
||||
cargo test -p cdk-integration-tests --test happy_path_mint_wallet
|
||||
status2=$?
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ 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 &
|
||||
cargo run --bin start_regtest -- --enable-logging "$CDK_ITESTS_DIR" &
|
||||
export CDK_REGTEST_PID=$!
|
||||
|
||||
# Create named pipe for progress tracking
|
||||
|
||||
158
misc/itests.sh
158
misc/itests.sh
@@ -4,25 +4,29 @@
|
||||
cleanup() {
|
||||
echo "Cleaning up..."
|
||||
|
||||
echo "Killing the cdk mintd"
|
||||
kill -2 $CDK_MINTD_PID
|
||||
wait $CDK_MINTD_PID
|
||||
|
||||
|
||||
echo "Killing the cdk lnd mintd"
|
||||
kill -2 $CDK_MINTD_LND_PID
|
||||
wait $CDK_MINTD_LND_PID
|
||||
|
||||
echo "Killing the cdk regtest"
|
||||
kill -2 $CDK_REGTEST_PID
|
||||
wait $CDK_REGTEST_PID
|
||||
|
||||
echo "Killing the cdk regtest and mints"
|
||||
if [ ! -z "$CDK_REGTEST_PID" ]; then
|
||||
# First try graceful shutdown with SIGTERM
|
||||
kill -15 $CDK_REGTEST_PID 2>/dev/null
|
||||
sleep 2
|
||||
|
||||
# Check if process is still running, if so force kill with SIGKILL
|
||||
if ps -p $CDK_REGTEST_PID > /dev/null 2>&1; then
|
||||
echo "Process still running, force killing..."
|
||||
kill -9 $CDK_REGTEST_PID 2>/dev/null
|
||||
fi
|
||||
|
||||
# Wait for process to terminate
|
||||
wait $CDK_REGTEST_PID 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo "Mint binary terminated"
|
||||
|
||||
# Remove the temporary directory
|
||||
rm -rf "$CDK_ITESTS_DIR"
|
||||
echo "Temp directory removed: $CDK_ITESTS_DIR"
|
||||
if [ ! -z "$CDK_ITESTS_DIR" ] && [ -d "$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
|
||||
@@ -32,18 +36,6 @@ cleanup() {
|
||||
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
|
||||
@@ -69,53 +61,59 @@ fi
|
||||
echo "Temp directory created: $CDK_ITESTS_DIR"
|
||||
export CDK_MINTD_DATABASE="$1"
|
||||
|
||||
cargo build -p cdk-integration-tests
|
||||
|
||||
cargo run --bin start_regtest &
|
||||
cargo build -p cdk-integration-tests
|
||||
cargo build --bin start_regtest_mints
|
||||
|
||||
echo "Starting regtest and mints"
|
||||
# Run the binary in background
|
||||
cargo r --bin start_regtest_mints -- --enable-logging "$CDK_MINTD_DATABASE" "$CDK_ITESTS_DIR" "$CDK_ITESTS_MINT_ADDR" "$CDK_ITESTS_MINT_PORT_0" "$CDK_ITESTS_MINT_PORT_1" &
|
||||
export CDK_REGTEST_PID=$!
|
||||
mkfifo "$CDK_ITESTS_DIR/progress_pipe"
|
||||
rm -f "$CDK_ITESTS_DIR/signal_received" # Ensure clean state
|
||||
# Start reading from pipe in background
|
||||
(while read line; do
|
||||
case "$line" in
|
||||
"checkpoint1")
|
||||
echo "Reached first checkpoint"
|
||||
touch "$CDK_ITESTS_DIR/signal_received"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done < "$CDK_ITESTS_DIR/progress_pipe") &
|
||||
# Wait for up to 120 seconds
|
||||
for ((i=0; i<120; i++)); do
|
||||
if [ -f "$CDK_ITESTS_DIR/signal_received" ]; then
|
||||
echo "break signal received"
|
||||
|
||||
# Give it a moment to start - reduced from 5 to 2 seconds since we have better waiting mechanisms now
|
||||
sleep 2
|
||||
|
||||
# Look for the .env file in the current directory
|
||||
ENV_FILE_PATH="$CDK_ITESTS_DIR/.env"
|
||||
|
||||
# Wait for the .env file to be created in the current directory
|
||||
max_wait=120
|
||||
wait_count=0
|
||||
while [ $wait_count -lt $max_wait ]; do
|
||||
if [ -f "$ENV_FILE_PATH" ]; then
|
||||
echo ".env file found at: $ENV_FILE_PATH"
|
||||
break
|
||||
fi
|
||||
wait_count=$((wait_count + 1))
|
||||
sleep 1
|
||||
done
|
||||
echo "Regtest set up continuing"
|
||||
|
||||
echo "Starting regtest mint"
|
||||
# cargo run --bin regtest_mint &
|
||||
# Check if we found the .env file
|
||||
if [ ! -f "$ENV_FILE_PATH" ]; then
|
||||
echo "ERROR: Could not find .env file at $ENV_FILE_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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"
|
||||
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
|
||||
# Source the environment variables from the .env file
|
||||
echo "Sourcing environment variables from $ENV_FILE_PATH"
|
||||
source "$ENV_FILE_PATH"
|
||||
|
||||
echo "Starting cln mintd"
|
||||
cargo run --bin cdk-mintd &
|
||||
export CDK_MINTD_PID=$!
|
||||
echo "Sourced environment variables:"
|
||||
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"
|
||||
|
||||
# Validate that we sourced the variables
|
||||
if [ -z "$CDK_TEST_MINT_URL" ] || [ -z "$CDK_TEST_MINT_URL_2" ] || [ -z "$CDK_ITESTS_DIR" ]; then
|
||||
echo "ERROR: Failed to source environment variables from the .env file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo $CDK_ITESTS_DIR
|
||||
# Export all variables so they're available to the tests
|
||||
export CDK_TEST_MINT_URL
|
||||
export CDK_TEST_MINT_URL_2
|
||||
|
||||
URL="$CDK_TEST_MINT_URL/v1/info"
|
||||
|
||||
URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_0/v1/info"
|
||||
|
||||
TIMEOUT=100
|
||||
START_TIME=$(date +%s)
|
||||
@@ -146,24 +144,8 @@ while true; do
|
||||
fi
|
||||
done
|
||||
|
||||
URL="$CDK_TEST_MINT_URL_2/v1/info"
|
||||
|
||||
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"
|
||||
|
||||
echo "Starting lnd mintd"
|
||||
cargo run --bin cdk-mintd &
|
||||
export CDK_MINTD_LND_PID=$!
|
||||
|
||||
URL="http://$CDK_ITESTS_MINT_ADDR:$CDK_ITESTS_MINT_PORT_1/v1/info"
|
||||
|
||||
TIMEOUT=100
|
||||
START_TIME=$(date +%s)
|
||||
@@ -194,13 +176,6 @@ while true; do
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
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"
|
||||
|
||||
# Run tests and exit immediately on failure
|
||||
|
||||
# Run cargo test
|
||||
echo "Running regtest test with CLN mint"
|
||||
cargo test -p cdk-integration-tests --test regtest
|
||||
@@ -216,7 +191,7 @@ if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# # Run cargo test with the http_subscription feature
|
||||
# Run cargo test with the http_subscription feature
|
||||
echo "Running regtest test with http_subscription feature"
|
||||
cargo test -p cdk-integration-tests --test regtest --features http_subscription
|
||||
if [ $? -ne 0 ]; then
|
||||
@@ -233,12 +208,13 @@ fi
|
||||
|
||||
# Switch Mints: Run tests with LND mint
|
||||
echo "Switching to LND mint for tests"
|
||||
export CDK_ITESTS_MINT_PORT_0=8087
|
||||
export CDK_ITESTS_MINT_PORT_1=8085
|
||||
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"
|
||||
|
||||
echo "Running regtest test with LND mint"
|
||||
CDK_TEST_MINT_URL_SWITCHED=$CDK_TEST_MINT_URL_2
|
||||
CDK_TEST_MINT_URL_2_SWITCHED=$CDK_TEST_MINT_URL
|
||||
export CDK_TEST_MINT_URL=$CDK_TEST_MINT_URL_SWITCHED
|
||||
export CDK_TEST_MINT_URL_2=$CDK_TEST_MINT_URL_2_SWITCHED
|
||||
|
||||
cargo test -p cdk-integration-tests --test regtest
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "regtest test with LND mint failed, exiting"
|
||||
|
||||
@@ -80,7 +80,7 @@ cargo build -p cdk-integration-tests
|
||||
export CDK_TEST_REGTEST=0
|
||||
if [ "$LN_BACKEND" != "FAKEWALLET" ]; then
|
||||
export CDK_TEST_REGTEST=1
|
||||
cargo run --bin start_regtest &
|
||||
cargo run --bin start_regtest "$CDK_ITESTS_DIR" &
|
||||
CDK_REGTEST_PID=$!
|
||||
mkfifo "$CDK_ITESTS_DIR/progress_pipe"
|
||||
rm -f "$CDK_ITESTS_DIR/signal_received" # Ensure clean state
|
||||
|
||||
@@ -58,6 +58,9 @@ export CDK_MINTD_FAKE_WALLET_RESERVE_FEE_MIN="1"
|
||||
export CDK_MINTD_INPUT_FEE_PPK="100"
|
||||
|
||||
|
||||
export CDK_ITESTS_DIR="$CDK_ITESTS"
|
||||
|
||||
|
||||
echo "Starting fake mintd"
|
||||
cargo run --bin cdk-mintd &
|
||||
CDK_MINTD_PID=$!
|
||||
|
||||
Reference in New Issue
Block a user