123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #!/usr/bin/env bash
- cleanup() {
- echo "Cleaning up..."
- echo "Killing the cdk mintd"
- kill -2 $cdk_mintd_pid
- wait $cdk_mintd_pid
- echo "Mint binary terminated"
-
-
- rm -rf "$cdk_itests"
- echo "Temp directory removed: $cdk_itests"
- unset cdk_itests
- unset cdk_itests_mint_addr
- unset cdk_itests_mint_port
- }
- trap cleanup EXIT
- export cdk_itests=$(mktemp -d)
- export cdk_itests_mint_addr="127.0.0.1";
- export cdk_itests_mint_port=8086;
- if [[ ! -d "$cdk_itests" ]]; then
- echo "Failed to create temp directory"
- exit 1
- fi
- echo "Temp directory created: $cdk_itests"
- export MINT_DATABASE="$1";
- 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";
- 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";
- export CDK_MINTD_DATABASE=$MINT_DATABASE;
- echo "Starting fake mintd";
- cargo run --bin cdk-mintd &
- cdk_mintd_pid=$!
- URL="http://$cdk_itests_mint_addr:$cdk_itests_mint_port/v1/info"
- TIMEOUT=100
- START_TIME=$(date +%s)
- while true; do
-
- CURRENT_TIME=$(date +%s)
-
-
- ELAPSED_TIME=$((CURRENT_TIME - START_TIME))
-
- if [ $ELAPSED_TIME -ge $TIMEOUT ]; then
- echo "Timeout of $TIMEOUT seconds reached. Exiting..."
- exit 1
- fi
-
- HTTP_STATUS=$(curl -o /dev/null -s -w "%{http_code}" $URL)
-
- 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
- fi
- done
- cargo test -p cdk-integration-tests --test fake_wallet
- test_status=$?
- exit $test_status
|