-
Notifications
You must be signed in to change notification settings - Fork 54
test(sdk): generate test vectors using testnet #2381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
63d66a9
test(sdk): generate test vectors using testnet
lklimek 39d05d0
chore: some docs
lklimek 8a7a241
doc(sdk): document connect_to_remote.sh
lklimek 8ca5608
chore: clippy warn
lklimek 8737420
chore: apply coderabbit suggestions
lklimek 36a1328
Merge branch 'v1.7-dev' into test/sdk-test-vectors-tunnel
lklimek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 ubuntu@1.2.3.4 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.