1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #!/usr/bin/env bash
- cleanup() {
- echo "Cleaning up..."
-
- echo "Killing the Rust binary with PID $RUST_BIN_PID"
- kill $CDK_ITEST_MINT_BIN_PID
-
- wait $CDK_ITEST_MINT_BIN_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;
- URL="http://$cdk_itests_mint_addr:$cdk_itests_mint_port/v1/info"
- 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
- cargo build --bin fake_wallet
- cargo run --bin fake_wallet &
- CDK_ITEST_MINT_BIN_PID=$!
- 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
|