Skip to content
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

feat: add example for using javascript SDK #832

Merged
merged 45 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
db835ea
add test sdk client
JeffreyDallas Nov 12, 2024
b37203a
save
JeffreyDallas Nov 12, 2024
f2fca67
Fix account test
JeffreyDallas Nov 12, 2024
c78dbb8
add steps to launch solo network
JeffreyDallas Nov 13, 2024
8599657
fix relay test
JeffreyDallas Nov 13, 2024
00eef83
fix change background traffic without using watch command
JeffreyDallas Nov 13, 2024
84d52bd
change local node version
JeffreyDallas Nov 13, 2024
4370b50
add step for using sdk sample
JeffreyDallas Nov 14, 2024
9169373
update relay test flow
JeffreyDallas Nov 14, 2024
8f79b5b
add clean port forward
JeffreyDallas Nov 14, 2024
d6cc4d4
add sdk test
JeffreyDallas Nov 14, 2024
75474db
change script name
JeffreyDallas Nov 14, 2024
6ed3be0
check port forwarding
JeffreyDallas Nov 14, 2024
3bb7aaa
fix task command
JeffreyDallas Nov 15, 2024
ca48359
fix namespace
JeffreyDallas Nov 15, 2024
ed60444
add test sleep
JeffreyDallas Nov 15, 2024
3986031
save
JeffreyDallas Nov 15, 2024
0086fd5
nmp install sdk
JeffreyDallas Nov 15, 2024
fab9f99
add ps ef for debug
JeffreyDallas Nov 15, 2024
09e45eb
capture error
JeffreyDallas Nov 15, 2024
16f7d0b
force port forward
JeffreyDallas Nov 15, 2024
63aec6c
run generate key in a loop
JeffreyDallas Nov 16, 2024
2b14cfa
fix
JeffreyDallas Nov 16, 2024
b9dad57
save
JeffreyDallas Nov 16, 2024
3fcf5c3
save
JeffreyDallas Nov 16, 2024
924b88b
add timeout
JeffreyDallas Nov 16, 2024
c3228f3
run longer
JeffreyDallas Nov 16, 2024
aa67662
update sleep time
JeffreyDallas Nov 16, 2024
efd3957
change round number
JeffreyDallas Nov 18, 2024
a4e1fa2
update retry function
JeffreyDallas Nov 18, 2024
32e863e
set 20 minutes timeout
JeffreyDallas Nov 18, 2024
508a89d
add sleep period
JeffreyDallas Nov 18, 2024
fbfcff6
update task name
JeffreyDallas Nov 18, 2024
efe8846
update readme and smoke test
JeffreyDallas Nov 18, 2024
8bc99c9
use helper taskfile.yml
jeromy-cannon Nov 18, 2024
4c3526c
empty readme
jeromy-cannon Nov 18, 2024
0964f5a
starting a solo network connection ts example
jeromy-cannon Nov 18, 2024
22e34f0
create helper file
jeromy-cannon Nov 18, 2024
9f530e1
fixed bugs
jeromy-cannon Nov 19, 2024
da5daa5
Fix private key extraction
JeffreyDallas Nov 19, 2024
96d06c6
add solo network connection example
jeromy-cannon Nov 19, 2024
cc19979
Merge commit '7fa86ad19c66d2ea98d4d10b0400b1635499c322' into 00816-D-…
JeffreyDallas Nov 21, 2024
2b2406b
Merge branch 'main' into 00816-D-client-doc-example
JeffreyDallas Nov 22, 2024
6d53ab1
revert
JeffreyDallas Nov 22, 2024
f01c890
remove smoke test
JeffreyDallas Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/flow-task-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ name: "Test Taskfile Commands"
# The purpose of this reusable workflow is to make sure task files are working as expected.

on:
workflow_dispatch:
workflow_call:
pull_request:
types:
Expand All @@ -35,6 +36,7 @@ permissions:

jobs:
example-task-file-test:
timeout-minutes: 20
runs-on: solo-linux-large
steps:
- name: Harden Runner
Expand All @@ -51,6 +53,16 @@ jobs:
node-version: 20
cache: npm

- name: Setup Kind
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
with:
install_only: true
node_image: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
version: v0.21.0
kubectl_version: v1.28.6
verbosity: 3
wait: 120s

- name: Install Dependencies
id: npm-deps
run: npm ci
Expand All @@ -60,6 +72,5 @@ jobs:

- name: Run Example Task File Test
run: |
task readme
task default-with-mirror
task default-with-relay
task clean
82 changes: 0 additions & 82 deletions .github/workflows/script/relay_smoke_test.sh
jeromy-cannon marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

7 changes: 1 addition & 6 deletions .github/workflows/zxc-e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ name: "ZXC: E2E Test"
# - .github/workflows/flow-build-application.yaml

on:
workflow_dispatch:
workflow_call:
inputs:
node-version:
Expand Down Expand Up @@ -181,12 +182,6 @@ jobs:
run: |
${{ env.CG_EXEC }} npm run ${{ inputs.npm-test-script }}

- name: RPC relay smoke test
if: ${{ runner.os == 'linux' && inputs.npm-test-script == 'test-e2e-relay' && !cancelled() && !failure() }}
run: |
echo "Skipped smoke test for relay"
#.github/workflows/script/relay_smoke_test.sh

- name: Upload E2E Logs to GitHub
if: ${{ !cancelled() }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
Expand Down
184 changes: 184 additions & 0 deletions HelperTasks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
version: 3
output: prefixed
silent: false
vars:
nodes:
ref: until (env "SOLO_NETWORK_SIZE" | default .SOLO_NETWORK_SIZE | int)
# node name should be node1, node2, node3, etc.
node_list_internal: "{{range $idx, $n := .nodes }}node{{add $n 1}},{{end}}"
node_identifiers: "{{ .node_list_internal | trimSuffix \",\" }}"

solo_user_dir: "{{ env \"HOME\" }}/.solo"
solo_cache_dir: "{{ .solo_user_dir }}/cache"
solo_logs_dir: "{{ .solo_user_dir }}/logs"
solo_keys_dir: "{{ .solo_cache_dir }}/keys"
solo_bin_dir: "{{ .solo_user_dir }}/bin"

tasks:
readme:
silent: true
cmds:
- echo "This is a custom network configuration for the Hedera Hashgraph Solo network."
- echo "The network is configured to have {{ .SOLO_NETWORK_SIZE }} nodes."
- echo "The network is deployed in the namespace {{ .SOLO_NAMESPACE }}."
- echo "The cluster is deployed in the namespace {{ .SOLO_CLUSTER_SETUP_NAMESPACE }}."
- echo "Use command 'task default' to deploy the network."
- echo "Use command 'task destroy' to destroy the network."
- echo "Use command 'task clean' to destroy and clean up the network."
- echo "Use command 'task show:ips' to show the external IPs of the nodes."
- echo "Use command 'task default-with-mirror' to deploy the network with a mirror node."
- echo "Use command 'task default-with-relay' to deploy the network with a relay node."

install:solo:
internal: true
status:
- command -v solo
cmds:
- npm install -g @hashgraph/solo
- cd ../..
- npm link

install:kubectl:darwin:
internal: true
platforms:
- darwin
status:
- command -v kubectl
cmds:
- brew update
- brew install kubernetes-cli

install:kubectl:linux:
internal: true
platforms:
- linux
status:
- command -v kubectl
cmds:
- curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/{{ ARCH }}/kubectl"
- sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
- rm -rf kubectl

solo:init:
internal: true
status:
- test -f {{ .solo_bin_dir }}/helm
- test -f {{ .solo_cache_dir }}/profiles/custom-spec.yaml
- test -f {{ .solo_cache_dir }}/templates/api-permission.properties
- test -f {{ .solo_cache_dir }}/templates/application.properties
- test -f {{ .solo_cache_dir }}/templates/bootstrap.properties
- test -f {{ .solo_cache_dir }}/templates/settings.txt
- test -f {{ .solo_cache_dir }}/templates/log4j2.xml
#- test "$(yq -r '.flags."node-ids"' < {{ .solo_user_dir }}/solo.yaml)" == "{{ .node_identifiers }}"
- test "$(jq -r '.flags."node-ids"' < {{ .solo_user_dir }}/solo.config)" == "{{ .node_identifiers }}"
cmds:
- npm run build
- solo init

solo:keys:
internal: true
status:
- |
for n in $(seq 0 {{ sub (env "SOLO_NETWORK_SIZE" | default .SOLO_NETWORK_SIZE | int) 1 }}); do
test -f {{ .solo_keys_dir }}/hedera-node${n}.crt
test -f {{ .solo_keys_dir }}/hedera-node${n}.key
test -f {{ .solo_keys_dir }}/s-public-node${n}.pem
test -f {{ .solo_keys_dir }}/s-private-node${n}.pem
done
cmds:
- npm run build
- solo node keys --gossip-keys --tls-keys --node-aliases-unparsed {{.node_identifiers}}

solo:network:deploy:
internal: true
cmds:
- npm run build
- solo network deploy --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} --release-tag "${CONSENSUS_NODE_VERSION}" --solo-chart-version "${SOLO_CHART_VERSION}"
- solo node setup --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} --release-tag "${CONSENSUS_NODE_VERSION}"

