-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(sdk): generate test vectors using testnet (#2381)
- Loading branch information
Showing
6 changed files
with
111 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#! /bin/bash | ||
|
||
set -e -o pipefail | ||
|
||
CORE_USER=dashmate | ||
|
||
function usage() { | ||
|
||
echo This script connects to a remote node and runs the SDK tests on it. | ||
echo It establishes SSH tunnel to the remote node and uses DAPI and Core RPC | ||
echo services running on the remote node to run the tests. | ||
echo | ||
echo Note: you can use | ||
echo | ||
echo "Usage: $0 <remote-user@remote-node> [ssh arguments]" | ||
echo " remote-user: The username to use for SSH connection." | ||
echo " remote-node: The IP address or hostname of the remote node." | ||
echo " ssh arguments: Additional arguments to pass to the SSH command." | ||
echo | ||
echo "Example: $0 [email protected] sudo -u dashmate" | ||
exit 1 | ||
} | ||
|
||
if [ "$#" -lt 1 ]; then | ||
usage | ||
fi | ||
|
||
REMOTE="$1" | ||
|
||
# Validate remote format | ||
if ! echo "$REMOTE" | grep -q "@"; then | ||
echo "Error: Remote must be in format user@host" | ||
usage | ||
fi | ||
|
||
# REMOTE_USER=$(echo "$1" | cut -d@ -f1) | ||
REMOTE_NODE=$(echo "$1" | cut -d@ -f2) | ||
|
||
SSH_ARGS=${*:2} | ||
|
||
echo -n Reading configuration from remote "$REMOTE" using \`dashmate config get\` command... | ||
# read core username and password from the remote node | ||
CORE_PORT=$(ssh "$REMOTE" ${SSH_ARGS} dashmate config get core.rpc.port) | ||
CORE_PASSWORD=$(ssh "$REMOTE" ${SSH_ARGS} dashmate config get "core.rpc.users.${CORE_USER}.password") | ||
|
||
DAPI_PORT=$(ssh "$REMOTE" ${SSH_ARGS} dashmate config get platform.gateway.listeners.dapiAndDrive.port) | ||
DAPI_SSL_ENABLED=$(ssh "$REMOTE" ${SSH_ARGS} dashmate config get platform.gateway.ssl.enabled) | ||
|
||
echo " done." | ||
|
||
# Double check that the variables are set | ||
if [ -z "$CORE_PORT" ] || [ -z "$CORE_PASSWORD" ] || [ -z "$DAPI_PORT" ] || [ -z "$DAPI_SSL_ENABLED" ]; then | ||
echo "Failed to read configuration from the remote node." | ||
exit 1 | ||
fi | ||
|
||
ENV_FILE="$(realpath "$0" | xargs dirname)/../tests/.env" | ||
echo -n Generating "${ENV_FILE}" file for the SDK tests... | ||
|
||
cat >"${ENV_FILE}" <<EOF | ||
# Configuration of tests and examples, generated by $(realpath "$0") | ||
DASH_SDK_PLATFORM_HOST="${REMOTE_NODE}" | ||
DASH_SDK_PLATFORM_PORT=${DAPI_PORT} | ||
DASH_SDK_PLATFORM_SSL=${DAPI_SSL_ENABLED} | ||
DASH_SDK_CORE_HOST=127.0.0.1 | ||
DASH_SDK_CORE_PORT=12367 | ||
DASH_SDK_CORE_USER="${CORE_USER}" | ||
DASH_SDK_CORE_PASSWORD="${CORE_PASSWORD}" | ||
EOF | ||
|
||
trap 'rm -f "${ENV_FILE}"' INT TERM EXIT # cleanup | ||
|
||
chmod 600 "${ENV_FILE}" | ||
|
||
echo " done." | ||
echo | ||
echo "Configured DAPI endpoint: ${REMOTE_NODE}:${DAPI_PORT}, SSL: ${DAPI_SSL_ENABLED}" | ||
echo | ||
echo "Establishing SSH tunnel to the remote node ${REMOTE_NODE} to forward Dash Core RPC:" | ||
echo " 127.0.0.1:12367-> ${REMOTE_NODE}:${CORE_PORT}" | ||
echo | ||
echo "To stop the tunnel, press Ctrl+C." | ||
|
||
ssh -L "12367:127.0.0.1:${CORE_PORT}" "$REMOTE" \ | ||
-o ServerAliveInterval=60 \ | ||
-o ServerAliveCountMax=3 \ | ||
-o ExitOnForwardFailure=yes \ | ||
-N ${SSH_ARGS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters