diff --git a/.github/scripts/ensure_set_euox_pipefail.sh b/.github/scripts/ensure_set_euox_pipefail.sh index 7cfdfc2a7..2dd9fbfdf 100644 --- a/.github/scripts/ensure_set_euox_pipefail.sh +++ b/.github/scripts/ensure_set_euox_pipefail.sh @@ -6,18 +6,21 @@ set -euo pipefail INVALID_FILES_FOUND=0 -for BASH_SCRIPT in $(find . -type f -name "*.sh") +while IFS= read -r -d '' BASH_SCRIPT do + echo "checking ${BASH_SCRIPT}" if ( ! grep -q "set -euo pipefail" "${BASH_SCRIPT}" ) && ( ! grep -q "set -euox pipefail" "${BASH_SCRIPT}" ) then echo "${BASH_SCRIPT}" INVALID_FILES_FOUND=1 fi -done +done < <(find . -type f -name "*.sh" -print0) # See https://github.com/koalaman/shellcheck/wiki/SC2044 if [[ INVALID_FILES_FOUND -eq 1 ]] then echo "" echo "The bash scripts above must include either 'set -euo pipefail' or 'set -euox pipefail." exit 1 +else + echo "euox-pipefaile check finished successfully" fi diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c7a619f45..77069c6a7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -55,6 +55,7 @@ jobs: VALIDATE_XML: true VALIDATE_YAML: true VALIDATE_OPENAPI: true + VALIDATE_BASH: true VALIDATE_ALL_CODEBASE: true LOG_LEVEL: WARN diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3e3d0ac30..893ba7eeb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,37 +6,12 @@ on: - "v*" jobs: - setup-workflow: - name: "Setup workflow" - runs-on: ubuntu-latest - outputs: - GITHUB_REPOSITORY_NAME: ${{ steps.cache.outputs.GITHUB_REPOSITORY_NAME }} - GITHUB_ORG_NAME: ${{ steps.cache.outputs.GITHUB_ORG_NAME }} - TAG: ${{ steps.cache.outputs.TAG }} - VERSION: ${{ steps.cache.outputs.VERSION }} - steps: - - name: Git checkout - uses: actions/checkout@v2 - - - name: Set outputs - id: cache - run: | - # Exposes org_name in lower case. Required by Docker. - echo "::set-output name=GITHUB_ORG_NAME::$(echo ${GITHUB_REPOSITORY_OWNER,,})" - - # Exposes org_name/repository_name in lower case. Required by Docker. - echo "::set-output name=GITHUB_REPOSITORY_NAME::$(echo ${GITHUB_REPOSITORY,,})" - - # Version is tag without `v` prefix. Required by Debian package. - TAG=${GITHUB_REF/refs\/tags\//} - echo "::set-output name=TAG::$TAG" - - VERSION="${TAG:1}" # Remove first character - echo "::set-output name=VERSION::$VERSION" build-binary: name: Build binary runs-on: ubuntu-20.04 + outputs: + VERSION: ${{ steps.set-version.outputs.VERSION }} steps: - name: Set up Go 1.17 uses: actions/setup-go@v2 @@ -81,13 +56,18 @@ jobs: name: cheqd-noded path: build/cheqd-noded - build-deb-package: - name: Build Debian package + - name: Set version + id: set-version + run: | + VERSION=$(build/cheqd-noded version 2>&1) + echo "::set-output name=VERSION::$VERSION" + + build-tar-package: + name: Build tar package runs-on: ubuntu-20.04 - needs: [ build-binary, setup-workflow ] + needs: build-binary env: - PACKAGE_NAME: "cheqd-node" - VERSION: ${{ needs.setup-workflow.outputs.VERSION }} + VERSION: ${{ needs.build-binary.outputs.VERSION }} steps: - uses: actions/checkout@v2 @@ -95,45 +75,67 @@ jobs: uses: actions/download-artifact@v2 with: name: cheqd-noded - path: /home/runner/go/bin - name: Restore binary permissions - run: sudo chmod +x /home/runner/go/bin/cheqd-noded + run: sudo chmod +x cheqd-noded - - name: Make intermediate archive + - name: Build tar working-directory: ./build-tools run: | - ./build-tar.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} + ./build-tar.sh "../cheqd-noded" + + - name: Store tar package artifact + uses: actions/upload-artifact@v2 + with: + name: cheqd-node_${{ env.VERSION }}.tar.gz + path: build-tools/output/cheqd-node_${{ env.VERSION }}.tar.gz + + build-deb-package: + name: Build Debian package + runs-on: ubuntu-20.04 + needs: [ build-binary ] + env: + VERSION: ${{ needs.build-binary.outputs.VERSION }} + steps: + - uses: actions/checkout@v2 + + - name: Load binary artifact + uses: actions/download-artifact@v2 + with: + name: cheqd-noded + + - name: Restore binary permissions + run: sudo chmod +x cheqd-noded - name: Install fpm run: | sudo apt-get install ruby ruby-dev rubygems build-essential sudo gem install --no-document fpm - - name: Build Debian package # Depends on tar archive + - name: Build deb working-directory: ./build-tools run: | - ./build-deb.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} + ./build-deb.sh "../cheqd-noded" - name: Store Debian package artifact uses: actions/upload-artifact@v2 with: - name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb - path: build-tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb + name: cheqd-node_${{ env.VERSION }}_amd64.deb + path: build-tools/output/cheqd-node_${{ env.VERSION }}_amd64.deb - build-node-image: - name: Build cheqd-node Docker image + build-node-images: + name: Build cheqd-node and cheqd-cli images runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 with: - fetch-depth: 0 # FIXME: Starport requires full repository + fetch-depth: 0 # Required to fetch version - name: Build cheqd-cli with 'cheqd-noded' as entrypoint - run: docker build --target base -t cheqd-cli -f docker/Dockerfile --build-arg UID=$(id -u) --build-arg GID=$(id -g) . + run: docker build --target base -t cheqd-cli -f docker/Dockerfile . - name: Build cheqd-node with 'node-start' as entrypoint - run: docker build --target node -t cheqd-node -f docker/Dockerfile --build-arg UID=$(id -u) --build-arg GID=$(id -g) . + run: docker build --target node -t cheqd-node -f docker/Dockerfile . - name: Save cheqd-cli run: docker save -o cheqd-cli-image.tar cheqd-cli @@ -156,7 +158,7 @@ jobs: build-testnet-image: name: Build cheqd-testnet image runs-on: ubuntu-20.04 - needs: build-node-image + needs: build-node-images steps: - name: Check out uses: actions/checkout@v2 @@ -184,15 +186,10 @@ jobs: publish: name: "Publish images and release" # Reference to workflow-setup job is required to access its various outputs. - needs: [ setup-workflow, build-node-image, build-testnet-image, build-deb-package ] + needs: [ build-binary, build-node-images, build-testnet-image, build-deb-package, build-tar-package ] runs-on: ubuntu-latest env: - GITHUB_REPOSITORY_NAME: ${{ needs.setup-workflow.outputs.GITHUB_REPOSITORY_NAME }} - GITHUB_ORG_NAME: ${{ needs.setup-workflow.outputs.GITHUB_ORG_NAME }} - TAG: ${{ needs.setup-workflow.outputs.TAG }} - VERSION: ${{ needs.setup-workflow.outputs.VERSION }} - PACKAGE_NAME: "cheqd-node" - TESTNET_IMAGE_NAME: "cheqd-testnet" + VERSION: ${{ needs.build-binary.outputs.VERSION }} steps: - name: Git checkout uses: actions/checkout@v2 @@ -227,10 +224,10 @@ jobs: - name: Push cheqd-node image run: | - docker tag cheqd-node ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:${{ env.VERSION }} - docker tag cheqd-node ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:latest - docker push ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:${{ env.VERSION }} - docker push ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:latest + docker tag cheqd-node ghcr.io/${{ github.repository }}:${{ env.VERSION }} + docker tag cheqd-node ghcr.io/${{ github.repository }}:latest + docker push ghcr.io/${{ github.repository }}:${{ env.VERSION }} + docker push ghcr.io/${{ github.repository }}:latest - name: Push cheqd-cli image @@ -242,32 +239,26 @@ jobs: - name: Push testnet image run: | - docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:${{ env.VERSION }} - docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:latest - docker push ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:${{ env.VERSION }} - docker push ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:latest + docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/cheqd-testnet:${{ env.VERSION }} + docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/cheqd-testnet:latest + docker push ghcr.io/${{ github.repository_owner }}/cheqd-testnet:${{ env.VERSION }} + docker push ghcr.io/${{ github.repository_owner }}/cheqd-testnet:latest - name: Download deb uses: actions/download-artifact@v2 with: - name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb + name: cheqd-node_${{ env.VERSION }}_amd64.deb - - name: Load binary artifact + - name: Download tar uses: actions/download-artifact@v2 with: - name: cheqd-noded - - - name: Restore binary permissions - run: sudo chmod +x cheqd-noded - - - name: Make tar archive - run: tar -zcvf ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz cheqd-noded + name: cheqd-node_${{ env.VERSION }}.tar.gz - uses: "marvinpinto/action-automatic-releases@latest" with: repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "${{ env.TAG }}" + automatic_release_tag: "${{ env.GITHUB_REF_NAME }}" prerelease: true files: | - ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb - ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz + cheqd-node_${{ env.VERSION }}_amd64.deb + cheqd-node_${{ env.VERSION }}.tar.gz diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 667282da0..7e46b27c1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,9 +9,7 @@ on: - '.gitbook/**' env: - NODE_CONFIGS_BASE: "/home/runner/work/cheqd-node/cheqd-node/tests/networks/docker-compose-localnet/node_configs" - PACKAGE_NAME: "cheqd-node" - VERSION: "1.0.0" # Package build scripts require version to be provided + NODE_CONFIGS_BASE: "/home/runner/work/cheqd-node/cheqd-node/tests/networks/docker-compose-localnet/network-config" jobs: @@ -32,6 +30,8 @@ jobs: build-binary: name: Build binary runs-on: ubuntu-20.04 + outputs: + VERSION: ${{ steps.set-version.outputs.VERSION }} steps: - name: Set up Go 1.17 uses: actions/setup-go@v2 @@ -76,10 +76,18 @@ jobs: name: cheqd-noded path: build/cheqd-noded - build-deb-package: - name: Build deb package + - name: Set version + id: set-version + run: | + VERSION=$(build/cheqd-noded version 2>&1) + echo "::set-output name=VERSION::$VERSION" + + build-tar-package: + name: Build tar package runs-on: ubuntu-20.04 needs: build-binary + env: + VERSION: ${{ needs.build-binary.outputs.VERSION }} steps: - uses: actions/checkout@v2 @@ -87,46 +95,68 @@ jobs: uses: actions/download-artifact@v2 with: name: cheqd-noded - path: /home/runner/go/bin - name: Restore binary permissions - run: sudo chmod +x /home/runner/go/bin/cheqd-noded + run: sudo chmod +x cheqd-noded - - name: Make intermediate archive + - name: Build tar working-directory: ./build-tools run: | - ./build-tar.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} + ./build-tar.sh "../cheqd-noded" + + - name: Store tar package artifact + uses: actions/upload-artifact@v2 + with: + name: cheqd-node_${{ env.VERSION }}.tar.gz + path: build-tools/output/cheqd-node_${{ env.VERSION }}.tar.gz + + build-deb-package: + name: Build deb package + runs-on: ubuntu-20.04 + needs: build-binary + env: + VERSION: ${{ needs.build-binary.outputs.VERSION }} + steps: + - uses: actions/checkout@v2 + + - name: Load binary artifact + uses: actions/download-artifact@v2 + with: + name: cheqd-noded + + - name: Restore binary permissions + run: sudo chmod +x cheqd-noded - name: Install fpm run: | sudo apt-get install ruby ruby-dev rubygems build-essential sudo gem install --no-document fpm - - name: Build deb # Depends on tar archive + - name: Build deb working-directory: ./build-tools run: | - ./build-deb.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} + ./build-deb.sh "../cheqd-noded" - name: Store deb package artifact uses: actions/upload-artifact@v2 with: - name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb - path: build-tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb + name: cheqd-node_${{ env.VERSION }}_amd64.deb + path: build-tools/output/cheqd-node_${{ env.VERSION }}_amd64.deb - build-node-image: - name: Build cheqd-node image + build-node-images: + name: Build cheqd-node and cheqd-cli images runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 with: - fetch-depth: 0 # FIXME: Starport requires full repository + fetch-depth: 0 # Required to fetch version - name: Build cheqd-cli with 'cheqd-noded' as entrypoint - run: docker build --target base -t cheqd-cli -f docker/Dockerfile --build-arg UID=$(id -u) --build-arg GID=$(id -g) . + run: docker build --target base -t cheqd-cli -f docker/Dockerfile --build-arg UID=$(id -u) --build-arg GID=$(id -g) . # TODO: Get rid of UID and GID - name: Build cheqd-node with 'node-start' as entrypoint run: docker build --target node -t cheqd-node -f docker/Dockerfile --build-arg UID=$(id -u) --build-arg GID=$(id -g) . - + - name: Save cheqd-cli run: docker save -o cheqd-cli-image.tar cheqd-cli @@ -148,7 +178,7 @@ jobs: build-testnet-image: name: Build cheqd-testnet image runs-on: ubuntu-20.04 - needs: build-node-image + needs: build-node-images steps: - name: Check out uses: actions/checkout@v2 @@ -176,15 +206,17 @@ jobs: test-new-node-setup-from-deb: name: Test new node setup from deb runs-on: ubuntu-20.04 - needs: [build-deb-package, build-node-image] + needs: [build-binary, build-deb-package, build-node-images] + env: + VERSION: ${{ needs.build-binary.outputs.VERSION }} steps: - name: Download deb uses: actions/download-artifact@v2 with: - name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb + name: cheqd-node_${{ env.VERSION }}_amd64.deb - name: Install deb - run: sudo CHEQD_HOME_DIR=/home/runner/cheqd dpkg -i ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb + run: sudo CHEQD_HOME_DIR=/home/runner/cheqd dpkg -i cheqd-node_${{ env.VERSION }}_amd64.deb - name: Download node image uses: actions/download-artifact@v2 @@ -200,9 +232,11 @@ jobs: - name: Set up 4 validators + 2 observers node docker pool # TODO: Replace with testnet image working-directory: ./tests/networks/docker-compose-localnet run: | - ./gen-node-configs.sh - ./run-docker.sh - ./wait.sh '[[ $(curl -s -N localhost:26657/block | jq -cr '"'"'.result.block.last_commit.height'"'"') -gt 1 ]] && echo "Height is more than 1"' + bash gen-network-config.sh + docker-compose up -d + + - name: Wait for chain + run: bash tests/networks/tools/wait-for-chain.sh - name: Add observer node working-directory: ./tests/networks/docker-compose-localnet @@ -229,10 +263,10 @@ jobs: run: | journalctl -u service-name.service --no-pager - run-cosmos-tests-using-cli: - name: Run cosmos and identity tests using CLI + run-python-based-integration-tests: + name: Run python based cosmos and identity tests runs-on: ubuntu-20.04 - needs: [build-node-image, build-binary] + needs: [build-node-images, build-binary] steps: - name: Load binary artifact uses: actions/download-artifact@v2 @@ -256,31 +290,35 @@ jobs: - name: Set up 4 validators + 2 observers node docker pool for local test run # Replace with testnet image working-directory: ./tests/networks/docker-compose-localnet run: | - ./gen-node-configs.sh - ./run-docker.sh - ./wait.sh '[[ $(curl -s -N localhost:26657/block | jq -cr '"'"'.result.block.last_commit.height'"'"') -gt 1 ]] && echo "Height is more than 1"' + bash gen-network-config.sh + docker-compose up -d + + - name: Wait for chain + run: bash tests/networks/tools/wait-for-chain.sh - name: Set up test environment working-directory: ./tests/e2e run: | pip3 install -r requirements.txt >> /dev/null - cp -R ${NODE_CONFIGS_BASE}/client/.cheqdnode /home/runner/ + cp -Rf ${NODE_CONFIGS_BASE}/validator-0/. /home/runner/.cheqdnode + cp -Rf ${NODE_CONFIGS_BASE}/validator-1/. /home/runner/.cheqdnode sudo chmod -R 777 /home/runner - name: Run cosmos-related tests run: | - export OP0_ADDRESS=$(cheqd-noded keys list --keyring-backend "test" | sed -nr 's/.*address: (.*?).*/\1/p' | sed -n 1p | sed 's/\r//g') - export OP1_ADDRESS=$(cheqd-noded keys list --keyring-backend "test" | sed -nr 's/.*address: (.*?).*/\1/p' | sed -n 2p | sed 's/\r//g') + set -euxo pipefail + export OP0_ADDRESS=$(cheqd-noded keys list --keyring-backend "test" --home "${NODE_CONFIGS_BASE}/validator-0" | sed -nr 's/.*address: (.*?).*/\1/p' | sed 's/\r//g') + export OP1_ADDRESS=$(cheqd-noded keys list --keyring-backend "test" --home "${NODE_CONFIGS_BASE}/validator-1" | sed -nr 's/.*address: (.*?).*/\1/p' | sed 's/\r//g') pytest -v -rP tests/e2e/test_cosmos.py - - name: Run identity-related tests + - name: Run identity-related tests # TODO: Move into separate stage? run: | export OP0_ADDRESS=$(cheqd-noded keys list --keyring-backend "test" | sed -nr 's/.*address: (.*?).*/\1/p' | sed -n 1p | sed 's/\r//g') export OP1_ADDRESS=$(cheqd-noded keys list --keyring-backend "test" | sed -nr 's/.*address: (.*?).*/\1/p' | sed -n 2p | sed 's/\r//g') pytest -v -rP tests/e2e/test_identity.py - run-identity-tests-using-cli: - name: Run identity tests using CLI + run-bash-based-integration-tests: + name: Run bash based identity tests runs-on: ubuntu-20.04 needs: [build-binary, build-testnet-image] steps: @@ -317,7 +355,7 @@ jobs: run-upgrade-test-positive-case: name: Run positive case for upgrade runs-on: ubuntu-20.04 - needs: build-node-image + needs: build-node-images steps: - uses: actions/checkout@v2 with: diff --git a/.gitignore b/.gitignore index 0ceddba28..629bb9351 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ ### APP-SPECIFIC EXCLUSIONS ### -# Cosmos SDK -**/node_configs +# Tests +**/network-config # Python .pytest_cache diff --git a/architecture/adr-list/adr-001-payment-mechanism-for-issuing-credentials.md b/architecture/adr-list/adr-001-payment-mechanism-for-issuing-credentials.md index fe087d350..59306b97d 100644 --- a/architecture/adr-list/adr-001-payment-mechanism-for-issuing-credentials.md +++ b/architecture/adr-list/adr-001-payment-mechanism-for-issuing-credentials.md @@ -199,5 +199,5 @@ Holder -> Issuer: Accept * [Hyperledger Aries RFC 0036: Issue Credential Protocol 1.0](https://github.com/hyperledger/aries-rfcs/blob/main/features/0036-issue-credential/README.md) * [Hyperledger Aries RFC 0075: Payment Decorators](https://github.com/hyperledger/aries-rfcs/blob/main/features/0075-payment-decorators/README.md) -* [Evernym VDR Tools cheqd network payments ADR](https://gitlab.com/evernym/verity/vdr-tools/-/tree/cheqd/docs/design/014-bank-transactions) +* [Evernym VDR Tools cheqd network payments ADR](https://gitlab.com/evernym/verity/vdr-tools/-/tree/main/docs/design/014-bank-transactions) diff --git a/build-tools/build-deb.sh b/build-tools/build-deb.sh index 69faf2bc4..8c263f7c6 100755 --- a/build-tools/build-deb.sh +++ b/build-tools/build-deb.sh @@ -2,43 +2,48 @@ set -euox pipefail -if [ -n "$1" ]; then - PKG_NAME=$1 -else - echo "It seems that parameter 'PKG_NAME' was missed. Try: " - echo "$0 " - exit 1 +if [ -z ${1+x} ]; then + echo "Binary path must be passed as the first parameter" fi -if [ -n "$2" ]; then - VERSION=$2 -else - echo "It seems that parameter 'VERSION' was missed. Try: " - echo "$0 " - exit 1 -fi +BINARY_PATH="$1" +VERSION=$("${BINARY_PATH}" version 2>&1) +PKG_NAME="cheqd-node" + +BUILD_DIR="build" +OUTPUT_DIR="output" + +mkdir "${BUILD_DIR}" +mkdir "${OUTPUT_DIR}" + +# Prepare content +PACKAGE_CONTENT="${BUILD_DIR}/deb-package-content" +mkdir -p "${PACKAGE_CONTENT}/usr/bin/" +cp "${BINARY_PATH}" "${PACKAGE_CONTENT}/usr/bin/" -source ./common.sh +# Make intermediate archive +PACKAGE_CONTENT_TAR="${BUILD_DIR}/deb-package-content.tar.gz" +tar -cvzf "${PACKAGE_CONTENT_TAR}" -C "${PACKAGE_CONTENT}" "." +# Build deb based on the archive ARCH="amd64" -FULL_PKG_NAME=${PKG_NAME}_${VERSION}_${ARCH}.deb -PKG_PATH=$OUTPUT_DIR/$FULL_PKG_NAME +DEB_PACKAGE="${OUTPUT_DIR}/${PKG_NAME}_${VERSION}_${ARCH}.deb" fpm \ - --input-type "tar" \ - --output-type "deb" \ - --version "${VERSION}" \ - --name "cheqd-node" \ - --description "cheqd node" \ - --url "https://github.com/cheqd/cheqd-node" - --architecture "${ARCH}" \ - --deb-generate-changes \ - --deb-compression gz \ - --after-install "postinst" \ - --deb-after-purge "postpurge" \ - --deb-systemd-enable \ - --deb-systemd cheqd-noded.service \ - --depends "logrotate" \ - --verbose \ - --package "${PKG_PATH}" \ - $PATH_TAR + --input-type "tar" \ + --output-type "deb" \ + --version "${VERSION}" \ + --name "cheqd-node" \ + --description "cheqd node" \ + --url "https://github.com/cheqd/cheqd-node" \ + --architecture "${ARCH}" \ + --deb-generate-changes \ + --deb-compression gz \ + --after-install "postinst" \ + --deb-after-purge "postpurge" \ + --deb-systemd-enable \ + --deb-systemd cheqd-noded.service \ + --depends "logrotate" \ + --verbose \ + --package "${DEB_PACKAGE}" \ + "${PACKAGE_CONTENT_TAR}" diff --git a/build-tools/build-tar.sh b/build-tools/build-tar.sh index 3a62fd6eb..fc5462f38 100755 --- a/build-tools/build-tar.sh +++ b/build-tools/build-tar.sh @@ -2,27 +2,25 @@ set -euox pipefail -if [ -n "$1" ]; then - PKG_NAME=$1 -else - echo "It seems that parameter 'PKG_NAME' was missed. Try: " - echo "$0 " - exit 1 +if [ -z ${1+x} ]; then + echo "Binary path must be passed as the first parameter" fi -if [ -n "$2" ]; then - VERSION=$2 -else - echo "It seems that parameter 'VERSION' was missed. Try: " - echo "$0 " - exit 1 -fi +BINARY_PATH="$1" +VERSION=$("${BINARY_PATH}" version 2>&1) +PKG_NAME="cheqd-node" +BUILD_DIR="build" +OUTPUT_DIR="output" -source ./common.sh +mkdir -p "${BUILD_DIR}" +mkdir -p "${OUTPUT_DIR}" -mkdir -p output -mkdir -p $TMP_DIR -cp $PATH_TO_BIN $TMP_DIR +# Prepare content +PACKAGE_CONTENT="${BUILD_DIR}/tar-package-content" +mkdir -p "${PACKAGE_CONTENT}" +cp "${BINARY_PATH}" "${PACKAGE_CONTENT}" -tar -czf $PATH_TAR $TMP_DIR +# Make an archive +TAR_PACKAGE="${OUTPUT_DIR}/${PKG_NAME}_${VERSION}.tar.gz" +tar -cvzf "${TAR_PACKAGE}" -C "${PACKAGE_CONTENT}" "." diff --git a/build-tools/common.sh b/build-tools/common.sh deleted file mode 100644 index 3a476cadf..000000000 --- a/build-tools/common.sh +++ /dev/null @@ -1,8 +0,0 @@ -set -euox pipefail - -BINARY_NAME=${PKG_NAME}d -PATH_TO_BIN=/home/runner/go/bin/${BINARY_NAME} # TODO: Must be parameters -TMP_DIR=usr/bin -OUTPUT_DIR=output -TAR_ARCHIVE=${PKG_NAME}_${VERSION}.tar.gz -PATH_TAR=$OUTPUT_DIR/$TAR_ARCHIVE diff --git a/docker/persistent-chains/entrypoint.sh b/docker/persistent-chains/entrypoint.sh index 31db039a5..ba91d3e21 100644 --- a/docker/persistent-chains/entrypoint.sh +++ b/docker/persistent-chains/entrypoint.sh @@ -11,7 +11,7 @@ CHEQD_ROOT_DIR="$HOME/.cheqdnode" if [ ! -d "${CHEQD_ROOT_DIR}/config" ] then echo "Node config not found. Initializing." - cheqd-noded init $NODE_MONIKER --home ${CHEQD_ROOT_DIR} + cheqd-noded init "$NODE_MONIKER" --home "${CHEQD_ROOT_DIR}" else echo "Node config exists. Skipping initialization." fi @@ -20,7 +20,7 @@ fi if [ -f "/genesis" ] then echo "Genesis file passed. Adding/replacing current genesis file." - cp /genesis ${CHEQD_ROOT_DIR}/config/genesis.json + cp /genesis "${CHEQD_ROOT_DIR}/config/genesis.json" else echo "No genesis file passed. Skipping and retaining existing genesis." fi @@ -29,26 +29,26 @@ fi if [ -f "/seeds" ] then echo "Seeds file passed. Replacing current seeds." - cp /seeds ${CHEQD_ROOT_DIR}/config/seeds.txt - cheqd-noded configure p2p seeds $(cat ${CHEQD_ROOT_DIR}/config/seeds.txt) + cp /seeds "${CHEQD_ROOT_DIR}/config/seeds.txt" + cheqd-noded configure p2p seeds "$(cat "${CHEQD_ROOT_DIR}/config/seeds.txt")" else echo "No seeds file passed. Skipping and retaining existing seeds." fi # Run configure # `! -z` is used instead of `-n` to distinguish null and empty values -if [[ ! -z ${CREATE_EMPTY_BLOCKS+x} ]]; then cheqd-noded configure create-empty-blocks ${CREATE_EMPTY_BLOCKS}; fi -if [[ ! -z ${FASTSYNC_VERSION+x} ]]; then cheqd-noded configure fastsync-version ${FASTSYNC_VERSION}; fi -if [[ ! -z ${MIN_GAS_PRICES+x} ]]; then cheqd-noded configure min-gas-prices ${MIN_GAS_PRICES}; fi -if [[ ! -z ${RPC_LADDR+x} ]]; then cheqd-noded configure rpc-laddr ${RPC_LADDR}; fi -if [[ ! -z ${P2P_EXTERNAL_ADDRESS+x} ]]; then cheqd-noded configure p2p external-address ${P2P_EXTERNAL_ADDRESS}; fi -if [[ ! -z ${P2P_LADDR+x} ]]; then cheqd-noded configure p2p laddr ${P2P_LADDR}; fi -if [[ ! -z ${P2P_MAX_PACKET_MSG_PAYLOAD_SIZE+x} ]]; then cheqd-noded configure p2p max-packet-msg-payload-size ${P2P_MAX_PACKET_MSG_PAYLOAD_SIZE}; fi -if [[ ! -z ${P2P_SEEDS+x} ]]; then cheqd-noded configure p2p seeds ${P2P_SEEDS}; fi -if [[ ! -z ${P2P_PERSISTENT_PEERS+x} ]]; then cheqd-noded configure p2p persistent-peers ${P2P_PERSISTENT_PEERS}; fi -if [[ ! -z ${P2P_SEED_MODE+x} ]]; then cheqd-noded configure p2p seed-mode ${P2P_SEED_MODE}; fi -if [[ ! -z ${P2P_RECV_RATE+x} ]]; then cheqd-noded configure p2p recv-rate ${P2P_RECV_RATE}; fi -if [[ ! -z ${P2P_SEND_RATE+x} ]]; then cheqd-noded configure p2p send-rate ${P2P_SEND_RATE}; fi +if [[ -n ${CREATE_EMPTY_BLOCKS+x} ]]; then cheqd-noded configure create-empty-blocks "${CREATE_EMPTY_BLOCKS}"; fi +if [[ -n ${FASTSYNC_VERSION+x} ]]; then cheqd-noded configure fastsync-version "${FASTSYNC_VERSION}"; fi +if [[ -n ${MIN_GAS_PRICES+x} ]]; then cheqd-noded configure min-gas-prices "${MIN_GAS_PRICES}"; fi +if [[ -n ${RPC_LADDR+x} ]]; then cheqd-noded configure rpc-laddr "${RPC_LADDR}"; fi +if [[ -n ${P2P_EXTERNAL_ADDRESS+x} ]]; then cheqd-noded configure p2p external-address "${P2P_EXTERNAL_ADDRESS}"; fi +if [[ -n ${P2P_LADDR+x} ]]; then cheqd-noded configure p2p laddr "${P2P_LADDR}"; fi +if [[ -n ${P2P_MAX_PACKET_MSG_PAYLOAD_SIZE+x} ]]; then cheqd-noded configure p2p max-packet-msg-payload-size "${P2P_MAX_PACKET_MSG_PAYLOAD_SIZE}"; fi +if [[ -n ${P2P_SEEDS+x} ]]; then cheqd-noded configure p2p seeds "${P2P_SEEDS}"; fi +if [[ -n ${P2P_PERSISTENT_PEERS+x} ]]; then cheqd-noded configure p2p persistent-peers "${P2P_PERSISTENT_PEERS}"; fi +if [[ -n ${P2P_SEED_MODE+x} ]]; then cheqd-noded configure p2p seed-mode "${P2P_SEED_MODE}"; fi +if [[ -n ${P2P_RECV_RATE+x} ]]; then cheqd-noded configure p2p recv-rate "${P2P_RECV_RATE}"; fi +if [[ -n ${P2P_SEND_RATE+x} ]]; then cheqd-noded configure p2p send-rate "${P2P_SEND_RATE}"; fi # Run node cheqd-noded start diff --git a/docs/build-and-networks/local-docker-compose-network.md b/docs/build-and-networks/local-docker-compose-network.md index bff3ac24f..568044575 100644 --- a/docs/build-and-networks/local-docker-compose-network.md +++ b/docs/build-and-networks/local-docker-compose-network.md @@ -59,7 +59,7 @@ Also, there will be 4 keys generated and corresponding genesis accounts created * operator2; * operator3; -When connecting using CLI, point path to home directory: `--home node_configs/client`. +When connecting using CLI, point path to home directory of the node corresponding to the operator: `--home network-config/validator-x`. ## CLI commands diff --git a/docs/build-and-networks/local-docker-network.md b/docs/build-and-networks/local-docker-network.md index e44ab9f09..9ee2b7df2 100644 --- a/docs/build-and-networks/local-docker-network.md +++ b/docs/build-and-networks/local-docker-network.md @@ -29,7 +29,7 @@ To build the image: ## Running -* Run `docker run -it --rm -p "26657:26657" cheqd-testnet` +* Run `docker run -it --rm -p "26657:26657" -p "1317:1317" cheqd-testnet` * RPC apis are exposed on the folowing ports: * node\_0: `26657` * Try to connect to any node in your browser, for instance: `http://localhost:26657/` diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index 2e0420791..1317156b2 100644 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -15,6 +15,7 @@ proto_dirs=$(find . -path ./third_party -prune -o -name '*.proto' -print0 | xarg for dir in $proto_dirs; do # Generate protobuf bind + # shellcheck disable=SC2046 buf protoc \ -I "proto" \ -I "$cosmos_sdk_dir/third_party/proto" \ @@ -24,6 +25,7 @@ Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \ $(find "${dir}" -name '*.proto') # Generate grpc gateway + # shellcheck disable=SC2046 buf protoc \ -I "proto" \ -I "$cosmos_sdk_dir/third_party/proto" \ diff --git a/tests/cli/run_all.sh b/tests/cli/run_all.sh index a81da5670..4db09ef5c 100644 --- a/tests/cli/run_all.sh +++ b/tests/cli/run_all.sh @@ -11,7 +11,7 @@ function log() { } # Run all shell tests -TESTS=$(find tests -type f -not -name "common.sh") +TESTS=$(find tests -type f -name "test_*") for TEST in ${TESTS} do diff --git a/tests/cli/tests/test_create_did.sh b/tests/cli/tests/test_create_did.sh index fc30a3903..4efe626eb 100644 --- a/tests/cli/tests/test_create_did.sh +++ b/tests/cli/tests/test_create_did.sh @@ -2,16 +2,8 @@ set -euox pipefail -# sed in macos requires extra argument - -sed_extension='' -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - sed_extension='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - sed_extension='.orig' -fi - SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +# shellcheck source=/dev/null source "$SCRIPT_DIR/common.sh" @@ -39,6 +31,7 @@ MSG_CREATE_DID='{ }'; # Post the message +# shellcheck disable=SC2086 RESULT=$(cheqd-noded tx cheqd create-did "${MSG_CREATE_DID}" "${KEY_ID}" --ver-key "${ALICE_VER_PRIV_BASE_64}" \ --from "${BASE_ACCOUNT_1}" ${TX_PARAMS}) diff --git a/tests/cli/tests/query_did.sh b/tests/cli/tests/test_query_did.sh similarity index 89% rename from tests/cli/tests/query_did.sh rename to tests/cli/tests/test_query_did.sh index d9450ac71..9872f6232 100644 --- a/tests/cli/tests/query_did.sh +++ b/tests/cli/tests/test_query_did.sh @@ -2,16 +2,8 @@ set -euox pipefail -# sed in macos requires extra argument - -sed_extension='' -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - sed_extension='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - sed_extension='.orig' -fi - SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +# shellcheck source=/dev/null source "$SCRIPT_DIR/common.sh" @@ -37,6 +29,7 @@ MSG_CREATE_DID='{ ] }'; +# shellcheck disable=SC2086 RESULT=$(cheqd-noded tx cheqd create-did "${MSG_CREATE_DID}" "${KEY_ID}" --ver-key "${ALICE_VER_PRIV_BASE_64}" \ --from "${BASE_ACCOUNT_1}" ${TX_PARAMS}) @@ -44,6 +37,7 @@ assert_tx_successful "$RESULT" # Query DID +# shellcheck disable=SC2086 RESULT=$(cheqd-noded query cheqd did "${DID}" ${QUERY_PARAMS}) EXPECTED='{ diff --git a/tests/cli/tests/query_did_via_rest.sh b/tests/cli/tests/test_query_did_via_rest.sh similarity index 86% rename from tests/cli/tests/query_did_via_rest.sh rename to tests/cli/tests/test_query_did_via_rest.sh index 6f69e6f6c..6d199bd0a 100644 --- a/tests/cli/tests/query_did_via_rest.sh +++ b/tests/cli/tests/test_query_did_via_rest.sh @@ -2,16 +2,8 @@ # set -euox pipefail -# sed in macos requires extra argument - -sed_extension='' -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - sed_extension='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - sed_extension='.orig' -fi - SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +# shellcheck source=/dev/null source "$SCRIPT_DIR/common.sh" @@ -37,6 +29,7 @@ MSG_CREATE_DID='{ ] }'; +# shellcheck disable=SC2086 RESULT=$(cheqd-noded tx cheqd create-did "${MSG_CREATE_DID}" "${KEY_ID}" --ver-key "${ALICE_VER_PRIV_BASE_64}" \ --from "${BASE_ACCOUNT_1}" ${TX_PARAMS}) @@ -44,7 +37,7 @@ assert_tx_successful "$RESULT" # Query DID -RESULT=$(curl http://localhost:1317/cheqd/cheqdnode/cheqd/did/"${DID}") +RESULT=$(curl "http://localhost:1317/cheqd/cheqdnode/cheqd/did/${DID}") EXPECTED='{ "context":[], diff --git a/tests/cli/tests/test_rotate_key.sh b/tests/cli/tests/test_rotate_key.sh index 25191267d..eaa6b4230 100644 --- a/tests/cli/tests/test_rotate_key.sh +++ b/tests/cli/tests/test_rotate_key.sh @@ -2,16 +2,8 @@ set -euox pipefail -# sed in macos requires extra argument - -sed_extension='' -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - sed_extension='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - sed_extension='.orig' -fi - SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +# shellcheck source=/dev/null source "$SCRIPT_DIR/common.sh" @@ -37,6 +29,7 @@ MSG_CREATE_DID='{ ] }'; +# shellcheck disable=SC2086 RESULT=$(cheqd-noded tx cheqd create-did "${MSG_CREATE_DID}" "${KEY_ID}" --ver-key "${OLD_VER_PRIV_BASE_64}" \ --from "${BASE_ACCOUNT_1}" ${TX_PARAMS}) @@ -44,6 +37,7 @@ assert_tx_successful "$RESULT" # Query DID to find out version id # TODO: VersionId must be returned in MsgCreateDidResp +# shellcheck disable=SC2086 RESULT=$(cheqd-noded query cheqd did "${DID}" ${QUERY_PARAMS}) VERSION_ID=$(echo "${RESULT}" | jq -r ".metadata.version_id") @@ -51,7 +45,6 @@ VERSION_ID=$(echo "${RESULT}" | jq -r ".metadata.version_id") # Updating DID NEW_VER_KEY="$(cheqd-noded debug ed25519 random)" NEW_VER_PUB_BASE_64=$(echo "${NEW_VER_KEY}" | jq -r ".pub_key_base_64") -NEW_VER_PRIV_BASE_64=$(echo "${NEW_VER_KEY}" | jq -r ".priv_key_base_64") NEW_VER_PUB_MULTIBASE_58=$(cheqd-noded debug encoding base64-multibase58 "${NEW_VER_PUB_BASE_64}") MSG_UPDATE_DID='{ @@ -72,6 +65,7 @@ MSG_UPDATE_DID='{ }'; # Post the message +# shellcheck disable=SC2086 RESULT=$(cheqd-noded tx cheqd update-did "${MSG_UPDATE_DID}" "${KEY_ID}" --ver-key "${OLD_VER_PRIV_BASE_64}" \ --from "${BASE_ACCOUNT_1}" ${TX_PARAMS}) @@ -79,6 +73,7 @@ assert_tx_successful "$RESULT" # Query DID and assert resp +# shellcheck disable=SC2086 RESULT=$(cheqd-noded query cheqd did "${DID}" ${QUERY_PARAMS}) EXPECTED='{ diff --git a/tests/cli/tests/test_update_did.sh b/tests/cli/tests/test_update_did.sh index 5c410b5b6..41926423b 100644 --- a/tests/cli/tests/test_update_did.sh +++ b/tests/cli/tests/test_update_did.sh @@ -2,16 +2,8 @@ set -euox pipefail -# sed in macos requires extra argument - -sed_extension='' -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - sed_extension='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - sed_extension='.orig' -fi - SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +# shellcheck source=/dev/null source "$SCRIPT_DIR/common.sh" @@ -37,6 +29,7 @@ MSG_CREATE_DID='{ ] }'; +# shellcheck disable=SC2086 RESULT=$(cheqd-noded tx cheqd create-did "${MSG_CREATE_DID}" "${KEY_ID}" --ver-key "${ALICE_VER_PRIV_BASE_64}" \ --from "${BASE_ACCOUNT_1}" ${TX_PARAMS}) @@ -44,6 +37,7 @@ assert_tx_successful "$RESULT" # Query DID to find out version id # TODO: VersionId must be returned in MsgCreateDidResp +# shellcheck disable=SC2086 RESULT=$(cheqd-noded query cheqd did "${DID}" ${QUERY_PARAMS}) VERSION_ID=$(echo "${RESULT}" | jq -r ".metadata.version_id") @@ -67,6 +61,7 @@ MSG_UPDATE_DID='{ }'; # Post the message +# shellcheck disable=SC2086 RESULT=$(cheqd-noded tx cheqd update-did "${MSG_UPDATE_DID}" "${KEY_ID}" --ver-key "${ALICE_VER_PRIV_BASE_64}" \ --from "${BASE_ACCOUNT_1}" ${TX_PARAMS}) @@ -74,6 +69,7 @@ assert_tx_successful "$RESULT" # Query DID and assert resp +# shellcheck disable=SC2086 RESULT=$(cheqd-noded query cheqd did "${DID}" ${QUERY_PARAMS}) EXPECTED='{ diff --git a/tests/e2e/test_cosmos.py b/tests/e2e/test_cosmos.py index 38545bec7..603501f3d 100644 --- a/tests/e2e/test_cosmos.py +++ b/tests/e2e/test_cosmos.py @@ -15,8 +15,8 @@ "command, params, expected_output", [ ("help", "",r"cheqd App(.*?)Usage:(.*?)Available Commands:(.*?)Flags:"), - ("status", LOCAL_NET_NODE_TCP, fr"\"NodeInfo\"(.*?)\"network\":\"{LOCAL_NET_NETWORK}\"(.*?)\"moniker\":\"node0\""), # tcp + local - ("status", LOCAL_NET_NODE_HTTP, fr"\"NodeInfo\"(.*?)\"network\":\"{LOCAL_NET_NETWORK}\"(.*?)\"moniker\":\"node0\""), # http + local + ("status", LOCAL_NET_NODE_TCP, fr"\"NodeInfo\"(.*?)\"network\":\"{LOCAL_NET_NETWORK}\"(.*?)\"moniker\":\"validator-0\""), # tcp + local + ("status", LOCAL_NET_NODE_HTTP, fr"\"NodeInfo\"(.*?)\"network\":\"{LOCAL_NET_NETWORK}\"(.*?)\"moniker\":\"validator-0\""), # http + local ] ) def test_basic(command, params, expected_output): diff --git a/tests/ibc-defi/README.md b/tests/ibc-defi/README.md new file mode 100644 index 000000000..d2a6c2104 --- /dev/null +++ b/tests/ibc-defi/README.md @@ -0,0 +1,9 @@ +# IBC Integration test + +```bash +# Cd to the test directory +cd tests/ibc-defi + +# Run test +bash bash ibc-transfer-test.sh +``` diff --git a/tests/ibc-defi/cheqd/cheqd_init.sh b/tests/ibc-defi/cheqd/cheqd_init.sh index b876c461d..68cce5ec8 100755 --- a/tests/ibc-defi/cheqd/cheqd_init.sh +++ b/tests/ibc-defi/cheqd/cheqd_init.sh @@ -25,7 +25,7 @@ sed -i $sed_extension 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0: # Genesis GENESIS="$HOME/.cheqdnode/config/genesis.json" -sed -i $sed_extension 's/"stake"/"ncheq"/' $GENESIS +sed -i $sed_extension 's/"stake"/"ncheq"/' "$GENESIS" cheqd-noded add-genesis-account cheqd-user 1000000000000000000ncheq --keyring-backend test cheqd-noded gentx cheqd-user 10000000000000000ncheq --chain-id $CHAIN_ID --pubkey "$NODE_0_VAL_PUBKEY" --keyring-backend test diff --git a/tests/ibc-defi/gravity/gravity_init.sh b/tests/ibc-defi/gravity/gravity_init.sh index 84c619c80..c4a03de8b 100755 --- a/tests/ibc-defi/gravity/gravity_init.sh +++ b/tests/ibc-defi/gravity/gravity_init.sh @@ -23,9 +23,6 @@ liquidityd keys add gravity-user --keyring-backend test sed -i $sed_extension 's|minimum-gas-prices = ""|minimum-gas-prices = "0stake"|g' "$HOME/.liquidityapp/config/app.toml" sed -i $sed_extension 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.liquidityapp/config/config.toml" -# Genesis -GENESIS="$HOME/.cheqdnode/config/genesis.json" - liquidityd add-genesis-account gravity-user 1000000000stake --keyring-backend test liquidityd gentx gravity-user 1000000000stake --chain-id $CHAIN_ID --pubkey "$NODE_0_VAL_PUBKEY" --keyring-backend test diff --git a/tests/ibc-defi/hermes/hermes_init.sh b/tests/ibc-defi/hermes/hermes_init.sh index 733c22155..b34d77f65 100755 --- a/tests/ibc-defi/hermes/hermes_init.sh +++ b/tests/ibc-defi/hermes/hermes_init.sh @@ -1,11 +1,3 @@ #!/bin/bash set -euox pipefail - -# sed in macos requires extra argument - -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - sed_extension='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - sed_extension='.orig' -fi diff --git a/tests/ibc-defi/ibc-transfer-test.sh b/tests/ibc-defi/ibc-transfer-test.sh index 65324ff69..ce4e43e8b 100755 --- a/tests/ibc-defi/ibc-transfer-test.sh +++ b/tests/ibc-defi/ibc-transfer-test.sh @@ -2,26 +2,29 @@ set -euox pipefail -# sed in macos requires extra argument - -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - sed_extension='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - sed_extension='.orig' -fi - - # Colors RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' # No Color function info() { - printf "${GREEN}[info] ${1}${NC}\n" + printf "${GREEN}[info] %s${NC}\n" "${1}" } function err() { - printf "${RED}[err] ${1}${NC}\n" + printf "${RED}[err] %s${NC}\n" "${1}" +} + +function assert_tx_successful() { + RES=$1 + + if [[ $(echo "${RES}" | jq --raw-output '.code') == 0 ]] + then + info "tx successful" + else + err "non zero tx return code" + exit 1 + fi } @@ -32,23 +35,22 @@ sleep 15 # Wait for chains info "Create relayer user on cheqd" # --- CHEQD_RELAYER_KEY_NAME="cheqd-relayer" CHEQD_RELAYER_ACCOUNT=$(docker-compose exec cheqd cheqd-noded keys add ${CHEQD_RELAYER_KEY_NAME} --keyring-backend test --output json) -CHEQD_RELAYER_ADDRESS=$(echo ${CHEQD_RELAYER_ACCOUNT} | jq --raw-output '.address') -CHEQD_RELAYER_MNEMONIC=$(echo ${CHEQD_RELAYER_ACCOUNT} | jq --raw-output '.mnemonic') +CHEQD_RELAYER_ADDRESS=$(echo "${CHEQD_RELAYER_ACCOUNT}" | jq --raw-output '.address') +CHEQD_RELAYER_MNEMONIC=$(echo "${CHEQD_RELAYER_ACCOUNT}" | jq --raw-output '.mnemonic') info "Send some tokens to it" # --- -RES=$(docker-compose exec cheqd cheqd-noded tx bank send cheqd-user ${CHEQD_RELAYER_ADDRESS} 1000000000000ncheq --gas-prices 25ncheq --chain-id cheqd -y --keyring-backend test) -[[ $(echo $RES | jq --raw-output '.code') == 0 ]] && info "tx successfull" || (err "non zero tx return code"; exit 1) - +RES=$(docker-compose exec cheqd cheqd-noded tx bank send cheqd-user "${CHEQD_RELAYER_ADDRESS}" 1000000000000ncheq --gas-prices 25ncheq --chain-id cheqd -y --keyring-backend test) +assert_tx_successful "${RES}" info "Create relayer user on osmosis" # --- OSMOSIS_RELAYER_KEY_NAME="osmosis-relayer" OSMOSIS_RELAYER_ACCOUNT=$(docker-compose exec osmosis osmosisd keys add ${OSMOSIS_RELAYER_KEY_NAME} --output json --keyring-backend test) -OSMOSIS_RELAYER_ADDRESS=$(echo ${OSMOSIS_RELAYER_ACCOUNT} | jq --raw-output '.address') -OSMOSIS_RELAYER_MNEMONIC=$(echo ${OSMOSIS_RELAYER_ACCOUNT} | jq --raw-output '.mnemonic') +OSMOSIS_RELAYER_ADDRESS=$(echo "${OSMOSIS_RELAYER_ACCOUNT}" | jq --raw-output '.address') +OSMOSIS_RELAYER_MNEMONIC=$(echo "${OSMOSIS_RELAYER_ACCOUNT}" | jq --raw-output '.mnemonic') info "Send some tokens to it" # --- -RES=$(docker-compose exec osmosis osmosisd tx bank send osmosis-user ${OSMOSIS_RELAYER_ADDRESS} 1000stake --chain-id osmosis -y --keyring-backend test --output json) -[[ $(echo $RES | jq --raw-output '.code') == 0 ]] && info "tx successfull" || (err "non zero tx return code"; exit 1) +RES=$(docker-compose exec osmosis osmosisd tx bank send osmosis-user "${OSMOSIS_RELAYER_ADDRESS}" 1000stake --chain-id osmosis -y --keyring-backend test --output json) +assert_tx_successful "${RES}" sleep 10 # Wait for state info "Import accounts in hermes" # --- @@ -66,42 +68,62 @@ info "Check balances" # --- CHEQD_USER_ADDRESS=$(docker-compose exec cheqd cheqd-noded keys show --address cheqd-user --keyring-backend test | sed 's/\r//g') OSMOSIS_USER_ADDRESS=$(docker-compose exec osmosis osmosisd keys show --address osmosis-user --keyring-backend test | sed 's/\r//g') -CHEQD_BALANCE_1=$(docker-compose exec cheqd cheqd-noded query bank balances $CHEQD_USER_ADDRESS --output json) -docker-compose exec osmosis osmosisd query bank balances $OSMOSIS_USER_ADDRESS +CHEQD_BALANCE_1=$(docker-compose exec cheqd cheqd-noded query bank balances "$CHEQD_USER_ADDRESS" --output json) +docker-compose exec osmosis osmosisd query bank balances "$OSMOSIS_USER_ADDRESS" info "Forward transfer" # --- PORT="transfer" CHANNEL="channel-0" -docker-compose exec cheqd cheqd-noded tx ibc-transfer transfer $PORT $CHANNEL $OSMOSIS_USER_ADDRESS 10000000000ncheq --from cheqd-user --chain-id cheqd --gas-prices 25ncheq --keyring-backend test -y +docker-compose exec cheqd cheqd-noded tx ibc-transfer transfer $PORT $CHANNEL "$OSMOSIS_USER_ADDRESS" 10000000000ncheq --from cheqd-user --chain-id cheqd --gas-prices 25ncheq --keyring-backend test -y sleep 30 # Wait for relayer info "Check balances the second time" # --- -CHEQD_BALANCE_2=$(docker-compose exec cheqd cheqd-noded query bank balances $CHEQD_USER_ADDRESS --output json) -BALANCES=$(docker-compose exec osmosis osmosisd query bank balances $OSMOSIS_USER_ADDRESS --output json) +CHEQD_BALANCE_2=$(docker-compose exec cheqd cheqd-noded query bank balances "$CHEQD_USER_ADDRESS" --output json) +BALANCES=$(docker-compose exec osmosis osmosisd query bank balances "$OSMOSIS_USER_ADDRESS" --output json) info "Denom trace" # --- DENOM=$(echo "$BALANCES" | jq --raw-output '.balances[0].denom') DENOM_CUT=$(echo "$DENOM" | cut -c 5-) -docker-compose exec osmosis osmosisd query ibc-transfer denom-trace $DENOM_CUT +docker-compose exec osmosis osmosisd query ibc-transfer denom-trace "$DENOM_CUT" info "Back transfer" # --- PORT="transfer" CHANNEL="channel-0" -docker-compose exec osmosis osmosisd tx ibc-transfer transfer $PORT $CHANNEL $CHEQD_USER_ADDRESS 10000000000${DENOM} --from osmosis-user --chain-id osmosis --keyring-backend test -y +docker-compose exec osmosis osmosisd tx ibc-transfer transfer $PORT $CHANNEL "$CHEQD_USER_ADDRESS" 10000000000"${DENOM}" --from osmosis-user --chain-id osmosis --keyring-backend test -y sleep 30 # Wait for relayer info "Check balances the last time" # --- -CHEQD_BALANCE_3=$(docker-compose exec cheqd cheqd-noded query bank balances $CHEQD_USER_ADDRESS --output json) -docker-compose exec osmosis osmosisd query bank balances $OSMOSIS_USER_ADDRESS +CHEQD_BALANCE_3=$(docker-compose exec cheqd cheqd-noded query bank balances "$CHEQD_USER_ADDRESS" --output json) +docker-compose exec osmosis osmosisd query bank balances "$OSMOSIS_USER_ADDRESS" -CHEQD_BALANCE_1=$(echo $CHEQD_BALANCE_1 | jq --raw-output '.balances[0].amount') -CHEQD_BALANCE_2=$(echo $CHEQD_BALANCE_2 | jq --raw-output '.balances[0].amount') -CHEQD_BALANCE_3=$(echo $CHEQD_BALANCE_3 | jq --raw-output '.balances[0].amount') +CHEQD_BALANCE_1=$(echo "$CHEQD_BALANCE_1" | jq --raw-output '.balances[0].amount') +CHEQD_BALANCE_2=$(echo "$CHEQD_BALANCE_2" | jq --raw-output '.balances[0].amount') +CHEQD_BALANCE_3=$(echo "$CHEQD_BALANCE_3" | jq --raw-output '.balances[0].amount') info "Assert balances" # --- -[[ $CHEQD_BALANCE_2 < $CHEQD_BALANCE_1 ]] && info "cheqd -> osmosis transfer is successfull" || (err "cheqd -> osmosis transfer error"; exit 1) -[[ $CHEQD_BALANCE_3 > $CHEQD_BALANCE_2 ]] && info "osmosis -> cheqd transfer is successfull" || (err "osmosis -> cheqd transfer error"; exit 1) -[[ $CHEQD_BALANCE_3 < $CHEQD_BALANCE_1 ]] && info "fee processed successfully" || (err "fee error"; exit 1) +if [[ $CHEQD_BALANCE_2 < $CHEQD_BALANCE_1 ]] +then + info "cheqd -> osmosis transfer is successfull" +else + err "cheqd -> osmosis transfer error" + exit 1 +fi + +if [[ $CHEQD_BALANCE_3 > $CHEQD_BALANCE_2 ]] +then + info "osmosis -> cheqd transfer is successfull" +else + err "osmosis -> cheqd transfer error" + exit 1 +fi + +if [[ $CHEQD_BALANCE_3 < $CHEQD_BALANCE_1 ]] +then + info "fee processed successfully" +else + err "fee error" + exit 1 +fi info "Tear down" # --- diff --git a/tests/ibc-defi/osmosis/osmosis_init.sh b/tests/ibc-defi/osmosis/osmosis_init.sh index 6f729502e..b23843ac5 100644 --- a/tests/ibc-defi/osmosis/osmosis_init.sh +++ b/tests/ibc-defi/osmosis/osmosis_init.sh @@ -19,11 +19,12 @@ osmosisd init --chain-id $CHAIN_ID testing osmosisd keys add osmosis-user --keyring-backend=test # Genesis -osmosisd add-genesis-account $(osmosisd keys show osmosis-user -a --keyring-backend=test) 1000000000stake,1000000000valtoken +osmosisd add-genesis-account "$(osmosisd keys show osmosis-user -a --keyring-backend=test)" 1000000000stake,1000000000valtoken osmosisd gentx osmosis-user 500000000stake --keyring-backend=test --chain-id $CHAIN_ID osmosisd collect-gentxs -cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["gov"]["voting_params"]["voting_period"]="10s"' > $HOME/.osmosisd/config/tmp_genesis.json && mv $HOME/.osmosisd/config/tmp_genesis.json $HOME/.osmosisd/config/genesis.json +jq '.app_state["gov"]["voting_params"]["voting_period"]="10s"' "$HOME/.osmosisd/config/genesis.json" > "$HOME/.osmosisd/config/tmp_genesis.json" && \ + mv "$HOME/.osmosisd/config/tmp_genesis.json" "$HOME/.osmosisd/config/genesis.json" # Config sed -i $sed_extension 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.osmosisd/config/config.toml" diff --git a/tests/networks/docker-compose-localnet/.env b/tests/networks/docker-compose-localnet/.env index 6438fdaa3..b7a6ab404 100644 --- a/tests/networks/docker-compose-localnet/.env +++ b/tests/networks/docker-compose-localnet/.env @@ -1,3 +1,2 @@ -CHEQD_VERSION="latest" CHEQD_IMAGE_NAME="cheqd-cli" -MOUNT_POINT="." \ No newline at end of file +MOUNT_POINT="." diff --git a/tests/networks/docker-compose-localnet/add-observer.sh b/tests/networks/docker-compose-localnet/add-observer.sh index d365137f7..68193b69e 100755 --- a/tests/networks/docker-compose-localnet/add-observer.sh +++ b/tests/networks/docker-compose-localnet/add-observer.sh @@ -3,14 +3,14 @@ set -euox pipefail sudo chown -R cheqd:cheqd "/home/runner/cheqd/" -NODE_CONFIGS_BASE="/home/runner/work/cheqd-node/cheqd-node/tests/networks/docker-compose-localnet/node_configs" +NODE_CONFIGS_BASE="/home/runner/work/cheqd-node/cheqd-node/tests/networks/docker-compose-localnet/network-config" sudo -u cheqd cheqd-noded init node5 -NODE0_ID=$(cat "${NODE_CONFIGS_BASE}/node0/node_id.txt") -PERSISTENT_PEERS="${NODE0_ID}@127.0.0.1:26656" +VALIDATOR_0_ID=$(cat "${NODE_CONFIGS_BASE}/validator-0/node_id.txt") +PERSISTENT_PEERS="${VALIDATOR_0_ID}@127.0.0.1:26656" sudo -u cheqd cheqd-noded configure p2p persistent-peers "${PERSISTENT_PEERS}" -sudo cp "${NODE_CONFIGS_BASE}/node0/.cheqdnode/config/genesis.json" "/home/runner/cheqd/.cheqdnode/config" +sudo cp "${NODE_CONFIGS_BASE}/validator-0/config/genesis.json" "/home/runner/cheqd/.cheqdnode/config" sudo chmod -R 777 "/home/runner/cheqd/.cheqdnode" diff --git a/tests/networks/docker-compose-localnet/docker-compose.yml b/tests/networks/docker-compose-localnet/docker-compose.yml index c63cb79bd..6a1b9c94f 100644 --- a/tests/networks/docker-compose-localnet/docker-compose.yml +++ b/tests/networks/docker-compose-localnet/docker-compose.yml @@ -1,75 +1,56 @@ version: '3.2' services: - node0: + validator-0: image: "${CHEQD_IMAGE_NAME}" ports: - "26656:26656" # p2p - "26657:26657" # rpc volumes: - - "${MOUNT_POINT}/node_configs/node0:/cheqd" - user: cheqd - environment: - - HOME=/cheqd - command: start --rpc.laddr tcp://0.0.0.0:26657 + - "${MOUNT_POINT}/network-config/validator-0:/home/cheqd/.cheqdnode" + command: start - node1: + validator-1: image: "${CHEQD_IMAGE_NAME}" ports: - "26659:26656" # p2p - "26660:26657" # rpc volumes: - - "${MOUNT_POINT}/node_configs/node1:/cheqd" - user: cheqd - environment: - - HOME=/cheqd - command: start --rpc.laddr tcp://0.0.0.0:26657 --p2p.persistent_peers "${NODE_0_ID}@node0:26656" + - "${MOUNT_POINT}/network-config/validator-1:/home/cheqd/.cheqdnode" + command: start - node2: + validator-2: image: "${CHEQD_IMAGE_NAME}" ports: - "26662:26656" # p2p - "26663:26657" # rpc volumes: - - "${MOUNT_POINT}/node_configs/node2:/cheqd" - user: cheqd - environment: - - HOME=/cheqd - command: start --rpc.laddr tcp://0.0.0.0:26657 --p2p.persistent_peers "${NODE_0_ID}@node0:26656" + - "${MOUNT_POINT}/network-config/validator-2:/home/cheqd/.cheqdnode" + command: start - node3: + validator-3: image: "${CHEQD_IMAGE_NAME}" ports: - "26665:26656" # p2p - "26666:26657" # rpc volumes: - - "${MOUNT_POINT}/node_configs/node3:/cheqd" - user: cheqd - environment: - - HOME=/cheqd - command: start --rpc.laddr tcp://0.0.0.0:26657 --p2p.persistent_peers "${NODE_0_ID}@node0:26656" + - "${MOUNT_POINT}/network-config/validator-3:/home/cheqd/.cheqdnode" + command: start - observer0: + seed-0: image: "${CHEQD_IMAGE_NAME}" ports: - "26668:26656" # p2p - "26669:26657" # rpc volumes: - - "${MOUNT_POINT}/node_configs/observer0:/cheqd" - user: cheqd - environment: - - HOME=/cheqd - command: start --rpc.laddr tcp://0.0.0.0:26657 --minimum-gas-prices "1cheq" --p2p.persistent_peers "${NODE_0_ID}@node0:26656" + - "${MOUNT_POINT}/network-config/seed-0:/home/cheqd/.cheqdnode" + command: start - observer1: + observer-0: image: "${CHEQD_IMAGE_NAME}" ports: - "26671:26656" # p2p - "26672:26657" # rpc volumes: - - "${MOUNT_POINT}/node_configs/observer1:/cheqd" - user: cheqd - environment: - - HOME=/cheqd - command: start --rpc.laddr tcp://0.0.0.0:26657 --minimum-gas-prices "1cheq" --p2p.persistent_peers "${NODE_0_ID}@node0:26656" - \ No newline at end of file + - "${MOUNT_POINT}/network-config/observer-0:/home/cheqd/.cheqdnode" + command: start diff --git a/tests/networks/docker-compose-localnet/gen-network-config.sh b/tests/networks/docker-compose-localnet/gen-network-config.sh new file mode 100644 index 000000000..5b05b2ad8 --- /dev/null +++ b/tests/networks/docker-compose-localnet/gen-network-config.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Tweaks network configuration generated by `../tools/gen-network-config.sh` for use with docker-localnet container. + +set -euo pipefail + +# Generate base network configuration +bash ../tools/gen-network-config-base.sh cheqd 4 1 1 # 4 validators, 1 observer and 1 seed + +# Set peers +SEED_0_ID=$(cheqd-noded tendermint show-node-id --home "network-config/seed-0") +PERSISTENT_PEERS="$SEED_0_ID@seed-0:26656" +sed -i.bak "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_PEERS\"/g" network-config/validator-0/config/config.toml +sed -i.bak "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_PEERS\"/g" network-config/validator-1/config/config.toml +sed -i.bak "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_PEERS\"/g" network-config/validator-2/config/config.toml +sed -i.bak "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_PEERS\"/g" network-config/validator-3/config/config.toml +sed -i.bak "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_PEERS\"/g" network-config/observer-0/config/config.toml diff --git a/tests/networks/docker-compose-localnet/gen-node-configs.sh b/tests/networks/docker-compose-localnet/gen-node-configs.sh deleted file mode 100755 index 8c6b0d8af..000000000 --- a/tests/networks/docker-compose-localnet/gen-node-configs.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/bin/bash - -# Generates configurations for 4 nodes. - -set -euox pipefail - -# sed in macos requires extra argument - -CHEQD_NODE_IMAGE=cheqd-cli - -sed_extension='' -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - sed_extension='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - sed_extension='.orig' -fi - -# cheqd_noded docker wrapper - -cheqd_noded_docker() { - docker run --rm \ - -v "$(pwd)":"/home/cheqd" \ - $CHEQD_NODE_IMAGE "$@" -} - - -CHAIN_ID="cheqd" - -VALIDATORS_COUNT="4" -OBSERVERS_COUNT="2" - -NODE_CONFIGS_DIR="node_configs" -rm -rf $NODE_CONFIGS_DIR -mkdir $NODE_CONFIGS_DIR -pushd $NODE_CONFIGS_DIR - -echo "Generating validator keys..." - -for ((i=0 ; i<$VALIDATORS_COUNT ; i++)) -do - NODE_HOME="node$i" - mkdir $NODE_HOME - pushd $NODE_HOME - - echo "[Validator $i] Generating key..." - - cheqd_noded_docker init "node$i" --chain-id $CHAIN_ID - echo "$(cheqd_noded_docker tendermint show-node-id)" > node_id.txt - echo "$(cheqd_noded_docker tendermint show-validator)" > node_val_pubkey.txt - - echo "Setting minimum fee price..." - - sed -i $sed_extension 's/minimum-gas-prices = ""/minimum-gas-prices = "25ncheq"/g' .cheqdnode/config/app.toml - - popd -done - - -OPERATORS_HOME="client" -mkdir $OPERATORS_HOME -pushd $OPERATORS_HOME - -echo "Initializing genesis..." -cheqd_noded_docker init dummy_node --chain-id $CHAIN_ID -sed -i $sed_extension 's/"stake"/"ncheq"/' .cheqdnode/config/genesis.json - -echo "Generating operator keys..." - -for ((i=0 ; i<$VALIDATORS_COUNT ; i++)) -do - cheqd_noded_docker keys add "operator$i" --keyring-backend "test" -done - -echo "Creating genesis accounts..." - -for ((i=0 ; i<$VALIDATORS_COUNT ; i++)) -do - cheqd_noded_docker add-genesis-account "operator$i" 20000000000000000ncheq --keyring-backend "test" -done - -echo "Creating genesis validators..." - -for ((i=0 ; i<$VALIDATORS_COUNT ; i++)) -do - NODE_HOME="../node$i" - pushd $NODE_HOME - - NODE_ID=$(cheqd_noded_docker tendermint show-node-id) - NODE_VAL_PUBKEY=$(cheqd_noded_docker tendermint show-validator) - - popd - - cheqd_noded_docker gentx "operator$i" 1000000000000000ncheq --chain-id $CHAIN_ID --node-id $NODE_ID --pubkey $NODE_VAL_PUBKEY --keyring-backend "test" -done - -echo "Collecting them..." - -cheqd_noded_docker collect-gentxs -cheqd_noded_docker validate-genesis - -echo "Propagating genesis to nodes..." - -for ((i=0 ; i<$VALIDATORS_COUNT ; i++)) -do - NODE_HOME="../node$i" - - cp ".cheqdnode/config/genesis.json" "$NODE_HOME/.cheqdnode/config/" -done - - -popd # operators' home - - -echo "##### Setting up observers..." - -for ((i=0 ; i<$OBSERVERS_COUNT ; i++)) -do - NODE_HOME="observer$i" - - mkdir $NODE_HOME - pushd $NODE_HOME - - echo "##### [Observer $i] Generating keys..." - cheqd_noded_docker init "node$i" --chain-id $CHAIN_ID - - echo "##### [Observer $i] Exporting public keys..." - echo "$(cheqd_noded_docker tendermint show-node-id)" > node_id.txt - echo "$(cheqd_noded_docker tendermint show-validator)" > node_val_pubkey.txt - - echo "##### [Observer $i] Loading genesis..." - OPERATORS_HOME="../client" - cp "$OPERATORS_HOME/.cheqdnode/config/genesis.json" ".cheqdnode/config/" - - echo "##### [Observer $i] Setting min gas prices..." - sed -i $sed_extension 's/minimum-gas-prices = ""/minimum-gas-prices = "25ncheq"/g' .cheqdnode/config/app.toml - - popd -done - -popd # node_configs \ No newline at end of file diff --git a/tests/networks/docker-compose-localnet/promote-validator.sh b/tests/networks/docker-compose-localnet/promote-validator.sh index c1ce8df69..6f5bc17df 100755 --- a/tests/networks/docker-compose-localnet/promote-validator.sh +++ b/tests/networks/docker-compose-localnet/promote-validator.sh @@ -2,11 +2,11 @@ set -euox pipefail -sudo chown -R runner:docker ${NODE_CONFIGS_BASE}/client -cheqd-noded keys list --keyring-backend "test" --home ${NODE_CONFIGS_BASE}/client/.cheqdnode/ +sudo chown -R runner:docker "${NODE_CONFIGS_BASE}" +cheqd-noded keys list --keyring-backend "test" --home "${NODE_CONFIGS_BASE}/validator-0" # Get operator0 address by setting --home flag -OP0_ADDRESS=$(cheqd-noded keys list --keyring-backend "test" --home ${NODE_CONFIGS_BASE}/client/.cheqdnode/ | sed -nr 's/.*address: (.*?).*/\1/p' | sed -n 1p | sed 's/\r//g') +OP0_ADDRESS=$(cheqd-noded keys list --keyring-backend "test" --home "${NODE_CONFIGS_BASE}/validator-0" | sed -nr 's/.*address: (.*?).*/\1/p' | sed -n 1p | sed 's/\r//g') # Create operator5 by running it under the `cheqd` user. sudo -u cheqd cheqd-noded keys add node5-operator --keyring-backend "test" @@ -14,6 +14,6 @@ OP5_ADDRESS=$(sudo -u cheqd cheqd-noded keys list --keyring-backend "test"| sed NODE5_PUBKEY=$(sudo -u cheqd cheqd-noded tendermint show-validator | sed 's/\r//g') # Send tokens from operator0 -cheqd-noded tx bank send ${OP0_ADDRESS} ${OP5_ADDRESS} 1100000000000000ncheq --chain-id cheqd --fees 5000000ncheq --node "http://localhost:26657" -y --keyring-backend "test" --home ${NODE_CONFIGS_BASE}/client/.cheqdnode/ +cheqd-noded tx bank send "${OP0_ADDRESS}" "${OP5_ADDRESS}" 1100000000000000ncheq --chain-id cheqd --fees 5000000ncheq --node "http://localhost:26657" -y --keyring-backend "test" --home "${NODE_CONFIGS_BASE}/validator-0" # Send promote validator from operator5 -sudo -u cheqd cheqd-noded tx staking create-validator --amount 1000000000000000ncheq --from node5-operator --chain-id cheqd --min-self-delegation="1" --gas-prices="25ncheq" --pubkey ${NODE5_PUBKEY} --commission-max-change-rate="0.02" --commission-max-rate="0.02" --commission-rate="0.01" --gas 500000 --node "http://localhost:26657" -y --keyring-backend "test" +sudo -u cheqd cheqd-noded tx staking create-validator --amount 1000000000000000ncheq --from node5-operator --chain-id cheqd --min-self-delegation="1" --gas-prices="25ncheq" --pubkey "${NODE5_PUBKEY}" --commission-max-change-rate="0.02" --commission-max-rate="0.02" --commission-rate="0.01" --gas 500000 --node "http://localhost:26657" -y --keyring-backend "test" diff --git a/tests/networks/docker-compose-localnet/run-docker.sh b/tests/networks/docker-compose-localnet/run-docker.sh deleted file mode 100755 index 31b25f837..000000000 --- a/tests/networks/docker-compose-localnet/run-docker.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# The script that exports node ids and runs docker-compose. - -set -euox pipefail - -# cheqd_noded docker wrapper - -CHEQD_NODE_IMAGE=cheqd-cli - -cheqd_noded_docker() { - docker run --rm \ - -v "$(pwd)":"/home/cheqd" \ - $CHEQD_NODE_IMAGE "$@" -} - -# sed in macos requires extra argument - -sed_extension='' -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - sed_extension='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - sed_extension='.orig' -fi - -pushd "node_configs/node0" - -export NODE_0_ID=$(cheqd_noded_docker tendermint show-node-id | sed 's/\r//g') - -popd - -docker-compose up -d diff --git a/tests/networks/docker-compose-localnet/wait.sh b/tests/networks/docker-compose-localnet/wait.sh index 06a3bbd5d..5db8422cd 100755 --- a/tests/networks/docker-compose-localnet/wait.sh +++ b/tests/networks/docker-compose-localnet/wait.sh @@ -1,12 +1,14 @@ #!/bin/bash +# TODO: Improve or get rid + set -euox pipefail cmd="$1" -for i in 1 2 3; do +for _ in 1 2 3; do sleep 60 - if eval $cmd; then + if eval "$cmd"; then echo "Waiter returned success!" exit 0 else diff --git a/tests/networks/docker-localnet/Dockerfile b/tests/networks/docker-localnet/Dockerfile index a0a7c1ef8..25db8d2f7 100644 --- a/tests/networks/docker-localnet/Dockerfile +++ b/tests/networks/docker-localnet/Dockerfile @@ -5,22 +5,19 @@ USER root RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ && apt-get -y install --no-install-recommends \ supervisor \ - jq + jq \ + nano USER cheqd -COPY --chown=cheqd:cheqd tests/networks/docker-localnet/gen-node-configs.sh ./ +COPY --chown=cheqd:cheqd tests/networks/tools/gen-network-config-base.sh ./ +COPY --chown=cheqd:cheqd tests/networks/docker-localnet/gen-network-config.sh ./ COPY tests/networks/docker-localnet/supervisord.conf /etc -RUN chmod +x ./gen-node-configs.sh -RUN ./gen-node-configs.sh +RUN chmod +x ./gen-network-config.sh; \ + ./gen-network-config.sh -# Update persistent peers list for at least one node -RUN NODE_0_ID=$(cheqd-noded tendermint show-node-id); \ - PERSISTENT_PEERS="$NODE_0_ID@127.0.0.1:26656"; \ - sed -i $extension "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_PEERS\"/g" .cheqdnode/config/config.toml - -EXPOSE 26657 26659 +EXPOSE 1317 26656 26657 9090 ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] STOPSIGNAL SIGTERM diff --git a/tests/networks/docker-localnet/gen-network-config.sh b/tests/networks/docker-localnet/gen-network-config.sh new file mode 100644 index 000000000..46846d57d --- /dev/null +++ b/tests/networks/docker-localnet/gen-network-config.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Tweaks network configuration generated by `../tools/gen-network-config.sh` for use with docker-localnet container. + +set -euo pipefail + +# Generate base network configuration +bash gen-network-config-base.sh cheqd 2 0 0 # 2 validators, 0 observers and 0 seeds + +# Change ports for validator-1 +sed -i.bak 's|laddr = "tcp://0.0.0.0:26656"|laddr = "tcp://0.0.0.0:26666"|g' network-config/validator-1/config/config.toml +sed -i.bak 's|laddr = "tcp://0.0.0.0:26657"|laddr = "tcp://0.0.0.0:26667"|g' network-config/validator-1/config/config.toml +sed -i.bak 's|pprof_laddr = "localhost:6060"|pprof_laddr = "localhost:6070"|g' network-config/validator-1/config/config.toml + +sed -i.bak 's|address = "0.0.0.0:9090"|address = "0.0.0.0:9100"|g' network-config/validator-1/config/app.toml +sed -i.bak 's|address = "0.0.0.0:9091"|address = "0.0.0.0:9101"|g' network-config/validator-1/config/app.toml +sed -i.bak 's|address = "tcp://0.0.0.0:1317"|address = "tcp://0.0.0.0:1327"|g' network-config/validator-1/config/app.toml +sed -i.bak 's|address = ":8080"|address = ":8090"|g' network-config/validator-1/config/app.toml + +# Set peers +VAL_0_ID=$(cheqd-noded tendermint show-node-id --home "network-config/validator-0") +PERSISTENT_PEERS="$VAL_0_ID@127.0.0.1:26656" +sed -i.bak "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_PEERS\"/g" network-config/validator-1/config/config.toml diff --git a/tests/networks/docker-localnet/gen-node-configs-new.sh b/tests/networks/docker-localnet/gen-node-configs-new.sh deleted file mode 100644 index ab0b0d419..000000000 --- a/tests/networks/docker-localnet/gen-node-configs-new.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash - -# Generates configurations for 4 nodes. - -# We can't pack several nodes without having `--home` flag working -# so reducing nodes count to 1 for now and creating follow up ticket. - -set -euox pipefail - -# sed in macos requires extra argument - -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - sed_extension='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - sed_extension='.orig' -fi - -function info() { - printf "[info] %s\n" "${1}" -} - - -CHAIN_ID="cheqd" -NODES_COUNT="4" - -for ((i=0 ; i<$NODES_COUNT ; i++)) -do - cheqd-noded init "node$i" --chain-id $CHAIN_ID --home "node$i" - cheqd-noded keys add "operator$i" --keyring-backend test -done - - -# NODE_0_ID=$(cheqd-noded tendermint show-node-id) -# NODE_0_VAL_PUBKEY=$(cheqd-noded tendermint show-validator) - -# Operator 0 -GENESIS="node0/config/genesis.json" -sed -i $sed_extension 's/"stake"/"ncheq"/' $GENESIS -cheqd-noded add-genesis-account "operator0" 20000000000000000ncheq --home "node0" --keyring-backend test -cheqd-noded gentx alice 1000000000000000ncheq --chain-id $CHAIN_ID --node-id "$NODE_0_ID" --pubkey "$NODE_0_VAL_PUBKEY" --home "node0" --keyring-backend test - -BASE_ACCOUNT_1="cheqd1rnr5jrt4exl0samwj0yegv99jeskl0hsxmcz96" -# Mnemonic: sketch mountain erode window enact net enrich smoke claim kangaroo another visual write meat latin bacon pulp similar forum guilt father state erase bright -cat <<< "$(jq '.app_state.bank.balances += [{"address": "'${BASE_ACCOUNT_1}'", "coins": [{"denom": "ncheq", "amount": "100001000000000000"}] }]' "$GENESIS")" > "$GENESIS" -cat <<< "$(jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount","address": "'${BASE_ACCOUNT_1}'", "pub_key": null,"account_number": "0","sequence": "0"}]' "$GENESIS")" > "$GENESIS" - -BASE_ACCOUNT_2="cheqd1l9sq0se0jd3vklyrrtjchx4ua47awug5vsyeeh" -# Mnemonic: ugly dirt sorry girl prepare argue door man that manual glow scout bomb pigeon matter library transfer flower clown cat miss pluck drama dizzy -cat <<< "$(jq '.app_state.bank.balances += [{"address": "'${BASE_ACCOUNT_2}'", "coins": [{"denom": "ncheq", "amount": "100001000000000000"}] }]' "$GENESIS")" > $GENESIS -cat <<< "$(jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount","address": "'${BASE_ACCOUNT_2}'", "pub_key": null,"account_number": "0","sequence": "0"}]' "$GENESIS")" > "$GENESIS" - -BASE_VESTING_ACCOUNT="cheqd1lkqddnapqvz2hujx2trpj7xj6c9hmuq7uhl0md" -# Mnemonic: coach index fence broken very cricket someone casino dial truth fitness stay habit such three jump exotic spawn planet fragile walk enact angry great -BASE_VESTING_COIN="{\"denom\":\"ncheq\",\"amount\":\"10001000000000000\"}" -cat <<< "$(jq '.app_state.bank.balances += [{"address": "'${BASE_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS")" > "$GENESIS" -cat <<< "$(jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.BaseVestingAccount", "base_account": {"address": "'${BASE_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['${BASE_VESTING_COIN}'], "delegated_free": [], "delegated_vesting": [], "end_time": "1630362459"}]' "$GENESIS")" > "$GENESIS" - -CONTINOUS_VESTING_ACCOUNT="cheqd1353p46macvn444rupg2jstmx3tmz657yt9gl4l" -# Mnemonic: phone worry flame safe panther dirt picture pepper purchase tiny search theme issue genre orange merit stove spoil surface color garment mind chuckle image -cat <<< "$(jq '.app_state.bank.balances += [{"address": "'${CONTINOUS_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS")" > "$GENESIS" -cat <<< "$(jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.ContinuousVestingAccount", "base_vesting_account": { "base_account": {"address": "'${CONTINOUS_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['${BASE_VESTING_COIN}'], "delegated_free": [], "delegated_vesting": [], "end_time": "1630362459"}, "start_time": "1630352459"}]' "$GENESIS")" > "$GENESIS" - -DELAYED_VESTING_ACCOUNT="cheqd1njwu33lek5jt4kzlmljkp366ny4qpqusahpyrj" -# Mnemonic: pilot text keen deal economy donkey use artist divide foster walk pink breeze proud dish brown icon shaft infant level labor lift will tomorrow -cat <<< "$(jq '.app_state.bank.balances += [{"address": "'${DELAYED_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS")" > "$GENESIS" -cat <<< "$(jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.DelayedVestingAccount", "base_vesting_account": { "base_account": {"address": "'${DELAYED_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['${BASE_VESTING_COIN}'], "delegated_free": [], "delegated_vesting": [], "end_time": "1630362459"}}]' "$GENESIS")" > "$GENESIS" - -PERIODIC_VESTING_ACCOUNT="cheqd1uyngr0l3xtyj07js9sdew9mk50tqeq8lghhcfr" -# Mnemonic: want merge flame plate trouble moral submit wing whale sick meat lonely yellow lens enable oyster slight health vast weird radar mesh grab olive -cat <<< "$(jq '.app_state.bank.balances += [{"address": "'${PERIODIC_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS")" > "$GENESIS" -cat <<< "$(jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.PeriodicVestingAccount", "base_vesting_account": { "base_account": {"address": "'${PERIODIC_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['${BASE_VESTING_COIN}'], "delegated_free": [], "delegated_vesting": [], "end_time": "1630362459"}, "start_time": "1630362439", "vesting_periods": [{"length": "20", "amount": ['${BASE_VESTING_COIN}']}]}]' "$GENESIS")" > "$GENESIS" - - -# Operators 1..N - -for ((i=1 ; i<$VALIDATORS_COUNT ; i++)) -do - cp "node$((i-1))/config/genesis.json" "node$i/config/genesis.json" - cp "node$((i-1))/config/genesis.json" "node$i/config/genesis.json" - - cheqd-noded add-genesis-account "operator$i" 20000000000000000ncheq --home "node$i" --keyring-backend test - cheqd-noded gentx alice 1000000000000000ncheq --chain-id $CHAIN_ID --node-id "$NODE_0_ID" --pubkey "$NODE_0_VAL_PUBKEY" --home "node$i" --keyring-backend test -done - -echo "##### [Validator operator] Collect gentxs" - -cheqd-noded collect-gentxs -cheqd-noded validate-genesis diff --git a/tests/networks/docker-localnet/gen-node-configs.sh b/tests/networks/docker-localnet/gen-node-configs.sh deleted file mode 100644 index 119118607..000000000 --- a/tests/networks/docker-localnet/gen-node-configs.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash - -# Generates configurations for 1 node. - -# We can't pack several nodes without having `--home` flag working -# so reducing nodes count to 1 for now and creating follow up ticket. - -set -euox pipefail - -# sed in macos requires extra argument - -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - sed_extension='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - sed_extension='.orig' -fi - -CHAIN_ID="cheqd" - -echo "##### [Node 0] Generating key" - -cheqd-noded init node0 --chain-id $CHAIN_ID -NODE_0_ID=$(cheqd-noded tendermint show-node-id) -NODE_0_VAL_PUBKEY=$(cheqd-noded tendermint show-validator) - -echo "##### [Node 0] Set fee" - -sed -i $sed_extension 's/minimum-gas-prices = ""/minimum-gas-prices = "25ncheq"/g' "$HOME/.cheqdnode/config/app.toml" - -echo "##### [Node 0] Switch on REST API" - -sed -i $sed_extension 's/enable = false/enable = true/g' "$HOME/.cheqdnode/config/app.toml" - -echo "##### [Node 0] Adjust consensus timeouts" - -sed -i $sed_extension 's/timeout_propose = "3s"/timeout_propose = "500ms"/g' "$HOME/.cheqdnode/config/config.toml" -sed -i $sed_extension 's/timeout_prevote = "1s"/timeout_prevote = "500ms"/g' "$HOME/.cheqdnode/config/config.toml" -sed -i $sed_extension 's/timeout_precommit = "1s"/timeout_precommit = "500ms"/g' "$HOME/.cheqdnode/config/config.toml" -sed -i $sed_extension 's/timeout_commit = "5s"/timeout_commit = "500ms"/g' "$HOME/.cheqdnode/config/config.toml" - -echo "##### [Validator operator] Generating key" - -cheqd-noded keys add alice --keyring-backend test - -echo "##### [Validator operator] Initializing genesis" - -GENESIS="$HOME/.cheqdnode/config/genesis.json" -sed -i $sed_extension 's/"stake"/"ncheq"/' $GENESIS - -echo "##### [Validator operator] Creating genesis account" - -cheqd-noded add-genesis-account alice 20000000000000000ncheq --keyring-backend test - -echo "##### Adding test accounts to the genesis" - -BASE_ACCOUNT_1="cheqd1rnr5jrt4exl0samwj0yegv99jeskl0hsxmcz96" -# Mnemonic: sketch mountain erode window enact net enrich smoke claim kangaroo another visual write meat latin bacon pulp similar forum guilt father state erase bright -cat <<< "$(jq '.app_state.bank.balances += [{"address": "'${BASE_ACCOUNT_1}'", "coins": [{"denom": "ncheq", "amount": "100001000000000000"}] }]' "$GENESIS")" > "$GENESIS" -cat <<< "$(jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount","address": "'${BASE_ACCOUNT_1}'", "pub_key": null,"account_number": "0","sequence": "0"}]' "$GENESIS")" > "$GENESIS" - -BASE_ACCOUNT_2="cheqd1l9sq0se0jd3vklyrrtjchx4ua47awug5vsyeeh" -# Mnemonic: ugly dirt sorry girl prepare argue door man that manual glow scout bomb pigeon matter library transfer flower clown cat miss pluck drama dizzy -cat <<< "$(jq '.app_state.bank.balances += [{"address": "'${BASE_ACCOUNT_2}'", "coins": [{"denom": "ncheq", "amount": "100001000000000000"}] }]' "$GENESIS")" > $GENESIS -cat <<< "$(jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount","address": "'${BASE_ACCOUNT_2}'", "pub_key": null,"account_number": "0","sequence": "0"}]' "$GENESIS")" > "$GENESIS" - -BASE_VESTING_ACCOUNT="cheqd1lkqddnapqvz2hujx2trpj7xj6c9hmuq7uhl0md" -# Mnemonic: coach index fence broken very cricket someone casino dial truth fitness stay habit such three jump exotic spawn planet fragile walk enact angry great -BASE_VESTING_COIN="{\"denom\":\"ncheq\",\"amount\":\"10001000000000000\"}" -cat <<< "$(jq '.app_state.bank.balances += [{"address": "'${BASE_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS")" > "$GENESIS" -cat <<< "$(jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.BaseVestingAccount", "base_account": {"address": "'${BASE_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['${BASE_VESTING_COIN}'], "delegated_free": [], "delegated_vesting": [], "end_time": "1630362459"}]' "$GENESIS")" > "$GENESIS" - -CONTINOUS_VESTING_ACCOUNT="cheqd1353p46macvn444rupg2jstmx3tmz657yt9gl4l" -# Mnemonic: phone worry flame safe panther dirt picture pepper purchase tiny search theme issue genre orange merit stove spoil surface color garment mind chuckle image -cat <<< "$(jq '.app_state.bank.balances += [{"address": "'${CONTINOUS_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS")" > "$GENESIS" -cat <<< "$(jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.ContinuousVestingAccount", "base_vesting_account": { "base_account": {"address": "'${CONTINOUS_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['${BASE_VESTING_COIN}'], "delegated_free": [], "delegated_vesting": [], "end_time": "1630362459"}, "start_time": "1630352459"}]' "$GENESIS")" > "$GENESIS" - -DELAYED_VESTING_ACCOUNT="cheqd1njwu33lek5jt4kzlmljkp366ny4qpqusahpyrj" -# Mnemonic: pilot text keen deal economy donkey use artist divide foster walk pink breeze proud dish brown icon shaft infant level labor lift will tomorrow -cat <<< "$(jq '.app_state.bank.balances += [{"address": "'${DELAYED_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS")" > "$GENESIS" -cat <<< "$(jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.DelayedVestingAccount", "base_vesting_account": { "base_account": {"address": "'${DELAYED_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['${BASE_VESTING_COIN}'], "delegated_free": [], "delegated_vesting": [], "end_time": "1630362459"}}]' "$GENESIS")" > "$GENESIS" - -PERIODIC_VESTING_ACCOUNT="cheqd1uyngr0l3xtyj07js9sdew9mk50tqeq8lghhcfr" -# Mnemonic: want merge flame plate trouble moral submit wing whale sick meat lonely yellow lens enable oyster slight health vast weird radar mesh grab olive -cat <<< "$(jq '.app_state.bank.balances += [{"address": "'${PERIODIC_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS")" > "$GENESIS" -cat <<< "$(jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.PeriodicVestingAccount", "base_vesting_account": { "base_account": {"address": "'${PERIODIC_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['${BASE_VESTING_COIN}'], "delegated_free": [], "delegated_vesting": [], "end_time": "1630362459"}, "start_time": "1630362439", "vesting_periods": [{"length": "20", "amount": ['${BASE_VESTING_COIN}']}]}]' "$GENESIS")" > "$GENESIS" - -echo "##### [Validator operator] Creating genesis validator" - -cheqd-noded gentx alice 1000000000000000ncheq --chain-id $CHAIN_ID --node-id "$NODE_0_ID" --pubkey "$NODE_0_VAL_PUBKEY" --keyring-backend test - -echo "##### [Validator operator] Collect gentxs" - -cheqd-noded collect-gentxs -cheqd-noded validate-genesis diff --git a/tests/networks/docker-localnet/supervisord.conf b/tests/networks/docker-localnet/supervisord.conf index 5bae819d2..2de38b184 100644 --- a/tests/networks/docker-localnet/supervisord.conf +++ b/tests/networks/docker-localnet/supervisord.conf @@ -16,15 +16,26 @@ childlogdir = /tmp strip_ansi = false -[program:node0] -command=cheqd-noded start --p2p.laddr tcp://127.0.0.1:26656 --grpc.address 0.0.0.0:9090 --rpc.laddr tcp://0.0.0.0:26657 +[program:validator-0] +command=cheqd-noded start --home "/home/cheqd/network-config/validator-0" directory=/home/cheqd -stdout_logfile=/tmp/node0.log -stderr_logfile=/tmp/node0.log +stdout_logfile=/tmp/validator-0.log +stderr_logfile=/tmp/validator-0.log +[program:validator-1] +command=cheqd-noded start --home "/home/cheqd/network-config/validator-1" +directory=/home/cheqd +stdout_logfile=/tmp/validator-1.log +stderr_logfile=/tmp/validator-1.log + +[program:validator-0-log] +command=tail -f /tmp/validator-0.log +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +redirect_stderr=true -[program:node0-log] -command=tail -f /tmp/node0.log +[program:validator-1-log] +command=tail -f /tmp/validator-1.log stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 redirect_stderr=true diff --git a/tests/networks/tools/gen-network-config-base.sh b/tests/networks/tools/gen-network-config-base.sh new file mode 100644 index 000000000..af1876a55 --- /dev/null +++ b/tests/networks/tools/gen-network-config-base.sh @@ -0,0 +1,206 @@ +#!/bin/bash + +# Generates network configuration for an arbitrary amount of validators, observers, and seeds. + +set -euo pipefail + +# sed in macos requires extra argument +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + SED_EXT='' +elif [[ "$OSTYPE" == "darwin"* ]]; then + SED_EXT='.orig' +fi + +# Params +CHAIN_ID=${1:-"cheqd"} # First parameter, default is "cheqd" + +VALIDATORS_COUNT=${2:-4} # Second parameter, default is 4 +SEEDS_COUNT=${3:-1} # Third parameter, default is 1 +OBSERVERS_COUNT=${4:-1} # Fourth parameter, default is 1 + +function init_node() { + NODE_HOME=$1 + NODE_MONIKER=$2 + + echo "[${NODE_MONIKER}] Initializing" + + cheqd-noded init "${NODE_MONIKER}" --chain-id "${CHAIN_ID}" --home "${NODE_HOME}" 2> /dev/null + cheqd-noded tendermint show-node-id --home "${NODE_HOME}" > "${NODE_HOME}/node_id.txt" + cheqd-noded tendermint show-validator --home "${NODE_HOME}" > "${NODE_HOME}/node_val_pubkey.txt" +} + +function configure_node() { + NODE_HOME=$1 + NODE_MONIKER=$2 + + echo "[${NODE_MONIKER}] Configuring app.toml and config.toml" + + APP_TOML="${NODE_HOME}/config/app.toml" + CONFIG_TOML="${NODE_HOME}/config/config.toml" + + sed -i $SED_EXT 's/minimum-gas-prices = ""/minimum-gas-prices = "25ncheq"/g' "${APP_TOML}" + sed -i $SED_EXT 's/enable = false/enable = true/g' "${APP_TOML}" + + sed -i $SED_EXT 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "${CONFIG_TOML}" + sed -i $SED_EXT 's|addr_book_strict = true|addr_book_strict = false|g' "${CONFIG_TOML}" + + sed -i $SED_EXT 's/timeout_propose = "3s"/timeout_propose = "500ms"/g' "${CONFIG_TOML}" + sed -i $SED_EXT 's/timeout_prevote = "1s"/timeout_prevote = "500ms"/g' "${CONFIG_TOML}" + sed -i $SED_EXT 's/timeout_precommit = "1s"/timeout_precommit = "500ms"/g' "${CONFIG_TOML}" + sed -i $SED_EXT 's/timeout_commit = "5s"/timeout_commit = "500ms"/g' "${CONFIG_TOML}" +} + +function configure_genesis() { + NODE_HOME=$1 + NODE_MONIKER=$2 + + echo "[${NODE_MONIKER}] Configuring genesis" + + GENESIS="${NODE_HOME}/config/genesis.json" + GENESIS_TMP="${NODE_HOME}/config/genesis_tmp.json" + + # Default denom + sed -i $SED_EXT 's/"stake"/"ncheq"/' "${GENESIS}" + + # Test accounts + BASE_ACCOUNT_1="cheqd1rnr5jrt4exl0samwj0yegv99jeskl0hsxmcz96" + # Mnemonic: sketch mountain erode window enact net enrich smoke claim kangaroo another visual write meat latin bacon pulp similar forum guilt father state erase bright + jq '.app_state.bank.balances += [{"address": "'${BASE_ACCOUNT_1}'", "coins": [{"denom": "ncheq", "amount": "100001000000000000"}] }]' "$GENESIS" > "$GENESIS_TMP" && \ + mv "${GENESIS_TMP}" "${GENESIS}" + jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount","address": "'${BASE_ACCOUNT_1}'", "pub_key": null,"account_number": "0","sequence": "0"}]' "$GENESIS" > "$GENESIS_TMP" && \ + mv "${GENESIS_TMP}" "${GENESIS}" + + BASE_ACCOUNT_2="cheqd1l9sq0se0jd3vklyrrtjchx4ua47awug5vsyeeh" + # Mnemonic: ugly dirt sorry girl prepare argue door man that manual glow scout bomb pigeon matter library transfer flower clown cat miss pluck drama dizzy + jq '.app_state.bank.balances += [{"address": "'${BASE_ACCOUNT_2}'", "coins": [{"denom": "ncheq", "amount": "100001000000000000"}] }]' "$GENESIS" > "$GENESIS_TMP" && \ + mv "${GENESIS_TMP}" "${GENESIS}" + jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount","address": "'${BASE_ACCOUNT_2}'", "pub_key": null,"account_number": "0","sequence": "0"}]' "$GENESIS" > "$GENESIS_TMP" && \ + mv "${GENESIS_TMP}" "${GENESIS}" + + BASE_VESTING_ACCOUNT="cheqd1lkqddnapqvz2hujx2trpj7xj6c9hmuq7uhl0md" + # Mnemonic: coach index fence broken very cricket someone casino dial truth fitness stay habit such three jump exotic spawn planet fragile walk enact angry great + # shellcheck disable=SC2089 + BASE_VESTING_COIN="{\"denom\":\"ncheq\",\"amount\":\"10001000000000000\"}" + jq '.app_state.bank.balances += [{"address": "'${BASE_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS" > "$GENESIS_TMP" && \ + mv "${GENESIS_TMP}" "${GENESIS}" + jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.BaseVestingAccount", "base_account": {"address": "'${BASE_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['"${BASE_VESTING_COIN}"'], "delegated_free": [], "delegated_vesting": [], "end_time": "1630362459"}]' "$GENESIS" > "$GENESIS_TMP" && \ + mv "${GENESIS_TMP}" "${GENESIS}" + + CONTINOUS_VESTING_ACCOUNT="cheqd1353p46macvn444rupg2jstmx3tmz657yt9gl4l" + # Mnemonic: phone worry flame safe panther dirt picture pepper purchase tiny search theme issue genre orange merit stove spoil surface color garment mind chuckle image + jq '.app_state.bank.balances += [{"address": "'${CONTINOUS_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS" > "$GENESIS_TMP" && \ + mv "${GENESIS_TMP}" "${GENESIS}" + jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.ContinuousVestingAccount", "base_vesting_account": { "base_account": {"address": "'${CONTINOUS_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['"${BASE_VESTING_COIN}"'], "delegated_free": [], "delegated_vesting": [], "end_time": "1630362459"}, "start_time": "1630352459"}]' "$GENESIS" > "$GENESIS_TMP" && \ + mv "${GENESIS_TMP}" "${GENESIS}" + + DELAYED_VESTING_ACCOUNT="cheqd1njwu33lek5jt4kzlmljkp366ny4qpqusahpyrj" + # Mnemonic: pilot text keen deal economy donkey use artist divide foster walk pink breeze proud dish brown icon shaft infant level labor lift will tomorrow + jq '.app_state.bank.balances += [{"address": "'${DELAYED_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS" > "$GENESIS_TMP" && \ + mv "${GENESIS_TMP}" "${GENESIS}" + jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.DelayedVestingAccount", "base_vesting_account": { "base_account": {"address": "'${DELAYED_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['"${BASE_VESTING_COIN}"'], "delegated_free": [], "delegated_vesting": [], "end_time": "1630362459"}}]' "$GENESIS" > "$GENESIS_TMP" && \ + mv "${GENESIS_TMP}" "${GENESIS}" + + PERIODIC_VESTING_ACCOUNT="cheqd1uyngr0l3xtyj07js9sdew9mk50tqeq8lghhcfr" + # Mnemonic: want merge flame plate trouble moral submit wing whale sick meat lonely yellow lens enable oyster slight health vast weird radar mesh grab olive + jq '.app_state.bank.balances += [{"address": "'${PERIODIC_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS" > "$GENESIS_TMP" && \ + mv "${GENESIS_TMP}" "${GENESIS}" + jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.PeriodicVestingAccount", "base_vesting_account": { "base_account": {"address": "'${PERIODIC_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['"${BASE_VESTING_COIN}"'], "delegated_free": [], "delegated_vesting": [], "end_time": "1630362459"}, "start_time": "1630362439", "vesting_periods": [{"length": "20", "amount": ['"${BASE_VESTING_COIN}"']}]}]' "$GENESIS" > "$GENESIS_TMP" && \ + mv "${GENESIS_TMP}" "${GENESIS}" +} + + +NETWORK_CONFIG_DIR="network-config" +rm -rf $NETWORK_CONFIG_DIR +mkdir $NETWORK_CONFIG_DIR + + +# Generating node configurations +for ((i=0 ; i> $FNAME_TXHASHES + txhash="$(echo "$send_res" | jq ".txhash" | tr -d '"')" + echo "$txhash" >> "$FNAME_TXHASHES" } # Send DID @@ -125,10 +132,11 @@ function send_did () { # Build CreateDid message KEY_ID="${did_to_write}#key1" - MSG_CREATE_DID='{"id":"'${did_to_write}'","verification_method":[{"id":"'${KEY_ID}'","type":"Ed25519VerificationKey2020","controller":"'${did_to_write}'","public_key_multibase":"'${ALICE_VER_PUB_MULTIBASE_58}'"}],"authentication":["'${KEY_ID}'"]}' + # shellcheck disable=SC2089 + MSG_CREATE_DID='{"id":"'${did_to_write}'","verification_method":[{"id":"'"${KEY_ID}"'","type":"Ed25519VerificationKey2020","controller":"'${did_to_write}'","public_key_multibase":"'${ALICE_VER_PUB_MULTIBASE_58}'"}],"authentication":["'${KEY_ID}'"]}' # Post the message - did=$(local_client_tx tx cheqd create-did ${MSG_CREATE_DID} ${KEY_ID} \ + did=$(local_client_tx tx cheqd create-did "${MSG_CREATE_DID}" "${KEY_ID}" \ --ver-key "${ALICE_VER_PRIV_BASE_64}" \ --from operator0 \ --gas-prices "25ncheq" \ @@ -137,40 +145,40 @@ function send_did () { -y) - txhash=$(echo $did | jq ".txhash" | tr -d '"') - echo $txhash >> $FNAME_TXHASHES + txhash=$(echo "$did" | jq ".txhash" | tr -d '"') + echo "$txhash" >> $FNAME_TXHASHES } # Check transaction hashes function check_tx_hashes () { - for txhash in $(cat $FNAME_TXHASHES); + while IFS= read -r txhash do - txhash=$(echo ${txhash} | tr -d '"') - result=$(cheqd_noded_docker query tx ${txhash} --output json) - tx_exist=$(echo $result | jq ".code") - if [ $tx_exist != "0" ] ; then + txhash=$(echo "${txhash}" | tr -d '"') + result=$(cheqd_noded_docker query tx "${txhash}" --output json) + tx_exist=$(echo "$result" | jq ".code") + if [ "$tx_exist" != "0" ] ; then echo "Error was in checking tx with hash: $txhash" exit 1 fi - done + done < $FNAME_TXHASHES } function get_balance () { address=$1 - echo $(cheqd_noded_docker query bank balances $address | grep amount | sed 's/[^0-9]//g') + cheqd_noded_docker query bank balances "$address" | grep amount | sed 's/[^0-9]//g' } function get_did () { requested_did=$1 - cheqd_noded_docker query cheqd did $requested_did --output json + cheqd_noded_docker query cheqd did "$requested_did" --output json } # Check that balance of operator3 increased to CHEQ_AMOUNT # Input: Address to check function check_balance () { address_to_check=$1 - new_balance=$(get_balance $address_to_check) - if [ $(echo $new_balance-$AMOUNT_BEFORE | bc) != $CHEQ_AMOUNT_NUMBER ]; + new_balance=$(get_balance "$address_to_check") + if [ $((new_balance - AMOUNT_BEFORE)) != $CHEQ_AMOUNT_NUMBER ]; then echo "Balance after token send is not expected" exit 1 @@ -180,8 +188,8 @@ function check_balance () { # Check that $DID exists function check_did () { did_to_check=$1 - did_from=$(get_did $did_to_check | jq ".did.id" | tr -d '"') - if [ $did_from != "$did_to_check" ]; + did_from=$(get_did "$did_to_check" | jq ".did.id" | tr -d '"') + if [ "$did_from" != "$did_to_check" ]; then echo "There is no any $did_to_check on server" exit 1 diff --git a/tests/upgrade/docker-compose.yml b/tests/upgrade/docker-compose.yml new file mode 100644 index 000000000..c63cb79bd --- /dev/null +++ b/tests/upgrade/docker-compose.yml @@ -0,0 +1,75 @@ +version: '3.2' + +services: + node0: + image: "${CHEQD_IMAGE_NAME}" + ports: + - "26656:26656" # p2p + - "26657:26657" # rpc + volumes: + - "${MOUNT_POINT}/node_configs/node0:/cheqd" + user: cheqd + environment: + - HOME=/cheqd + command: start --rpc.laddr tcp://0.0.0.0:26657 + + node1: + image: "${CHEQD_IMAGE_NAME}" + ports: + - "26659:26656" # p2p + - "26660:26657" # rpc + volumes: + - "${MOUNT_POINT}/node_configs/node1:/cheqd" + user: cheqd + environment: + - HOME=/cheqd + command: start --rpc.laddr tcp://0.0.0.0:26657 --p2p.persistent_peers "${NODE_0_ID}@node0:26656" + + node2: + image: "${CHEQD_IMAGE_NAME}" + ports: + - "26662:26656" # p2p + - "26663:26657" # rpc + volumes: + - "${MOUNT_POINT}/node_configs/node2:/cheqd" + user: cheqd + environment: + - HOME=/cheqd + command: start --rpc.laddr tcp://0.0.0.0:26657 --p2p.persistent_peers "${NODE_0_ID}@node0:26656" + + node3: + image: "${CHEQD_IMAGE_NAME}" + ports: + - "26665:26656" # p2p + - "26666:26657" # rpc + volumes: + - "${MOUNT_POINT}/node_configs/node3:/cheqd" + user: cheqd + environment: + - HOME=/cheqd + command: start --rpc.laddr tcp://0.0.0.0:26657 --p2p.persistent_peers "${NODE_0_ID}@node0:26656" + + observer0: + image: "${CHEQD_IMAGE_NAME}" + ports: + - "26668:26656" # p2p + - "26669:26657" # rpc + volumes: + - "${MOUNT_POINT}/node_configs/observer0:/cheqd" + user: cheqd + environment: + - HOME=/cheqd + command: start --rpc.laddr tcp://0.0.0.0:26657 --minimum-gas-prices "1cheq" --p2p.persistent_peers "${NODE_0_ID}@node0:26656" + + observer1: + image: "${CHEQD_IMAGE_NAME}" + ports: + - "26671:26656" # p2p + - "26672:26657" # rpc + volumes: + - "${MOUNT_POINT}/node_configs/observer1:/cheqd" + user: cheqd + environment: + - HOME=/cheqd + command: start --rpc.laddr tcp://0.0.0.0:26657 --minimum-gas-prices "1cheq" --p2p.persistent_peers "${NODE_0_ID}@node0:26656" + \ No newline at end of file diff --git a/tests/upgrade/gen_node_configs.sh b/tests/upgrade/gen_node_configs.sh index 9e979b257..4c8f13c6e 100755 --- a/tests/upgrade/gen_node_configs.sh +++ b/tests/upgrade/gen_node_configs.sh @@ -4,6 +4,7 @@ set -euox pipefail +# shellcheck disable=SC1091 . common.sh # sed in macos requires extra argument @@ -24,7 +25,7 @@ edit_genesis () { PARAMETER_NAME=$1 VALUE=$2 GENESIS_PATH=$3 - jq "${PARAMETER_NAME} = \"${VALUE}\"" $GENESIS_PATH > /tmp/1 && mv /tmp/1 $GENESIS_PATH + jq "${PARAMETER_NAME} = \"${VALUE}\"" "$GENESIS_PATH" > /tmp/1 && mv /tmp/1 "$GENESIS_PATH" } @@ -38,7 +39,7 @@ pushd $NODE_CONFIGS_DIR echo "Generating validator keys..." -for ((i=0 ; i<$VALIDATORS_COUNT ; i++)) +for ((i=0 ; i node_id.txt - echo "$(cheqd_noded_docker tendermint show-validator)" > node_val_pubkey.txt + cheqd_noded_docker init "node$i" --chain-id "$CHAIN_ID" + sudo chown -R "$USER:$USER" . + cheqd_noded_docker tendermint show-node-id > node_id.txt + cheqd_noded_docker tendermint show-validator > node_val_pubkey.txt echo "Setting minimum fee price..." @@ -64,28 +65,28 @@ mkdir $OPERATORS_HOME pushd $OPERATORS_HOME echo "Initializing genesis..." -cheqd_noded_docker init dummy_node --chain-id $CHAIN_ID -sudo chown -R $USER:$USER . +cheqd_noded_docker init dummy_node --chain-id "$CHAIN_ID" +sudo chown -R "$USER:$USER" . sed -i $sed_extension 's/"stake"/"ncheq"/' .cheqdnode/config/genesis.json echo "Generating operator keys..." -for ((i=0 ; i<$VALIDATORS_COUNT ; i++)) +for ((i=0 ; i node_id.txt - echo "$(cheqd_noded_docker tendermint show-validator)" > node_val_pubkey.txt + cheqd_noded_docker tendermint show-node-id > node_id.txt + cheqd_noded_docker tendermint show-validator > node_val_pubkey.txt echo "##### [Observer $i] Loading genesis..." OPERATORS_HOME="../client" diff --git a/tests/upgrade/initiate_upgrade.sh b/tests/upgrade/initiate_upgrade.sh index e97489444..e1fb2976a 100755 --- a/tests/upgrade/initiate_upgrade.sh +++ b/tests/upgrade/initiate_upgrade.sh @@ -2,19 +2,20 @@ set -euox pipefail +# shellcheck disable=SC1091 . common.sh # Send proposal to pool local_client_tx tx gov submit-proposal software-upgrade \ - $UPGRADE_NAME \ + "$UPGRADE_NAME" \ --title "Upgrade-to-new-version" \ --description "Description-of-upgrade-to-new-version" \ - --upgrade-height $UPGRADE_HEIGHT \ + --upgrade-height "$UPGRADE_HEIGHT" \ --from operator1 \ --gas auto \ --gas-adjustment 1.2 \ --gas-prices "25ncheq" \ - --chain-id $CHAIN_ID \ + --chain-id "$CHAIN_ID" \ -y # Set the deposit from operator0 @@ -24,7 +25,7 @@ local_client_tx tx gov deposit 1 \ --gas auto \ --gas-adjustment 1.2 \ --gas-prices 25ncheq \ - --chain-id $CHAIN_ID \ + --chain-id "$CHAIN_ID" \ -y # Make a vote for operator0 @@ -34,7 +35,7 @@ local_client_tx tx gov vote 1 \ --gas auto \ --gas-adjustment 1.3 \ --gas-prices 25ncheq \ - --chain-id $CHAIN_ID \ + --chain-id "$CHAIN_ID" \ -y # Make a vote for operator1 @@ -44,5 +45,5 @@ local_client_tx tx gov vote 1 \ --gas auto \ --gas-adjustment 1.3 \ --gas-prices 25ncheq \ - --chain-id $CHAIN_ID \ - -y \ No newline at end of file + --chain-id "$CHAIN_ID" \ + -y diff --git a/tests/upgrade/prepare.sh b/tests/upgrade/prepare.sh index 5cd410304..025372e70 100755 --- a/tests/upgrade/prepare.sh +++ b/tests/upgrade/prepare.sh @@ -2,6 +2,7 @@ set -euox pipefail +# shellcheck disable=SC1091 . common.sh # Stop docker compose @@ -14,26 +15,27 @@ clean_env bash gen_node_configs.sh # Start the network on version which will be upgraded from -docker_compose_up "${CHEQD_IMAGE_FROM}" $(pwd) +docker_compose_up "${CHEQD_IMAGE_FROM}" "$(pwd)" # Wait for start ordering, till height 1 bash ../networks/tools/wait-for-chain.sh 1 # Get address of operator which will be used for sending tokens before upgrade get_addresses +# shellcheck disable=SC2154 OP2_ADDRESS=${addresses[2]} # Send tokens before upgrade -send_tokens $OP2_ADDRESS +send_tokens "$OP2_ADDRESS" # Send DID transaction -send_did $DID_1 +send_did "$DID_1" # Check that token transaction exists check_tx_hashes # Check that $DID was written -check_did $DID_1 +check_did "$DID_1" # Check balance after token sending -check_balance $OP2_ADDRESS +check_balance "$OP2_ADDRESS" diff --git a/tests/upgrade/upgrade_and_check.sh b/tests/upgrade/upgrade_and_check.sh index 6e11d4624..107f9467f 100755 --- a/tests/upgrade/upgrade_and_check.sh +++ b/tests/upgrade/upgrade_and_check.sh @@ -2,55 +2,57 @@ set -euox pipefail +# shellcheck disable=SC1091 . common.sh # Wait for upgrade height -bash ../networks/tools/wait-for-chain.sh $UPGRADE_HEIGHT $(echo "2*$VOTING_PERIOD" | bc) +bash ../networks/tools/wait-for-chain.sh "$UPGRADE_HEIGHT" $((2 * VOTING_PERIOD)) # Stop docker-compose service docker_compose_down -# Make all the data accessable +# Make all the data accessible make_777 # Start docker-compose with new base image on new version -docker_compose_up "$CHEQD_IMAGE_TO" $(pwd) +docker_compose_up "$CHEQD_IMAGE_TO" "$(pwd)" # Check that upgrade was successful # Wait for upgrade height -bash ../networks/tools/wait-for-chain.sh $(echo $UPGRADE_HEIGHT+2 | bc) +bash ../networks/tools/wait-for-chain.sh $((UPGRADE_HEIGHT + 2)) -CURRENT_VERSION=$(docker run --entrypoint cheqd-noded $CHEQD_IMAGE_TO version 2>&1) +CURRENT_VERSION=$(docker run --entrypoint cheqd-noded "$CHEQD_IMAGE_TO" version 2>&1) -if [ $CURRENT_VERSION != $CHEQD_VERSION_TO ] ; then +if [ "$CURRENT_VERSION" != "$CHEQD_VERSION_TO" ] ; then echo "Upgrade to version $CHEQD_VERSION_TO was not successful" exit 1 fi get_addresses # "To" address was used for sending tokens before upgrade +# shellcheck disable=SC2154 OP_ADDRESS_BEFORE=${addresses[2]} # "To" address was used for sending tokens after upgrade OP_ADDRESS_AFTER=${addresses[3]} # Check balances after tokens sending -check_balance $OP_ADDRESS_BEFORE +check_balance "$OP_ADDRESS_BEFORE" # Check that did written before upgrade stil exist -check_did $DID_1 +check_did "$DID_1" # Send tokens for checking functionality after upgrade -send_tokens $OP_ADDRESS_AFTER +send_tokens "$OP_ADDRESS_AFTER" # Send DID after upgrade -send_did $DID_2 +send_did "$DID_2" # Check balance after token sending -check_balance $OP_ADDRESS_AFTER +check_balance "$OP_ADDRESS_AFTER" # Check that did written before upgrade stil exist -check_did $DID_2 +check_did "$DID_2" # Check that token transaction exists after upgrade too check_tx_hashes