solo:network:destroy:
internal: true
cmds:
- npm run build
- solo network destroy --namespace "${SOLO_NAMESPACE}" --delete-pvcs --delete-secrets --force

solo:node:start:
internal: true
cmds:
- npm run build
- solo node start --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} {{ .CLI_ARGS }}
- kubectl port-forward -n "${SOLO_NAMESPACE}" svc/haproxy-node1-svc 50211:50211 &
- task: "sleep_after_port_forward"

solo:node:stop:
internal: true
ignore_error: true
cmds:
- npm run build
- solo node stop --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} {{ .CLI_ARGS }}

solo:node:addresses:
internal: true
cmds:
- kubectl get svc -n "${SOLO_NAMESPACE}" -l "solo.hedera.com/type=network-node-svc"

solo:relay:
cmds:
- npm run build
- solo relay deploy -n "${SOLO_NAMESPACE}" -i node1
- echo "Enable port forwarding for Hedera JSON RPC Relay"
- kubectl port-forward -n "${SOLO_NAMESPACE}" svc/relay-node1-hedera-json-rpc-relay 7546:7546 &
- task: "sleep_after_port_forward"

solo:destroy-relay:
status:
- helm list -n "${SOLO_NAMESPACE}" | grep -vqz relay-node1
cmds:
- npm run build
- solo relay destroy -n "${SOLO_NAMESPACE}" -i node1

solo:cache:remove:
internal: true
status:
- test [[ ! -d {{ .solo_cache_dir }} ]]
cmds:
- rm -rf {{ .solo_cache_dir }}

solo:logs:remove:
internal: true
status:
- test [[ ! -d {{ .solo_logs_dir }} ]]
cmds:
- rm -rf {{ .solo_logs_dir }}

solo:config:remove:
internal: true
status:
- test [[ ! -f {{ .solo_user_dir }}/solo.yaml ]]
cmds:
- rm -rf {{ .solo_user_dir }}/solo.yaml

cluster:create:
status:
- kind get clusters | grep -q "${SOLO_CLUSTER_NAME}"
cmds:
- kind create cluster -n "${SOLO_CLUSTER_NAME}" --image "${KIND_IMAGE}"

cluster:setup:
cmds:
- npm run build
- solo cluster setup --cluster-setup-namespace "${SOLO_CLUSTER_SETUP_NAMESPACE}"

cluster:destroy:
cmds:
- kind delete cluster --name "${SOLO_CLUSTER_NAME}"

clean:port-forward:
cmds:
- pkill -f "kubectl port-forward -n {{ .SOLO_NAMESPACE }}" || true

sleep_after_port_forward:
cmds:
# somehow without the sleep, when port-forward is the last command of a series of tasks, port-forward
# prematurely killed when task is exiting
- sleep 4
Loading
Loading