Skip to content

Commit

Permalink
Update private tangle setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed Sep 4, 2023
1 parent b14d7eb commit 289889f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 71 deletions.
55 changes: 22 additions & 33 deletions .github/actions/private-tangle/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,36 @@
name: 'private-tangle-setup'
description: 'Setup a private tangle'
name: "private-tangle-setup"
description: "Setup a private tangle"
runs:
using: "composite"
steps:
- name: Clone private tangle files
uses: actions/checkout@v3
with:
repository: iotaledger/hornet
path: hornet
repository: iotaledger/iota-core
path: iota-core

- name: Prepare files for start and stop
shell: bash
run: |
echo "docker compose down -v" >> cleanup.sh
echo "rm *.snapshot" >> cleanup.sh
chmod +x cleanup.sh
sed -i -n -e :a -e '1,5!{P;N;D;};N;ba' run.sh
echo "docker compose -f \$DOCKER_COMPOSE_FILE up -d" >> run.sh
working-directory: iota-core/tools/docker-network

- name: Setup private tangle
shell: bash
run: |
# TODO: use next lines when a working hornet release is published
# # Download the private_tangle setup from the hornet repo.
# mkdir private_tangle
# cd private_tangle
# # Use the output of https://api.github.com/repos/iotaledger/hornet/releases/latest once there's a 2.0 Hornet release.
# DOWNLOAD_URL=$(curl "https://api.github.com/repos/iotaledger/hornet/releases" | jq -r '.[0].assets[] | select(.name | contains("private_tangle")) | .browser_download_url')
# echo "Downloading private tangle from $DOWNLOAD_URL"
# curl -L -o private_tangle.tar.gz $DOWNLOAD_URL
# tar -xf private_tangle.tar.gz
# TODO: remove next lines when a working hornet release is published
# Set protocol_parameters to the same values as in the shimmer network
jq '.tokenSupply="1813620509061365" | .rentStructure.vByteCost=100 | .bech32HRP="rms"' protocol_parameters.json > tmp.json && mv tmp.json protocol_parameters.json
jq --color-output . protocol_parameters.json
# Reduce milestone interval to 1 second
yq eval '.services.inx-coordinator.command += "--coordinator.interval=1s"' docker-compose.yml > tmp.yml && mv tmp.yml docker-compose.yml
jq --color-output . config_private_tangle.json
# Start Tangle
sudo ./cleanup.sh
sudo ./bootstrap.sh
sudo ./run.sh -d --quiet-pull
working-directory: hornet/private_tangle
sudo ./run.sh
working-directory: iota-core/tools/docker-network

- name: Wait for tangle to start
shell: bash
run: wget -qO- https://raw.githubusercontent.com/eficode/wait-for/$WAIT_FOR_VERSION/wait-for | sh -s -- -t 60 http://localhost:14265/health -- echo "Tangle is up"
env:
WAIT_FOR_VERSION: 4df3f9262d84cab0039c07bf861045fbb3c20ab7 # v2.2.3
- name: Wait for faucet to start
shell: bash
run: wget -qO- https://raw.githubusercontent.com/eficode/wait-for/$WAIT_FOR_VERSION/wait-for | sh -s -- -t 60 http://localhost:8091/api/info -- echo "Faucet is up"
env:
WAIT_FOR_VERSION: 4df3f9262d84cab0039c07bf861045fbb3c20ab7 # v2.2.3
run: wget -qO- https://raw.githubusercontent.com/eficode/wait-for/v2.2.4/wait-for | sh -s -- -t 120 http://localhost:8080/health -- echo "Tangle is up"
# TODO enable, maybe need another URL
# - name: Wait for faucet to start
# shell: bash
# run: wget -qO- https://raw.githubusercontent.com/eficode/wait-for/v2.2.4/wait-for | sh -s -- -t 120 http://localhost:8081/api/info -- echo "Faucet is up"
8 changes: 3 additions & 5 deletions .github/actions/private-tangle/tear-down/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ runs:
- name: Tear down private tangle
shell: bash
run: |
# TODO: use next line when a working hornet release is published
#cd private_tangle
# TODO: remove next line when a working hornet release is published
sudo ./cleanup.sh
working-directory: hornet/private_tangle
# sudo docker compose kill
# sudo docker compose down
working-directory: iota-core/tools/docker-network
41 changes: 22 additions & 19 deletions .github/workflows/private-tangle-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,32 @@ jobs:
steps:
- uses: actions/checkout@v3

# - name: Install toolchain
# uses: dtolnay/rust-toolchain@stable
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable

# - name: Install required packages
# run: |
# sudo apt-get update
# sudo apt-get install libudev-dev libusb-1.0-0-dev
- name: Install required packages
run: |
sudo apt-get update
sudo apt-get install libudev-dev libusb-1.0-0-dev
# - name: Install Nextest
# uses: taiki-e/install-action@nextest
- name: Install Nextest
uses: taiki-e/install-action@nextest

# - name: Cache dependencies
# uses: Swatinem/rust-cache@v2
- name: Cache dependencies
uses: Swatinem/rust-cache@v2

# - name: Start private tangle
# uses: "./.github/actions/private-tangle/setup"
- name: Start private tangle
uses: "./.github/actions/private-tangle/setup"

# - name: Start ledger nano
# uses: "./.github/actions/ledger-nano"
- name: Start ledger nano
uses: "./.github/actions/ledger-nano"

# - name: Run tests
# run: cargo nextest run --tests --all-features --run-ignored ignored-only --profile ci --cargo-profile ci -p iota-sdk -p iota-sdk-bindings-core
- name: Run nodeinfo test
run: |
cargo nextest run test_get_info --all-features --run-ignored ignored-only --profile ci --cargo-profile ci -p iota-sdk -p iota-sdk-bindings-core --no-capture
# TODO: change in the future to run all tests and not only test_get_info
# cargo nextest run --tests --all-features --run-ignored ignored-only --profile ci --cargo-profile ci -p iota-sdk -p iota-sdk-bindings-core
# - name: Tear down private tangle
# if: always()
# uses: "./.github/actions/private-tangle/tear-down"
- name: Tear down private tangle
if: always()
uses: "./.github/actions/private-tangle/tear-down"
27 changes: 14 additions & 13 deletions sdk/src/client/node_api/core/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,19 +432,20 @@ impl Client {
}
url.set_path(INFO_PATH);

let resp: InfoResponse =
crate::client::node_manager::http_client::HttpClient::new(DEFAULT_USER_AGENT.to_string())
.get(
Node {
url,
auth,
disabled: false,
},
DEFAULT_API_TIMEOUT,
)
.await?
.into_json()
.await?;
let resp = crate::client::node_manager::http_client::HttpClient::new(DEFAULT_USER_AGENT.to_string())
.get(
Node {
url,
auth,
disabled: false,
},
DEFAULT_API_TIMEOUT,
)
.await?;
// TODO: don't convert into_text(), but use into_json() directly, only for testing of the private tangle now
let node_info = resp.into_text().await?;
println!("info response {node_info}");
let resp: InfoResponse = serde_json::from_str(&node_info)?;

Ok(resp)
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/tests/client/common/constants.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

pub static NODE_LOCAL: &str = "http://localhost:14265";
pub static NODE_LOCAL: &str = "http://localhost:8080";

pub static FAUCET_URL: &str = "http://localhost:8091/api/enqueue";

0 comments on commit 289889f

Please sign in to comment.