From c32d32885db0a43ba6095594e0deb9162a824bf5 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 12:35:30 +0300 Subject: [PATCH 01/74] Added cli validators test in pytest and CI for localnet dependent tests. --- .github/workflows/test-localnet-tests.yml | 63 ++++++ .../tests/test_cli_validators.py | 197 ++++++++++++++++++ 2 files changed, 260 insertions(+) create mode 100644 .github/workflows/test-localnet-tests.yml create mode 100644 multiversx_sdk_cli/tests/test_cli_validators.py diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml new file mode 100644 index 00000000..3b675c91 --- /dev/null +++ b/.github/workflows/test-localnet-tests.yml @@ -0,0 +1,63 @@ +name: Test localnet-dependent tests + +on: + pull_request: + branches: [main, feat/*] + workflow_dispatch: + +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + +jobs: + localnet: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + python-version: [3.11] + + steps: + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip + pip3 install -r requirements.txt + pip3 install -r ./requirements-dev.txt --upgrade + + - name: Deploy a localnet + run: | + mkdir -p ~/multiversx-sdk + export PYTHONPATH=. + python3 -m multiversx_sdk_cli.cli config set github_api_token ${{ secrets.GITHUB_TOKEN }} + python3 -m multiversx_sdk_cli.cli localnet prerequisites --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml + python3 -m multiversx_sdk_cli.cli localnet build --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml + + # "Go" and artifacts from "GOPATH/pkg/mod" are not needed anymore. + sudo rm -rf ~/multiversx-sdk/golang + + python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml + python3 -m multiversx_sdk_cli.cli localnet config --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml + python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml --stop-after-seconds=120 + + if grep -r --include=\*.log "started committing block" ./localnet; then + echo "The localnet processed blocks successfully." + else + echo "The localnet failed to process blocks." + exit 1 + fi + + ls + + - name: Test localnet dependent tests + run: | + pytest -m require_localnet multiversx_sdk_cli/tests diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py new file mode 100644 index 00000000..7046371e --- /dev/null +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -0,0 +1,197 @@ +import pytest + +from pathlib import Path + +from multiversx_sdk_cli.cli import main + +testdata_path = Path(__file__).parent / "testdata" +testdata_out = Path(__file__).parent / "testdata-out" + +alice_pem = testdata_path / "alice.pem" +reward_address = "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8" +bls_key = "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" + + +@pytest.mark.require_localnet +def test_stake(): + validators_json = testdata_path / "validators.json" + + # Stake with recall nonce + return_code = main([ + "validator", "stake", + "--pem", str(alice_pem), + "--value", "2500000000000000000000", + "--validators-file", str(validators_json), + "--reward-address", reward_address, + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--recall-nonce" + ]) + assert return_code == 0 + + # Stake with provided nonce + return_code = main([ + "validator", "stake", + "--pem", str(alice_pem), + "--value", "2500000000000000000000", + "--validators-file", str(validators_json), + "--reward-address", reward_address, + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--nonce=0" + ]) + assert return_code == 0 + + +@pytest.mark.require_localnet +def test_stake_top_up(): + # Stake with topUp + return_code = main([ + "validator", "stake", "--top-up", + "--pem", str(alice_pem), + "--value", "2711000000000000000000", + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--recall-nonce" + ]) + assert return_code == 0 + + +@pytest.mark.require_localnet +def test_unstake(): + # Unstake + return_code = main([ + "validator", "unstake", + "--pem", str(alice_pem), + "--nodes-public-key", bls_key, + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--recall-nonce" + ]) + assert return_code == 0 + + +@pytest.mark.require_localnet +def test_unbond(): + # Unbond + return_code = main([ + "validator", "unbond", + "--pem", str(alice_pem), + "--nodes-public-key", bls_key, + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--recall-nonce" + ]) + assert return_code == 0 + + +@pytest.mark.require_localnet +def test_unjail(): + # Unjail + return_code = main([ + "validator", "unjail", + "--pem", str(alice_pem), + "--value", "2500000000000000000000", + "--nodes-public-key", bls_key, + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--recall-nonce" + ]) + assert return_code == 0 + + +@pytest.mark.require_localnet +def test_change_reward_address(): + # Change reward address + return_code = main([ + "validator", "change-reward-address", + "--pem", str(alice_pem), + "--reward-address", reward_address, + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--recall-nonce" + ]) + assert return_code == 0 + + +@pytest.mark.require_localnet +def test_unstake_nodes(): + # Unstake Nodes + return_code = main([ + "validator", "unstake-nodes", + "--pem", str(alice_pem), + "--nodes-public-key", bls_key, + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--recall-nonce" + ]) + assert return_code == 0 + + +@pytest.mark.require_localnet +def test_unstake_tokens(): + # Unstake Tokens + return_code = main([ + "validator", "unstake-tokens", + "--pem", str(alice_pem), + "--unstake-value", "11000000000000000000", + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--recall-nonce" + ]) + assert return_code == 0 + + +@pytest.mark.require_localnet +def test_unbond_nodes(): + # Unbond nodes + return_code = main([ + "validator", "unbond-nodes", + "--pem", str(alice_pem), + "--nodes-public-keys", bls_key, + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--recall-nonce" + ]) + assert return_code == 0 + + +@pytest.mark.require_localnet +def test_unbond_tokens(): + # Unbond nodes + return_code = main([ + "validator", "unbond-tokens", + "--pem", str(alice_pem), + "--unbond-value", "20000000000000000000", + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--recall-nonce" + ]) + assert return_code == 0 + + +@pytest.mark.require_localnet +def test_clean_registration_data(): + # Clean registration data + return_code = main([ + "validator", "clean-registered-data", + "--pem", str(alice_pem), + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--recall-nonce" + ]) + assert return_code == 0 + + +@pytest.mark.require_localnet +def test_re_stake_unstaked_nodes(): + # Clean registration data + return_code = main([ + "validator", "restake-unstaked-nodes", + "--pem", str(alice_pem), + "--nodes-public-keys", bls_key, + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--recall-nonce" + ]) + assert return_code == 0 From 84efeb2d301ede00f03078bee5c75788d1effce7 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 12:54:41 +0300 Subject: [PATCH 02/74] Added fixture for proxy polling. --- .github/workflows/test-localnet-tests.yml | 2 - .../tests/test_cli_validators.py | 56 +++++++++++++++---- pytest.ini | 1 + 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 3b675c91..21db81d5 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -55,8 +55,6 @@ jobs: echo "The localnet failed to process blocks." exit 1 fi - - ls - name: Test localnet dependent tests run: | diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index 7046371e..56f58777 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -1,3 +1,5 @@ +import requests +import time import pytest from pathlib import Path @@ -7,13 +9,43 @@ testdata_path = Path(__file__).parent / "testdata" testdata_out = Path(__file__).parent / "testdata-out" +proxy_url = "http://127.0.0.1:7950/network/config" alice_pem = testdata_path / "alice.pem" reward_address = "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8" bls_key = "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" +@pytest.fixture() +def poll_endpoint(): + start_time = time.time() # Record the start time + timeout = 60 + interval = 1 + + while True: + try: + # Make the request to the endpoint + response = requests.get(proxy_url, timeout=5) # Add request timeout to prevent blocking indefinitely + if response.status_code == 200: + # Break out of the loop if we get a successful response + return response.json() # Return the response (or .text, .content based on your needs) + else: + print(f"Received non-200 status code: {response.status_code}") + + except requests.RequestException as e: + # Handle network exceptions or timeouts + print(f"Request failed: {e}") + + # Check if the timeout is reached + if time.time() - start_time > timeout: + print("Polling timed out") + break + + # Wait for the specified interval before sending the next request + time.sleep(interval) + + @pytest.mark.require_localnet -def test_stake(): +def test_stake(poll_endpoint): validators_json = testdata_path / "validators.json" # Stake with recall nonce @@ -44,7 +76,7 @@ def test_stake(): @pytest.mark.require_localnet -def test_stake_top_up(): +def test_stake_top_up(poll_endpoint): # Stake with topUp return_code = main([ "validator", "stake", "--top-up", @@ -58,7 +90,7 @@ def test_stake_top_up(): @pytest.mark.require_localnet -def test_unstake(): +def test_unstake(poll_endpoint): # Unstake return_code = main([ "validator", "unstake", @@ -72,7 +104,7 @@ def test_unstake(): @pytest.mark.require_localnet -def test_unbond(): +def test_unbond(poll_endpoint): # Unbond return_code = main([ "validator", "unbond", @@ -86,7 +118,7 @@ def test_unbond(): @pytest.mark.require_localnet -def test_unjail(): +def test_unjail(poll_endpoint): # Unjail return_code = main([ "validator", "unjail", @@ -101,7 +133,7 @@ def test_unjail(): @pytest.mark.require_localnet -def test_change_reward_address(): +def test_change_reward_address(poll_endpoint): # Change reward address return_code = main([ "validator", "change-reward-address", @@ -115,7 +147,7 @@ def test_change_reward_address(): @pytest.mark.require_localnet -def test_unstake_nodes(): +def test_unstake_nodes(poll_endpoint): # Unstake Nodes return_code = main([ "validator", "unstake-nodes", @@ -129,7 +161,7 @@ def test_unstake_nodes(): @pytest.mark.require_localnet -def test_unstake_tokens(): +def test_unstake_tokens(poll_endpoint): # Unstake Tokens return_code = main([ "validator", "unstake-tokens", @@ -143,7 +175,7 @@ def test_unstake_tokens(): @pytest.mark.require_localnet -def test_unbond_nodes(): +def test_unbond_nodes(poll_endpoint): # Unbond nodes return_code = main([ "validator", "unbond-nodes", @@ -157,7 +189,7 @@ def test_unbond_nodes(): @pytest.mark.require_localnet -def test_unbond_tokens(): +def test_unbond_tokens(poll_endpoint): # Unbond nodes return_code = main([ "validator", "unbond-tokens", @@ -171,7 +203,7 @@ def test_unbond_tokens(): @pytest.mark.require_localnet -def test_clean_registration_data(): +def test_clean_registration_data(poll_endpoint): # Clean registration data return_code = main([ "validator", "clean-registered-data", @@ -184,7 +216,7 @@ def test_clean_registration_data(): @pytest.mark.require_localnet -def test_re_stake_unstaked_nodes(): +def test_re_stake_unstaked_nodes(poll_endpoint): # Clean registration data return_code = main([ "validator", "restake-unstaked-nodes", diff --git a/pytest.ini b/pytest.ini index 6669f27f..cab31729 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,5 +2,6 @@ markers = skip_on_windows: marks tests as being skiped when running on windows (deselect with '-m "skip_on_windows"') only: only run a specific test (run using: pytest -m "only") + require_localnet: marks tests that require a localnet (run using: pytest -m require_localnet) log_cli = True From 1685f0248df4c8a934b0611927f29fe4aa103798 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 14:16:39 +0300 Subject: [PATCH 03/74] try different endpoint for polling. --- multiversx_sdk_cli/tests/test_cli_validators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index 56f58777..256eeeaf 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -9,7 +9,7 @@ testdata_path = Path(__file__).parent / "testdata" testdata_out = Path(__file__).parent / "testdata-out" -proxy_url = "http://127.0.0.1:7950/network/config" +proxy_url = "http://localhost:7950/network/config" alice_pem = testdata_path / "alice.pem" reward_address = "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8" bls_key = "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" From f4e9c730ed1e2be54f50ae7a847147e91afec185 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 14:39:37 +0300 Subject: [PATCH 04/74] adding debug command. --- .github/workflows/test-localnet-tests.yml | 1 + multiversx_sdk_cli/tests/test_cli_validators.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 21db81d5..ea1677eb 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -58,4 +58,5 @@ jobs: - name: Test localnet dependent tests run: | + netstat -tulpn pytest -m require_localnet multiversx_sdk_cli/tests diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index 256eeeaf..56f58777 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -9,7 +9,7 @@ testdata_path = Path(__file__).parent / "testdata" testdata_out = Path(__file__).parent / "testdata-out" -proxy_url = "http://localhost:7950/network/config" +proxy_url = "http://127.0.0.1:7950/network/config" alice_pem = testdata_path / "alice.pem" reward_address = "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8" bls_key = "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" From 315e3b0b34175fc5520ba46d12568ebc472a8f96 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 14:48:51 +0300 Subject: [PATCH 05/74] more debugging. --- .github/workflows/test-localnet-tests.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index ea1677eb..3ab50df7 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -13,7 +13,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest] +# TODO: enable mac-os back once debugging is done. +# os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] python-version: [3.11] steps: @@ -59,4 +61,6 @@ jobs: - name: Test localnet dependent tests run: | netstat -tulpn + sleep 3m + curl -XGET http://127.0.0.1:7950/network/config pytest -m require_localnet multiversx_sdk_cli/tests From 39be1b4515d71e4773cabad30bfe78107785af33 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 16:03:10 +0300 Subject: [PATCH 06/74] make localnet run in background. --- .github/workflows/test-localnet-tests.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 3ab50df7..a4e03d87 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -49,7 +49,7 @@ jobs: python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml python3 -m multiversx_sdk_cli.cli localnet config --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml - python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml --stop-after-seconds=120 + python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml & if grep -r --include=\*.log "started committing block" ./localnet; then echo "The localnet processed blocks successfully." @@ -60,7 +60,5 @@ jobs: - name: Test localnet dependent tests run: | - netstat -tulpn - sleep 3m curl -XGET http://127.0.0.1:7950/network/config pytest -m require_localnet multiversx_sdk_cli/tests From 18d6c714a25d3ed8fb6cc9fab0d97b41120d615c Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 17:35:47 +0300 Subject: [PATCH 07/74] added Dockerfile and integrated CI with docker. --- .github/workflows/test-localnet-tests.yml | 38 ++--------------------- Dockerfile | 22 +++++++++++++ 2 files changed, 25 insertions(+), 35 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index a4e03d87..1d6d80cb 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -19,46 +19,14 @@ jobs: python-version: [3.11] steps: - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies + - name: Set up Docker image run: | - python3 -m pip install --upgrade pip - pip3 install -r requirements.txt - pip3 install -r ./requirements-dev.txt --upgrade + docker build --build-arg PYTHON_VERSION=${{ matrix.python-version }} -t mxpy . - name: Deploy a localnet run: | - mkdir -p ~/multiversx-sdk - export PYTHONPATH=. - python3 -m multiversx_sdk_cli.cli config set github_api_token ${{ secrets.GITHUB_TOKEN }} - python3 -m multiversx_sdk_cli.cli localnet prerequisites --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml - python3 -m multiversx_sdk_cli.cli localnet build --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml - - # "Go" and artifacts from "GOPATH/pkg/mod" are not needed anymore. - sudo rm -rf ~/multiversx-sdk/golang - - python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml - python3 -m multiversx_sdk_cli.cli localnet config --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml - python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml & - - if grep -r --include=\*.log "started committing block" ./localnet; then - echo "The localnet processed blocks successfully." - else - echo "The localnet failed to process blocks." - exit 1 - fi + docker run -d -p 7950:7950 mxpy localnet start - name: Test localnet dependent tests run: | - curl -XGET http://127.0.0.1:7950/network/config pytest -m require_localnet multiversx_sdk_cli/tests diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..0bf6711b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +ARG PYTHON_VERSION=3.10 + +# Step 1: Use an official Python runtime as a parent image +FROM python:${PYTHON_VERSION}-slim + +# Step 2: Set the working directory in the container +WORKDIR /usr/src/app + +# Step 3: Copy the requirements file into the container +COPY requirements.txt ./ + +# Step 5: Copy the requirements-dev file into the container +COPY requirements-dev.txt ./ + +# Step 6: Install any dependencies listed in requirements.txt +RUN pip install --no-cache-dir -r requirements.txt + +# Step 7: Copy the current directory contents into the container +COPY . . + +# Step 6: Specify the command to run the application +ENTRYPOINT ["python", "-m", "multiversx_sdk_cli.cli"] \ No newline at end of file From 3f825a2922537a4168787df8233a012c7b6799a5 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 17:38:17 +0300 Subject: [PATCH 08/74] add checkout. --- .github/workflows/test-localnet-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 1d6d80cb..73e140c6 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -19,6 +19,7 @@ jobs: python-version: [3.11] steps: + - uses: actions/checkout@v2 - name: Set up Docker image run: | docker build --build-arg PYTHON_VERSION=${{ matrix.python-version }} -t mxpy . From 99a198d40fb0369375e9fa0f13b0904db704255d Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 17:40:50 +0300 Subject: [PATCH 09/74] install python dependencies in order to trigger the tests. --- .github/workflows/test-localnet-tests.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 73e140c6..b9b4c626 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -19,7 +19,23 @@ jobs: python-version: [3.11] steps: + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip + pip3 install -r requirements.txt + pip3 install -r ./requirements-dev.txt --upgrade + - name: Set up Docker image run: | docker build --build-arg PYTHON_VERSION=${{ matrix.python-version }} -t mxpy . From 3d2be36de5842efdcd725a4ea2fb00b379fed68a Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 17:47:31 +0300 Subject: [PATCH 10/74] rename to localhost. possible issue with the loopback interface. --- multiversx_sdk_cli/tests/test_cli_validators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index 56f58777..256eeeaf 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -9,7 +9,7 @@ testdata_path = Path(__file__).parent / "testdata" testdata_out = Path(__file__).parent / "testdata-out" -proxy_url = "http://127.0.0.1:7950/network/config" +proxy_url = "http://localhost:7950/network/config" alice_pem = testdata_path / "alice.pem" reward_address = "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8" bls_key = "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" From beef1398f9538b8072c4c3120a549fec0f1ce9bb Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 17:50:32 +0300 Subject: [PATCH 11/74] debug commands --- .github/workflows/test-localnet-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index b9b4c626..46e5bed4 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -46,4 +46,5 @@ jobs: - name: Test localnet dependent tests run: | + curl -X GET http://localhost:7950/network/config pytest -m require_localnet multiversx_sdk_cli/tests From 95f1a152c44a0bfb727ed459ab8a98169e57e1bb Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 17:51:49 +0300 Subject: [PATCH 12/74] more debugging. --- .github/workflows/test-localnet-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 46e5bed4..c472d2b0 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -46,5 +46,6 @@ jobs: - name: Test localnet dependent tests run: | + docker ps curl -X GET http://localhost:7950/network/config pytest -m require_localnet multiversx_sdk_cli/tests From 23b9961ca4448f949043f7733c2b2cdb0f7c912c Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 17:53:04 +0300 Subject: [PATCH 13/74] add a sleep for debugging. --- .github/workflows/test-localnet-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index c472d2b0..ad58ab04 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -47,5 +47,6 @@ jobs: - name: Test localnet dependent tests run: | docker ps + sleep 5m curl -X GET http://localhost:7950/network/config pytest -m require_localnet multiversx_sdk_cli/tests From ef9cdb2b9d8c8d0fbdd027e6b16cbdcd0657bf0a Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 18:01:59 +0300 Subject: [PATCH 14/74] trying to debug docker publishing in GHA. --- .github/workflows/test-localnet-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index ad58ab04..1c70bb08 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -42,11 +42,11 @@ jobs: - name: Deploy a localnet run: | - docker run -d -p 7950:7950 mxpy localnet start + docker run -name localnet -d -p 7950:7950 mxpy localnet start - name: Test localnet dependent tests run: | - docker ps sleep 5m - curl -X GET http://localhost:7950/network/config + docker logs localnet | grep proxy + curl -X GET http://0.0.0.0:7950/network/config pytest -m require_localnet multiversx_sdk_cli/tests From 5043947beb63ad6ff003c241e2463370fe91db5d Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 18:05:10 +0300 Subject: [PATCH 15/74] cosmetic changes --- .github/workflows/test-localnet-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 1c70bb08..39929665 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -42,7 +42,7 @@ jobs: - name: Deploy a localnet run: | - docker run -name localnet -d -p 7950:7950 mxpy localnet start + docker run --name localnet -d -p 7950:7950 mxpy localnet start - name: Test localnet dependent tests run: | From 4953eaa2fbcac5d76655ec8ec3fc075591446a07 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 18:12:02 +0300 Subject: [PATCH 16/74] move sleep above. --- .github/workflows/test-localnet-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 39929665..6135ca63 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -43,10 +43,10 @@ jobs: - name: Deploy a localnet run: | docker run --name localnet -d -p 7950:7950 mxpy localnet start + sleep 2m - name: Test localnet dependent tests run: | - sleep 5m docker logs localnet | grep proxy curl -X GET http://0.0.0.0:7950/network/config pytest -m require_localnet multiversx_sdk_cli/tests From a5ccb0352d7403d8c15aac9e76241d00e457efc4 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 18:19:28 +0300 Subject: [PATCH 17/74] more debugging. --- .github/workflows/test-localnet-tests.yml | 5 ++--- multiversx_sdk_cli/tests/test_cli_validators.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 6135ca63..c9ee68e1 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -43,10 +43,9 @@ jobs: - name: Deploy a localnet run: | docker run --name localnet -d -p 7950:7950 mxpy localnet start - sleep 2m - name: Test localnet dependent tests run: | - docker logs localnet | grep proxy - curl -X GET http://0.0.0.0:7950/network/config + sleep 2m + curl -XGET http://0.0.0.0:7950/network/config pytest -m require_localnet multiversx_sdk_cli/tests diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index 256eeeaf..6833513b 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -18,7 +18,7 @@ @pytest.fixture() def poll_endpoint(): start_time = time.time() # Record the start time - timeout = 60 + timeout = 300 interval = 1 while True: From 7e889f1697bd8bd0a92259756f7c366670a00c83 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 18:25:47 +0300 Subject: [PATCH 18/74] increase timeout to 10 mins. --- .github/workflows/test-localnet-tests.yml | 2 -- multiversx_sdk_cli/tests/test_cli_validators.py | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index c9ee68e1..01297dd5 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -46,6 +46,4 @@ jobs: - name: Test localnet dependent tests run: | - sleep 2m - curl -XGET http://0.0.0.0:7950/network/config pytest -m require_localnet multiversx_sdk_cli/tests diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index 6833513b..8a01ae41 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -18,7 +18,7 @@ @pytest.fixture() def poll_endpoint(): start_time = time.time() # Record the start time - timeout = 300 + timeout = 600 interval = 1 while True: From 0af4d95e7dea639e3b0b35f53888e656a7fc77cd Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 18:35:00 +0300 Subject: [PATCH 19/74] check logs of docker localnet inside worker. --- .github/workflows/test-localnet-tests.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 01297dd5..896a6067 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -42,8 +42,4 @@ jobs: - name: Deploy a localnet run: | - docker run --name localnet -d -p 7950:7950 mxpy localnet start - - - name: Test localnet dependent tests - run: | - pytest -m require_localnet multiversx_sdk_cli/tests + docker run --name localnet -p 7950:7950 mxpy localnet start From 05a7e574541e9455d4cab3580851900c302a7836 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 19:27:01 +0300 Subject: [PATCH 20/74] fix CI and dockerfile by installing build-essential in the docker container. --- .github/workflows/test-localnet-tests.yml | 6 +++++- Dockerfile | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 896a6067..a5cc097f 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -42,4 +42,8 @@ jobs: - name: Deploy a localnet run: | - docker run --name localnet -p 7950:7950 mxpy localnet start + docker run --name localnet -d -p 7950:7950 mxpy localnet setup && mxpy localnet start + + - name: Test localnet dependent tests + run: | + pytest -m require_localnet multiversx_sdk_cli/tests diff --git a/Dockerfile b/Dockerfile index 0bf6711b..3d69006a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,8 +15,11 @@ COPY requirements-dev.txt ./ # Step 6: Install any dependencies listed in requirements.txt RUN pip install --no-cache-dir -r requirements.txt -# Step 7: Copy the current directory contents into the container +# Step 7: Install build-essential. Will be needed to compile the node binaries. +RUN apt update && apt install -y build-essential + +# Step 8: Copy the current directory contents into the container COPY . . -# Step 6: Specify the command to run the application +# Step 9: Specify the command to run the application ENTRYPOINT ["python", "-m", "multiversx_sdk_cli.cli"] \ No newline at end of file From ec17ddac0f5fcd6ce74c13544be7c8db15876800 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Thu, 24 Oct 2024 19:30:38 +0300 Subject: [PATCH 21/74] adding verbose command. --- .github/workflows/test-localnet-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index a5cc097f..06db8c9d 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -42,7 +42,7 @@ jobs: - name: Deploy a localnet run: | - docker run --name localnet -d -p 7950:7950 mxpy localnet setup && mxpy localnet start + docker run --name localnet -d -p 7950:7950 mxpy localnet setup && python -m multiversx_sdk_cli.cli localnet start - name: Test localnet dependent tests run: | From 1a4fe12f5f5bafd8041bdbd63f724d25910ec065 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 10:29:43 +0300 Subject: [PATCH 22/74] Fix deploy localnet job. --- .github/workflows/test-localnet-tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 06db8c9d..82b99b91 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -42,7 +42,9 @@ jobs: - name: Deploy a localnet run: | - docker run --name localnet -d -p 7950:7950 mxpy localnet setup && python -m multiversx_sdk_cli.cli localnet start + docker run -d -p 7950:7950 \ + -v ./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml=/usr/src/app/localnet.toml \ + mxpy localnet setup && python -m multiversx_sdk_cli.cli localnet start - name: Test localnet dependent tests run: | From 900530f3f2c6f0eb0e0d963d35735cfaa3f87e5f Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 10:31:49 +0300 Subject: [PATCH 23/74] fix whitespaces in multi-line command. --- .github/workflows/test-localnet-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 82b99b91..bbf55dd5 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -42,7 +42,7 @@ jobs: - name: Deploy a localnet run: | - docker run -d -p 7950:7950 \ + docker run -d -p 7950:7950 \ -v ./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml=/usr/src/app/localnet.toml \ mxpy localnet setup && python -m multiversx_sdk_cli.cli localnet start From 17a08cf813f4fc05b2d3e62ef8bc4e9386933cd0 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 11:07:02 +0300 Subject: [PATCH 24/74] fixing docker image and localnet setup. --- .github/workflows/test-localnet-tests.yml | 6 ++---- Dockerfile | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index bbf55dd5..7cccad1a 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -42,10 +42,8 @@ jobs: - name: Deploy a localnet run: | - docker run -d -p 7950:7950 \ - -v ./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml=/usr/src/app/localnet.toml \ - mxpy localnet setup && python -m multiversx_sdk_cli.cli localnet start - + docker run -d -p 7950:7950 mxpy localnet start \ + --configfile=/usr/src/app/multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml - name: Test localnet dependent tests run: | pytest -m require_localnet multiversx_sdk_cli/tests diff --git a/Dockerfile b/Dockerfile index 3d69006a..9d6f84a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,5 +21,8 @@ RUN apt update && apt install -y build-essential # Step 8: Copy the current directory contents into the container COPY . . -# Step 9: Specify the command to run the application +# Step 9: Setup the localnet configuration in the eventuality of a localnet start. +RUN python -m multiversx_sdk_cli.cli localnet setup --configfile=/usr/src/app/multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml + +# Step 10: Specify the entrypoint to run the application ENTRYPOINT ["python", "-m", "multiversx_sdk_cli.cli"] \ No newline at end of file From 8359cbb3ccc6e0121a52375193014ddaefb8dd6d Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 11:19:59 +0300 Subject: [PATCH 25/74] adding separate validators json file for docker tests. --- Dockerfile | 2 +- multiversx_sdk_cli/tests/test_cli_validators.py | 2 +- .../tests/testdata/validators_docker.json | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 multiversx_sdk_cli/tests/testdata/validators_docker.json diff --git a/Dockerfile b/Dockerfile index 9d6f84a4..bf595f5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,4 +25,4 @@ COPY . . RUN python -m multiversx_sdk_cli.cli localnet setup --configfile=/usr/src/app/multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml # Step 10: Specify the entrypoint to run the application -ENTRYPOINT ["python", "-m", "multiversx_sdk_cli.cli"] \ No newline at end of file +CMD ["python", "-m", "multiversx_sdk_cli.cli"] \ No newline at end of file diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index 8a01ae41..eeccb028 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -46,7 +46,7 @@ def poll_endpoint(): @pytest.mark.require_localnet def test_stake(poll_endpoint): - validators_json = testdata_path / "validators.json" + validators_json = testdata_path / "validators_docker.json" # Stake with recall nonce return_code = main([ diff --git a/multiversx_sdk_cli/tests/testdata/validators_docker.json b/multiversx_sdk_cli/tests/testdata/validators_docker.json new file mode 100644 index 00000000..edf4f998 --- /dev/null +++ b/multiversx_sdk_cli/tests/testdata/validators_docker.json @@ -0,0 +1,13 @@ +{ + "validators": [ + { + "pemFile": "/usr/src/app/localnet/validator00/config/walletKey.pem" + }, + { + "pemFile": "/usr/src/app/localnet/validator00/config/walletKey.pem" + }, + { + "pemFile": "/usr/src/app/localnet/validator00/config/walletKey.pem" + } + ] +} From b43c31a785e95e41e3fee4245e60396740b09eed Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 11:23:43 +0300 Subject: [PATCH 26/74] fixing Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bf595f5f..9d6f84a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,4 +25,4 @@ COPY . . RUN python -m multiversx_sdk_cli.cli localnet setup --configfile=/usr/src/app/multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml # Step 10: Specify the entrypoint to run the application -CMD ["python", "-m", "multiversx_sdk_cli.cli"] \ No newline at end of file +ENTRYPOINT ["python", "-m", "multiversx_sdk_cli.cli"] \ No newline at end of file From bbe93e7af76598b59b73562b7f3acb75515ad222 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 11:31:44 +0300 Subject: [PATCH 27/74] fix paths for validators_docker.json --- multiversx_sdk_cli/tests/testdata/validators_docker.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/multiversx_sdk_cli/tests/testdata/validators_docker.json b/multiversx_sdk_cli/tests/testdata/validators_docker.json index edf4f998..ac0198c0 100644 --- a/multiversx_sdk_cli/tests/testdata/validators_docker.json +++ b/multiversx_sdk_cli/tests/testdata/validators_docker.json @@ -1,13 +1,13 @@ { "validators": [ { - "pemFile": "/usr/src/app/localnet/validator00/config/walletKey.pem" + "pemFile": "/usr/src/app/localnet/validator00/config/validatorKey.pem" }, { - "pemFile": "/usr/src/app/localnet/validator00/config/walletKey.pem" + "pemFile": "/usr/src/app/localnet/validator00/config/validatorKey.pem" }, { - "pemFile": "/usr/src/app/localnet/validator00/config/walletKey.pem" + "pemFile": "/usr/src/app/localnet/validator00/config/validatorKey.pem" } ] } From ad7e421f941811858cc2800c2008ccca86cbbd2f Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 11:41:28 +0300 Subject: [PATCH 28/74] fix paths in validators_docker.json --- multiversx_sdk_cli/tests/testdata/validators_docker.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multiversx_sdk_cli/tests/testdata/validators_docker.json b/multiversx_sdk_cli/tests/testdata/validators_docker.json index ac0198c0..e0cc9f79 100644 --- a/multiversx_sdk_cli/tests/testdata/validators_docker.json +++ b/multiversx_sdk_cli/tests/testdata/validators_docker.json @@ -4,10 +4,10 @@ "pemFile": "/usr/src/app/localnet/validator00/config/validatorKey.pem" }, { - "pemFile": "/usr/src/app/localnet/validator00/config/validatorKey.pem" + "pemFile": "/usr/src/app/localnet/validator01/config/validatorKey.pem" }, { - "pemFile": "/usr/src/app/localnet/validator00/config/validatorKey.pem" + "pemFile": "/usr/src/app/localnet/validator02/config/validatorKey.pem" } ] } From bfe909fe156897d01d822dce731aee7e0882587f Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 12:17:51 +0300 Subject: [PATCH 29/74] fix validators_docker.json --- .github/workflows/test-localnet-tests.yml | 9 ++++++++- multiversx_sdk_cli/tests/testdata/validators_docker.json | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 7cccad1a..44c9c103 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -42,8 +42,15 @@ jobs: - name: Deploy a localnet run: | - docker run -d -p 7950:7950 mxpy localnet start \ + docker run --name localnet -d -p 7950:7950 mxpy localnet start \ --configfile=/usr/src/app/multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml + - name: Test localnet dependent tests run: | + docker cp localnet:/usr/src/app/localnet/validator00/config/validatorKey.pem ./validatorKey00.pem + docker cp localnet:/usr/src/app/localnet/validator01/config/validatorKey.pem ./validatorKey01.pem + docker cp localnet:/usr/src/app/localnet/validator02/config/validatorKey.pem ./validatorKey02.pem + + + pytest -m require_localnet multiversx_sdk_cli/tests diff --git a/multiversx_sdk_cli/tests/testdata/validators_docker.json b/multiversx_sdk_cli/tests/testdata/validators_docker.json index e0cc9f79..c3314d0a 100644 --- a/multiversx_sdk_cli/tests/testdata/validators_docker.json +++ b/multiversx_sdk_cli/tests/testdata/validators_docker.json @@ -1,13 +1,13 @@ { "validators": [ { - "pemFile": "/usr/src/app/localnet/validator00/config/validatorKey.pem" + "pemFile": "~/mx-sdk-py-cli/validatorKey00.pem" }, { - "pemFile": "/usr/src/app/localnet/validator01/config/validatorKey.pem" + "pemFile": "~/mx-sdk-py-cli/validatorKey01.pem" }, { - "pemFile": "/usr/src/app/localnet/validator02/config/validatorKey.pem" + "pemFile": "~/mx-sdk-py-cli/validatorKey02.pem" } ] } From 83b76aa80e1e0f986d8c3e5c67d40f672457cbb4 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 12:22:08 +0300 Subject: [PATCH 30/74] fix yaml file. --- .github/workflows/test-localnet-tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 44c9c103..a341db7a 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -50,7 +50,4 @@ jobs: docker cp localnet:/usr/src/app/localnet/validator00/config/validatorKey.pem ./validatorKey00.pem docker cp localnet:/usr/src/app/localnet/validator01/config/validatorKey.pem ./validatorKey01.pem docker cp localnet:/usr/src/app/localnet/validator02/config/validatorKey.pem ./validatorKey02.pem - - - pytest -m require_localnet multiversx_sdk_cli/tests From 88047542e2f6507d999994d527a6f4b01583b54b Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 12:40:07 +0300 Subject: [PATCH 31/74] fix yaml file, round 2. --- .github/workflows/test-localnet-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index a341db7a..343b2ee0 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -50,4 +50,4 @@ jobs: docker cp localnet:/usr/src/app/localnet/validator00/config/validatorKey.pem ./validatorKey00.pem docker cp localnet:/usr/src/app/localnet/validator01/config/validatorKey.pem ./validatorKey01.pem docker cp localnet:/usr/src/app/localnet/validator02/config/validatorKey.pem ./validatorKey02.pem - pytest -m require_localnet multiversx_sdk_cli/tests + pytest -m require_localnet multiversx_sdk_cli/tests From d3d0d5c7a9c91fb2f2446d6bee59a1869e11a9c0 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 12:47:12 +0300 Subject: [PATCH 32/74] add debug commands. --- .github/workflows/test-localnet-tests.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 343b2ee0..582060b1 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -50,4 +50,9 @@ jobs: docker cp localnet:/usr/src/app/localnet/validator00/config/validatorKey.pem ./validatorKey00.pem docker cp localnet:/usr/src/app/localnet/validator01/config/validatorKey.pem ./validatorKey01.pem docker cp localnet:/usr/src/app/localnet/validator02/config/validatorKey.pem ./validatorKey02.pem + + ls + echo $(pwd) + + pytest -m require_localnet multiversx_sdk_cli/tests From 9f9b8c03664d00312a3204eaa5755c9f62bdd8d3 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 12:54:47 +0300 Subject: [PATCH 33/74] debug home directory inside runner. --- .github/workflows/test-localnet-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 582060b1..dfa69246 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -52,7 +52,7 @@ jobs: docker cp localnet:/usr/src/app/localnet/validator02/config/validatorKey.pem ./validatorKey02.pem ls - echo $(pwd) + echo ~ pytest -m require_localnet multiversx_sdk_cli/tests From 79392ad94d0013d87e32fd77cf9a463cfbf6d7b5 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 13:00:15 +0300 Subject: [PATCH 34/74] fix paths. --- multiversx_sdk_cli/tests/testdata/validators_docker.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/multiversx_sdk_cli/tests/testdata/validators_docker.json b/multiversx_sdk_cli/tests/testdata/validators_docker.json index c3314d0a..2adb1109 100644 --- a/multiversx_sdk_cli/tests/testdata/validators_docker.json +++ b/multiversx_sdk_cli/tests/testdata/validators_docker.json @@ -1,13 +1,13 @@ { "validators": [ { - "pemFile": "~/mx-sdk-py-cli/validatorKey00.pem" + "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/validatorKey00.pem" }, { - "pemFile": "~/mx-sdk-py-cli/validatorKey01.pem" + "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/validatorKey01.pem" }, { - "pemFile": "~/mx-sdk-py-cli/validatorKey02.pem" + "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-clivalidatorKey02.pem" } ] } From d3f707dc4ff508f159d47181ea1f145b29538249 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 13:37:42 +0300 Subject: [PATCH 35/74] more debugging. --- .github/workflows/test-localnet-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index dfa69246..618c5f6a 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -52,7 +52,10 @@ jobs: docker cp localnet:/usr/src/app/localnet/validator02/config/validatorKey.pem ./validatorKey02.pem ls + echo "HOME DIR:" echo ~ + echo "CURR PATH:" + echo $(pwd) pytest -m require_localnet multiversx_sdk_cli/tests From adaf45a3f1b402343d445e04fe2cea41568f7002 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 13:41:11 +0300 Subject: [PATCH 36/74] fix more paths. --- multiversx_sdk_cli/tests/testdata/validators_docker.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multiversx_sdk_cli/tests/testdata/validators_docker.json b/multiversx_sdk_cli/tests/testdata/validators_docker.json index 2adb1109..51fe7684 100644 --- a/multiversx_sdk_cli/tests/testdata/validators_docker.json +++ b/multiversx_sdk_cli/tests/testdata/validators_docker.json @@ -7,7 +7,7 @@ "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/validatorKey01.pem" }, { - "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-clivalidatorKey02.pem" + "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/validatorKey02.pem" } ] } From 28fa95858729a40bd8b8c662a2c13d257346f774 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 13:46:13 +0300 Subject: [PATCH 37/74] add debug sleep. --- .github/workflows/test-localnet-tests.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 618c5f6a..2b407afd 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -50,12 +50,5 @@ jobs: docker cp localnet:/usr/src/app/localnet/validator00/config/validatorKey.pem ./validatorKey00.pem docker cp localnet:/usr/src/app/localnet/validator01/config/validatorKey.pem ./validatorKey01.pem docker cp localnet:/usr/src/app/localnet/validator02/config/validatorKey.pem ./validatorKey02.pem - - ls - echo "HOME DIR:" - echo ~ - echo "CURR PATH:" - echo $(pwd) - - + sleep 2m pytest -m require_localnet multiversx_sdk_cli/tests From 0e46464b98bb24d30c9c0cdcab2e4a9110913341 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 13:53:09 +0300 Subject: [PATCH 38/74] cosmetic changes. --- .github/workflows/test-localnet-tests.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 2b407afd..de79cbcb 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -13,9 +13,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: -# TODO: enable mac-os back once debugging is done. -# os: [ubuntu-latest, macos-latest] - os: [ubuntu-latest] + os: [ubuntu-latest, macos-latest] python-version: [3.11] steps: @@ -50,5 +48,6 @@ jobs: docker cp localnet:/usr/src/app/localnet/validator00/config/validatorKey.pem ./validatorKey00.pem docker cp localnet:/usr/src/app/localnet/validator01/config/validatorKey.pem ./validatorKey01.pem docker cp localnet:/usr/src/app/localnet/validator02/config/validatorKey.pem ./validatorKey02.pem +# TODO: introduce polling in test fixture sleep 2m pytest -m require_localnet multiversx_sdk_cli/tests From 7045c321b6688f4abf69b2b46eec12676a816d50 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 25 Oct 2024 13:54:48 +0300 Subject: [PATCH 39/74] fix yaml file. --- .github/workflows/test-localnet-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index de79cbcb..5cf98d84 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -43,11 +43,12 @@ jobs: docker run --name localnet -d -p 7950:7950 mxpy localnet start \ --configfile=/usr/src/app/multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml +# TODO: introduce polling in test fixture +# remove sleep - name: Test localnet dependent tests run: | docker cp localnet:/usr/src/app/localnet/validator00/config/validatorKey.pem ./validatorKey00.pem docker cp localnet:/usr/src/app/localnet/validator01/config/validatorKey.pem ./validatorKey01.pem docker cp localnet:/usr/src/app/localnet/validator02/config/validatorKey.pem ./validatorKey02.pem -# TODO: introduce polling in test fixture sleep 2m pytest -m require_localnet multiversx_sdk_cli/tests From 5f0f807a59811d142cb4b64a2d9183860b047a47 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 15:43:07 +0200 Subject: [PATCH 40/74] remove docker --- .github/workflows/test-localnet-tests.yml | 19 +++++---------- Dockerfile | 28 ----------------------- 2 files changed, 6 insertions(+), 41 deletions(-) delete mode 100644 Dockerfile diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 5cf98d84..baea51e9 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -34,21 +34,14 @@ jobs: pip3 install -r requirements.txt pip3 install -r ./requirements-dev.txt --upgrade - - name: Set up Docker image + - name: Set up MultiversX localnet run: | - docker build --build-arg PYTHON_VERSION=${{ matrix.python-version }} -t mxpy . + # Start the local testnet with mxpy + mkdir -p ~/localnet && cd ~/localnet + mxpy localnet setup --configfile=${GITHUB_WORKSPACE}/localnet.toml + nohup mxpy localnet start --configfile=${GITHUB_WORKSPACE}/localnet.toml > localnet.log 2>&1 & echo $! > localnet.pid + sleep 120 # Allow time for the testnet to fully start - - name: Deploy a localnet - run: | - docker run --name localnet -d -p 7950:7950 mxpy localnet start \ - --configfile=/usr/src/app/multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml - -# TODO: introduce polling in test fixture -# remove sleep - name: Test localnet dependent tests run: | - docker cp localnet:/usr/src/app/localnet/validator00/config/validatorKey.pem ./validatorKey00.pem - docker cp localnet:/usr/src/app/localnet/validator01/config/validatorKey.pem ./validatorKey01.pem - docker cp localnet:/usr/src/app/localnet/validator02/config/validatorKey.pem ./validatorKey02.pem - sleep 2m pytest -m require_localnet multiversx_sdk_cli/tests diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 9d6f84a4..00000000 --- a/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -ARG PYTHON_VERSION=3.10 - -# Step 1: Use an official Python runtime as a parent image -FROM python:${PYTHON_VERSION}-slim - -# Step 2: Set the working directory in the container -WORKDIR /usr/src/app - -# Step 3: Copy the requirements file into the container -COPY requirements.txt ./ - -# Step 5: Copy the requirements-dev file into the container -COPY requirements-dev.txt ./ - -# Step 6: Install any dependencies listed in requirements.txt -RUN pip install --no-cache-dir -r requirements.txt - -# Step 7: Install build-essential. Will be needed to compile the node binaries. -RUN apt update && apt install -y build-essential - -# Step 8: Copy the current directory contents into the container -COPY . . - -# Step 9: Setup the localnet configuration in the eventuality of a localnet start. -RUN python -m multiversx_sdk_cli.cli localnet setup --configfile=/usr/src/app/multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml - -# Step 10: Specify the entrypoint to run the application -ENTRYPOINT ["python", "-m", "multiversx_sdk_cli.cli"] \ No newline at end of file From 7a1c8cbc740505d737d2d5aa18fd1681b34ee4a1 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 15:47:42 +0200 Subject: [PATCH 41/74] fix mxpy commands in CI. --- .github/workflows/test-localnet-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index baea51e9..0f4a3b0a 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -38,8 +38,8 @@ jobs: run: | # Start the local testnet with mxpy mkdir -p ~/localnet && cd ~/localnet - mxpy localnet setup --configfile=${GITHUB_WORKSPACE}/localnet.toml - nohup mxpy localnet start --configfile=${GITHUB_WORKSPACE}/localnet.toml > localnet.log 2>&1 & echo $! > localnet.pid + python3 -m multiversx_sdk_cli.cli localnet setup --configfile=${GITHUB_WORKSPACE}/localnet.toml + nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=${GITHUB_WORKSPACE}/localnet.toml > localnet.log 2>&1 & echo $! > localnet.pid sleep 120 # Allow time for the testnet to fully start - name: Test localnet dependent tests From 6d2888e951773d210fae449ce99001b5961d875b Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 15:50:03 +0200 Subject: [PATCH 42/74] cosmetic changes. --- .github/workflows/test-localnet-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 0f4a3b0a..366a31b1 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -37,7 +37,6 @@ jobs: - name: Set up MultiversX localnet run: | # Start the local testnet with mxpy - mkdir -p ~/localnet && cd ~/localnet python3 -m multiversx_sdk_cli.cli localnet setup --configfile=${GITHUB_WORKSPACE}/localnet.toml nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=${GITHUB_WORKSPACE}/localnet.toml > localnet.log 2>&1 & echo $! > localnet.pid sleep 120 # Allow time for the testnet to fully start From 685ca9eeab29f797287c8b8fb30393a35986a3eb Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 15:57:05 +0200 Subject: [PATCH 43/74] debug strings --- .github/workflows/test-localnet-tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 366a31b1..31d52ff6 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -38,6 +38,10 @@ jobs: run: | # Start the local testnet with mxpy python3 -m multiversx_sdk_cli.cli localnet setup --configfile=${GITHUB_WORKSPACE}/localnet.toml + echo "LIST FILES" + ls + echo "PWD" + pwd nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=${GITHUB_WORKSPACE}/localnet.toml > localnet.log 2>&1 & echo $! > localnet.pid sleep 120 # Allow time for the testnet to fully start From 7bdab1ae338deeb74461b4589e4255adab147af9 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 16:00:35 +0200 Subject: [PATCH 44/74] more debug commands. --- .github/workflows/test-localnet-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 31d52ff6..1a3ee83c 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -42,6 +42,9 @@ jobs: ls echo "PWD" pwd + echo "HOME DIR" + cd ~ + pwd nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=${GITHUB_WORKSPACE}/localnet.toml > localnet.log 2>&1 & echo $! > localnet.pid sleep 120 # Allow time for the testnet to fully start From 343ba6b5000aa4f875d9057a3128a6318ce72346 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 16:07:14 +0200 Subject: [PATCH 45/74] fix CI tests and remove docker naming. --- multiversx_sdk_cli/tests/test_cli_validators.py | 2 +- .../tests/testdata/validators_ci.json | 13 +++++++++++++ .../tests/testdata/validators_docker.json | 13 ------------- 3 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 multiversx_sdk_cli/tests/testdata/validators_ci.json delete mode 100644 multiversx_sdk_cli/tests/testdata/validators_docker.json diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index eeccb028..233b1d0d 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -46,7 +46,7 @@ def poll_endpoint(): @pytest.mark.require_localnet def test_stake(poll_endpoint): - validators_json = testdata_path / "validators_docker.json" + validators_json = testdata_path / "validators_ci.json" # Stake with recall nonce return_code = main([ diff --git a/multiversx_sdk_cli/tests/testdata/validators_ci.json b/multiversx_sdk_cli/tests/testdata/validators_ci.json new file mode 100644 index 00000000..3067c23a --- /dev/null +++ b/multiversx_sdk_cli/tests/testdata/validators_ci.json @@ -0,0 +1,13 @@ +{ + "validators": [ + { + "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/localnet/validator00/validatorKey00.pem" + }, + { + "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/localnet/validator01/validatorKey01.pem" + }, + { + "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/localnet/validator02/validatorKey02.pem" + } + ] +} diff --git a/multiversx_sdk_cli/tests/testdata/validators_docker.json b/multiversx_sdk_cli/tests/testdata/validators_docker.json deleted file mode 100644 index 51fe7684..00000000 --- a/multiversx_sdk_cli/tests/testdata/validators_docker.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "validators": [ - { - "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/validatorKey00.pem" - }, - { - "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/validatorKey01.pem" - }, - { - "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/validatorKey02.pem" - } - ] -} From bf164f63f59d68ed4d29cc9dde0619a15f2423a9 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 16:20:42 +0200 Subject: [PATCH 46/74] remove polling. --- .../tests/test_cli_validators.py | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index 233b1d0d..db026fd2 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -44,35 +44,35 @@ def poll_endpoint(): time.sleep(interval) -@pytest.mark.require_localnet -def test_stake(poll_endpoint): - validators_json = testdata_path / "validators_ci.json" - - # Stake with recall nonce - return_code = main([ - "validator", "stake", - "--pem", str(alice_pem), - "--value", "2500000000000000000000", - "--validators-file", str(validators_json), - "--reward-address", reward_address, - "--chain", "localnet", - "--proxy", "http://127.0.0.1:7950", - "--estimate-gas", "--recall-nonce" - ]) - assert return_code == 0 - - # Stake with provided nonce - return_code = main([ - "validator", "stake", - "--pem", str(alice_pem), - "--value", "2500000000000000000000", - "--validators-file", str(validators_json), - "--reward-address", reward_address, - "--chain", "localnet", - "--proxy", "http://127.0.0.1:7950", - "--estimate-gas", "--nonce=0" - ]) - assert return_code == 0 +# @pytest.mark.require_localnet +# def test_stake(poll_endpoint): +# validators_json = testdata_path / "validators_ci.json" +# +# # Stake with recall nonce +# return_code = main([ +# "validator", "stake", +# "--pem", str(alice_pem), +# "--value", "2500000000000000000000", +# "--validators-file", str(validators_json), +# "--reward-address", reward_address, +# "--chain", "localnet", +# "--proxy", "http://127.0.0.1:7950", +# "--estimate-gas", "--recall-nonce" +# ]) +# assert return_code == 0 +# +# # Stake with provided nonce +# return_code = main([ +# "validator", "stake", +# "--pem", str(alice_pem), +# "--value", "2500000000000000000000", +# "--validators-file", str(validators_json), +# "--reward-address", reward_address, +# "--chain", "localnet", +# "--proxy", "http://127.0.0.1:7950", +# "--estimate-gas", "--nonce=0" +# ]) +# assert return_code == 0 @pytest.mark.require_localnet From e8137fa4a7cb92620935e4a7e2b8365fd542db4e Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 16:21:08 +0200 Subject: [PATCH 47/74] cosmetic changes. --- .../tests/test_cli_validators.py | 112 +++++++++--------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index db026fd2..fed75da6 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -15,64 +15,64 @@ bls_key = "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" -@pytest.fixture() -def poll_endpoint(): - start_time = time.time() # Record the start time - timeout = 600 - interval = 1 - - while True: - try: - # Make the request to the endpoint - response = requests.get(proxy_url, timeout=5) # Add request timeout to prevent blocking indefinitely - if response.status_code == 200: - # Break out of the loop if we get a successful response - return response.json() # Return the response (or .text, .content based on your needs) - else: - print(f"Received non-200 status code: {response.status_code}") - - except requests.RequestException as e: - # Handle network exceptions or timeouts - print(f"Request failed: {e}") - - # Check if the timeout is reached - if time.time() - start_time > timeout: - print("Polling timed out") - break - - # Wait for the specified interval before sending the next request - time.sleep(interval) - - -# @pytest.mark.require_localnet -# def test_stake(poll_endpoint): -# validators_json = testdata_path / "validators_ci.json" +# @pytest.fixture() +# def poll_endpoint(): +# start_time = time.time() # Record the start time +# timeout = 600 +# interval = 1 # -# # Stake with recall nonce -# return_code = main([ -# "validator", "stake", -# "--pem", str(alice_pem), -# "--value", "2500000000000000000000", -# "--validators-file", str(validators_json), -# "--reward-address", reward_address, -# "--chain", "localnet", -# "--proxy", "http://127.0.0.1:7950", -# "--estimate-gas", "--recall-nonce" -# ]) -# assert return_code == 0 +# while True: +# try: +# # Make the request to the endpoint +# response = requests.get(proxy_url, timeout=5) # Add request timeout to prevent blocking indefinitely +# if response.status_code == 200: +# # Break out of the loop if we get a successful response +# return response.json() # Return the response (or .text, .content based on your needs) +# else: +# print(f"Received non-200 status code: {response.status_code}") # -# # Stake with provided nonce -# return_code = main([ -# "validator", "stake", -# "--pem", str(alice_pem), -# "--value", "2500000000000000000000", -# "--validators-file", str(validators_json), -# "--reward-address", reward_address, -# "--chain", "localnet", -# "--proxy", "http://127.0.0.1:7950", -# "--estimate-gas", "--nonce=0" -# ]) -# assert return_code == 0 +# except requests.RequestException as e: +# # Handle network exceptions or timeouts +# print(f"Request failed: {e}") +# +# # Check if the timeout is reached +# if time.time() - start_time > timeout: +# print("Polling timed out") +# break +# +# # Wait for the specified interval before sending the next request +# time.sleep(interval) + + +@pytest.mark.require_localnet +def test_stake(poll_endpoint): + validators_json = testdata_path / "validators_ci.json" + + # Stake with recall nonce + return_code = main([ + "validator", "stake", + "--pem", str(alice_pem), + "--value", "2500000000000000000000", + "--validators-file", str(validators_json), + "--reward-address", reward_address, + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--recall-nonce" + ]) + assert return_code == 0 + + # Stake with provided nonce + return_code = main([ + "validator", "stake", + "--pem", str(alice_pem), + "--value", "2500000000000000000000", + "--validators-file", str(validators_json), + "--reward-address", reward_address, + "--chain", "localnet", + "--proxy", "http://127.0.0.1:7950", + "--estimate-gas", "--nonce=0" + ]) + assert return_code == 0 @pytest.mark.require_localnet From 3fb2a0e73ddc6523f6ef64eb5afc800ffd81fc19 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 16:22:24 +0200 Subject: [PATCH 48/74] fix unused fixture. --- multiversx_sdk_cli/tests/test_cli_validators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index fed75da6..e75e59bd 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -45,7 +45,7 @@ @pytest.mark.require_localnet -def test_stake(poll_endpoint): +def test_stake(): validators_json = testdata_path / "validators_ci.json" # Stake with recall nonce From af2c955028a6f377de1eda101ad08d92f23517c4 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 16:32:52 +0200 Subject: [PATCH 49/74] remove polling fixture. --- .../tests/test_cli_validators.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index e75e59bd..0891ef56 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -76,7 +76,7 @@ def test_stake(): @pytest.mark.require_localnet -def test_stake_top_up(poll_endpoint): +def test_stake_top_up(): # Stake with topUp return_code = main([ "validator", "stake", "--top-up", @@ -90,7 +90,7 @@ def test_stake_top_up(poll_endpoint): @pytest.mark.require_localnet -def test_unstake(poll_endpoint): +def test_unstake(): # Unstake return_code = main([ "validator", "unstake", @@ -104,7 +104,7 @@ def test_unstake(poll_endpoint): @pytest.mark.require_localnet -def test_unbond(poll_endpoint): +def test_unbond(): # Unbond return_code = main([ "validator", "unbond", @@ -118,7 +118,7 @@ def test_unbond(poll_endpoint): @pytest.mark.require_localnet -def test_unjail(poll_endpoint): +def test_unjail(): # Unjail return_code = main([ "validator", "unjail", @@ -133,7 +133,7 @@ def test_unjail(poll_endpoint): @pytest.mark.require_localnet -def test_change_reward_address(poll_endpoint): +def test_change_reward_address(): # Change reward address return_code = main([ "validator", "change-reward-address", @@ -147,7 +147,7 @@ def test_change_reward_address(poll_endpoint): @pytest.mark.require_localnet -def test_unstake_nodes(poll_endpoint): +def test_unstake_nodes(): # Unstake Nodes return_code = main([ "validator", "unstake-nodes", @@ -161,7 +161,7 @@ def test_unstake_nodes(poll_endpoint): @pytest.mark.require_localnet -def test_unstake_tokens(poll_endpoint): +def test_unstake_tokens(): # Unstake Tokens return_code = main([ "validator", "unstake-tokens", @@ -175,7 +175,7 @@ def test_unstake_tokens(poll_endpoint): @pytest.mark.require_localnet -def test_unbond_nodes(poll_endpoint): +def test_unbond_nodes(): # Unbond nodes return_code = main([ "validator", "unbond-nodes", @@ -189,7 +189,7 @@ def test_unbond_nodes(poll_endpoint): @pytest.mark.require_localnet -def test_unbond_tokens(poll_endpoint): +def test_unbond_tokens(): # Unbond nodes return_code = main([ "validator", "unbond-tokens", @@ -203,7 +203,7 @@ def test_unbond_tokens(poll_endpoint): @pytest.mark.require_localnet -def test_clean_registration_data(poll_endpoint): +def test_clean_registration_data(): # Clean registration data return_code = main([ "validator", "clean-registered-data", @@ -216,7 +216,7 @@ def test_clean_registration_data(poll_endpoint): @pytest.mark.require_localnet -def test_re_stake_unstaked_nodes(poll_endpoint): +def test_re_stake_unstaked_nodes(): # Clean registration data return_code = main([ "validator", "restake-unstaked-nodes", From c7d799f2e6e5a8a7ff35cd381a3784a7428f6c46 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 16:46:39 +0200 Subject: [PATCH 50/74] more debugging. --- .github/workflows/test-localnet-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 1a3ee83c..71c22526 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -46,6 +46,7 @@ jobs: cd ~ pwd nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=${GITHUB_WORKSPACE}/localnet.toml > localnet.log 2>&1 & echo $! > localnet.pid + cat ${GITHUB_WORKSPACE}/localnet.toml sleep 120 # Allow time for the testnet to fully start - name: Test localnet dependent tests From 5a274c47f62994601360ca52724c04a9937d7ac8 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 16:54:53 +0200 Subject: [PATCH 51/74] show log in CI. --- .github/workflows/test-localnet-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 71c22526..9bcd80b0 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -46,7 +46,7 @@ jobs: cd ~ pwd nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=${GITHUB_WORKSPACE}/localnet.toml > localnet.log 2>&1 & echo $! > localnet.pid - cat ${GITHUB_WORKSPACE}/localnet.toml + cat ${GITHUB_WORKSPACE}/localnet.log sleep 120 # Allow time for the testnet to fully start - name: Test localnet dependent tests From 42c12601feb678a93cb38a988f85497bb8d5a756 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 16:58:33 +0200 Subject: [PATCH 52/74] more debugging in CI. --- .github/workflows/test-localnet-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 9bcd80b0..718a9eba 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -46,7 +46,7 @@ jobs: cd ~ pwd nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=${GITHUB_WORKSPACE}/localnet.toml > localnet.log 2>&1 & echo $! > localnet.pid - cat ${GITHUB_WORKSPACE}/localnet.log + cat localnet.log sleep 120 # Allow time for the testnet to fully start - name: Test localnet dependent tests From 1ba5d85c3742d1cc97e29ff3adf94a96eb017c30 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 17:10:31 +0200 Subject: [PATCH 53/74] more debugging in CI. --- .github/workflows/test-localnet-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 718a9eba..3127a395 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -46,7 +46,7 @@ jobs: cd ~ pwd nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=${GITHUB_WORKSPACE}/localnet.toml > localnet.log 2>&1 & echo $! > localnet.pid - cat localnet.log + ls sleep 120 # Allow time for the testnet to fully start - name: Test localnet dependent tests From 25760e9945aebc6697fe99376b4e19ef814f26fd Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 17:14:00 +0200 Subject: [PATCH 54/74] check logs in CI. --- .github/workflows/test-localnet-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 3127a395..82d0b2f7 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -47,6 +47,7 @@ jobs: pwd nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=${GITHUB_WORKSPACE}/localnet.toml > localnet.log 2>&1 & echo $! > localnet.pid ls + cat localnet.log sleep 120 # Allow time for the testnet to fully start - name: Test localnet dependent tests From fe180f00a22466d0d45b6b8275f992bc483de71c Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 17:18:17 +0200 Subject: [PATCH 55/74] rewrite setting up commands. --- .github/workflows/test-localnet-tests.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 82d0b2f7..3d376f42 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -36,19 +36,10 @@ jobs: - name: Set up MultiversX localnet run: | - # Start the local testnet with mxpy - python3 -m multiversx_sdk_cli.cli localnet setup --configfile=${GITHUB_WORKSPACE}/localnet.toml - echo "LIST FILES" - ls - echo "PWD" - pwd - echo "HOME DIR" - cd ~ - pwd - nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=${GITHUB_WORKSPACE}/localnet.toml > localnet.log 2>&1 & echo $! > localnet.pid - ls - cat localnet.log - sleep 120 # Allow time for the testnet to fully start + python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml + python3 -m multiversx_sdk_cli.cli localnet config --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml + nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml + sleep 120 - name: Test localnet dependent tests run: | From 61bf2919055830ab6673db1f3f237dc86aee95aa Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 17:26:18 +0200 Subject: [PATCH 56/74] debug. --- .github/workflows/test-localnet-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 3d376f42..6beac073 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -36,7 +36,6 @@ jobs: - name: Set up MultiversX localnet run: | - python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml python3 -m multiversx_sdk_cli.cli localnet config --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml sleep 120 From 4ce863e00e68baa5f9c8b91fd543573617697d36 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 17:33:18 +0200 Subject: [PATCH 57/74] more commands. --- .github/workflows/test-localnet-tests.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 6beac073..3b3b7925 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -36,6 +36,15 @@ jobs: - name: Set up MultiversX localnet run: | + mkdir -p ~/multiversx-sdk + export PYTHONPATH=. + python3 -m multiversx_sdk_cli.cli localnet prerequisites --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml + python3 -m multiversx_sdk_cli.cli localnet build --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml + + # "Go" and artifacts from "GOPATH/pkg/mod" are not needed anymore. + sudo rm -rf ~/multiversx-sdk/golang + + python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml python3 -m multiversx_sdk_cli.cli localnet config --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml sleep 120 From 380c08b9ee18aa8f2adc52b24eee80a8426c4bc3 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 17:39:07 +0200 Subject: [PATCH 58/74] make nohup run in background. --- .github/workflows/test-localnet-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 3b3b7925..630ef7cb 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -46,7 +46,7 @@ jobs: python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml python3 -m multiversx_sdk_cli.cli localnet config --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml - nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml + nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml > localnet.log 2>&1 & echo $! > localnet.pid sleep 120 - name: Test localnet dependent tests From 58e29a0386cd4916c03f300d63f398d0366303ce Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 17:49:11 +0200 Subject: [PATCH 59/74] debug localnet config. --- .github/workflows/test-localnet-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 630ef7cb..f05bf9c2 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -47,6 +47,7 @@ jobs: python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml python3 -m multiversx_sdk_cli.cli localnet config --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml > localnet.log 2>&1 & echo $! > localnet.pid + ls sleep 120 - name: Test localnet dependent tests From 31b65631bec57dcbc6ec3ae97c19bea84f874afe Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 17:53:51 +0200 Subject: [PATCH 60/74] more debugging paths. --- .github/workflows/test-localnet-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index f05bf9c2..dec981f5 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -47,6 +47,7 @@ jobs: python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml python3 -m multiversx_sdk_cli.cli localnet config --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml > localnet.log 2>&1 & echo $! > localnet.pid + cd localnet ls sleep 120 From 92e6386de09c43b38dc2884bdf51ef70100b87cb Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 18:01:42 +0200 Subject: [PATCH 61/74] fix paths for ci validator keys file. --- .github/workflows/test-localnet-tests.yml | 2 ++ multiversx_sdk_cli/tests/testdata/validators_ci.json | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index dec981f5..b3a8ba37 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -48,7 +48,9 @@ jobs: python3 -m multiversx_sdk_cli.cli localnet config --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml > localnet.log 2>&1 & echo $! > localnet.pid cd localnet + cd validator00 ls + pwd sleep 120 - name: Test localnet dependent tests diff --git a/multiversx_sdk_cli/tests/testdata/validators_ci.json b/multiversx_sdk_cli/tests/testdata/validators_ci.json index 3067c23a..99a390c6 100644 --- a/multiversx_sdk_cli/tests/testdata/validators_ci.json +++ b/multiversx_sdk_cli/tests/testdata/validators_ci.json @@ -1,13 +1,13 @@ { "validators": [ { - "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/localnet/validator00/validatorKey00.pem" + "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/localnet/validator00/config/validatorKey.pem" }, { - "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/localnet/validator01/validatorKey01.pem" + "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/localnet/validator01/config/validatorKey.pem" }, { - "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/localnet/validator02/validatorKey02.pem" + "pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/localnet/validator02/config/validatorKey.pem" } ] } From e8c89e1729c163b0ef57704ea2806a3607725aae Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 18:10:52 +0200 Subject: [PATCH 62/74] clean remaining commented code. --- .github/workflows/test-localnet-tests.yml | 4 --- .../tests/test_cli_validators.py | 29 ------------------- 2 files changed, 33 deletions(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index b3a8ba37..630ef7cb 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -47,10 +47,6 @@ jobs: python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml python3 -m multiversx_sdk_cli.cli localnet config --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml > localnet.log 2>&1 & echo $! > localnet.pid - cd localnet - cd validator00 - ls - pwd sleep 120 - name: Test localnet dependent tests diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index 0891ef56..3f5d6402 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -15,35 +15,6 @@ bls_key = "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" -# @pytest.fixture() -# def poll_endpoint(): -# start_time = time.time() # Record the start time -# timeout = 600 -# interval = 1 -# -# while True: -# try: -# # Make the request to the endpoint -# response = requests.get(proxy_url, timeout=5) # Add request timeout to prevent blocking indefinitely -# if response.status_code == 200: -# # Break out of the loop if we get a successful response -# return response.json() # Return the response (or .text, .content based on your needs) -# else: -# print(f"Received non-200 status code: {response.status_code}") -# -# except requests.RequestException as e: -# # Handle network exceptions or timeouts -# print(f"Request failed: {e}") -# -# # Check if the timeout is reached -# if time.time() - start_time > timeout: -# print("Polling timed out") -# break -# -# # Wait for the specified interval before sending the next request -# time.sleep(interval) - - @pytest.mark.require_localnet def test_stake(): validators_json = testdata_path / "validators_ci.json" From 0080690f8698b83c6b2fb0eb6fab9e1a0b498120 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 23:54:29 +0200 Subject: [PATCH 63/74] added conftest and strict markers. --- .github/workflows/test-localnet-tests.yml | 1 + multiversx_sdk_cli/tests/conftest.py | 12 ++++++++++++ multiversx_sdk_cli/tests/test_cli_validators.py | 2 -- pytest.ini | 4 ++-- 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 multiversx_sdk_cli/tests/conftest.py diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 630ef7cb..e4b66985 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -52,3 +52,4 @@ jobs: - name: Test localnet dependent tests run: | pytest -m require_localnet multiversx_sdk_cli/tests + diff --git a/multiversx_sdk_cli/tests/conftest.py b/multiversx_sdk_cli/tests/conftest.py new file mode 100644 index 00000000..601ea625 --- /dev/null +++ b/multiversx_sdk_cli/tests/conftest.py @@ -0,0 +1,12 @@ +import pytest + + +# function executed right after test items collected but before test run +def pytest_collection_modifyitems(config, items): + if not config.getoption('-m'): + skip_me = pytest.mark.skip(reason="to run marked tests, you need to explicitly run them wiht -m") + for item in items: + if "require_localnet" in item.keywords: + item.add_marker(skip_me) + if "skip_on_winodws" in item.keywords: + item.add_marker(skip_me) diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index 3f5d6402..8b7cc521 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -1,5 +1,3 @@ -import requests -import time import pytest from pathlib import Path diff --git a/pytest.ini b/pytest.ini index cab31729..4cee0be1 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,7 +1,7 @@ [pytest] markers = - skip_on_windows: marks tests as being skiped when running on windows (deselect with '-m "skip_on_windows"') + skip_on_windows: marks tests as being skipped when running on windows (deselect with '-m "skip_on_windows"') only: only run a specific test (run using: pytest -m "only") - require_localnet: marks tests that require a localnet (run using: pytest -m require_localnet) + require_localnet: marks tests that require a localnet (select with '-m "require_localnet"') log_cli = True From 69404f006d0687bbd0971b0a39a653524ddb600a Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Tue, 5 Nov 2024 10:14:37 +0200 Subject: [PATCH 64/74] modified skip on windows marker. --- .github/workflows/build-windows.yml | 2 +- multiversx_sdk_cli/tests/conftest.py | 4 ++-- multiversx_sdk_cli/tests/test_cli_deps.py | 4 ++-- pytest.ini | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index e7010de2..ae33b14e 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -47,7 +47,7 @@ jobs: shell: bash run: | export PYTHONPATH=. - pytest -m "not skip_on_windows" . + pytest -m "run_on_windows" . - name: Run CLI tests shell: bash run: | diff --git a/multiversx_sdk_cli/tests/conftest.py b/multiversx_sdk_cli/tests/conftest.py index 601ea625..2939fe5e 100644 --- a/multiversx_sdk_cli/tests/conftest.py +++ b/multiversx_sdk_cli/tests/conftest.py @@ -4,9 +4,9 @@ # function executed right after test items collected but before test run def pytest_collection_modifyitems(config, items): if not config.getoption('-m'): - skip_me = pytest.mark.skip(reason="to run marked tests, you need to explicitly run them wiht -m") + skip_me = pytest.mark.skip(reason="to run marked tests, you need to explicitly run them with -m") for item in items: if "require_localnet" in item.keywords: item.add_marker(skip_me) - if "skip_on_winodws" in item.keywords: + if "run_on_windows" in item.keywords: item.add_marker(skip_me) diff --git a/multiversx_sdk_cli/tests/test_cli_deps.py b/multiversx_sdk_cli/tests/test_cli_deps.py index 63162d71..1d57bbf5 100644 --- a/multiversx_sdk_cli/tests/test_cli_deps.py +++ b/multiversx_sdk_cli/tests/test_cli_deps.py @@ -41,13 +41,13 @@ def test_deps_check_testwallets(): assert return_code == 0 -@pytest.mark.skip_on_windows +@pytest.mark.run_on_windows def test_deps_install_all(): return_code = main(["deps", "install", "all"]) assert return_code == 0 -@pytest.mark.skip_on_windows +@pytest.mark.run_on_windows def test_deps_check_all(): return_code = main(["deps", "check", "all"]) assert return_code == 0 diff --git a/pytest.ini b/pytest.ini index 4cee0be1..f1722316 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,6 +1,6 @@ [pytest] markers = - skip_on_windows: marks tests as being skipped when running on windows (deselect with '-m "skip_on_windows"') + run_on_windows: marks tests as being skipped when running on windows (select with '-m "run_on_windows"') only: only run a specific test (run using: pytest -m "only") require_localnet: marks tests that require a localnet (select with '-m "require_localnet"') From c2adbf221fe38bc9624ead44615a57d79eec9baf Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Tue, 5 Nov 2024 11:26:10 +0200 Subject: [PATCH 65/74] fix skip_on_windows marker --- .github/workflows/build-windows.yml | 2 +- .github/workflows/test-localnet-tests.yml | 2 +- multiversx_sdk_cli/tests/conftest.py | 4 +--- multiversx_sdk_cli/tests/test_cli_deps.py | 4 ++-- pytest.ini | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index ae33b14e..e7010de2 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -47,7 +47,7 @@ jobs: shell: bash run: | export PYTHONPATH=. - pytest -m "run_on_windows" . + pytest -m "not skip_on_windows" . - name: Run CLI tests shell: bash run: | diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index e4b66985..c79969c9 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -51,5 +51,5 @@ jobs: - name: Test localnet dependent tests run: | - pytest -m require_localnet multiversx_sdk_cli/tests + pytest -m require_localnet . diff --git a/multiversx_sdk_cli/tests/conftest.py b/multiversx_sdk_cli/tests/conftest.py index 2939fe5e..abff81f5 100644 --- a/multiversx_sdk_cli/tests/conftest.py +++ b/multiversx_sdk_cli/tests/conftest.py @@ -4,9 +4,7 @@ # function executed right after test items collected but before test run def pytest_collection_modifyitems(config, items): if not config.getoption('-m'): - skip_me = pytest.mark.skip(reason="to run marked tests, you need to explicitly run them with -m") + skip_me = pytest.mark.skip(reason="require_localnet will only run if explicitly set to with -m") for item in items: if "require_localnet" in item.keywords: item.add_marker(skip_me) - if "run_on_windows" in item.keywords: - item.add_marker(skip_me) diff --git a/multiversx_sdk_cli/tests/test_cli_deps.py b/multiversx_sdk_cli/tests/test_cli_deps.py index 1d57bbf5..63162d71 100644 --- a/multiversx_sdk_cli/tests/test_cli_deps.py +++ b/multiversx_sdk_cli/tests/test_cli_deps.py @@ -41,13 +41,13 @@ def test_deps_check_testwallets(): assert return_code == 0 -@pytest.mark.run_on_windows +@pytest.mark.skip_on_windows def test_deps_install_all(): return_code = main(["deps", "install", "all"]) assert return_code == 0 -@pytest.mark.run_on_windows +@pytest.mark.skip_on_windows def test_deps_check_all(): return_code = main(["deps", "check", "all"]) assert return_code == 0 diff --git a/pytest.ini b/pytest.ini index f1722316..4cee0be1 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,6 +1,6 @@ [pytest] markers = - run_on_windows: marks tests as being skipped when running on windows (select with '-m "run_on_windows"') + skip_on_windows: marks tests as being skipped when running on windows (deselect with '-m "skip_on_windows"') only: only run a specific test (run using: pytest -m "only") require_localnet: marks tests that require a localnet (select with '-m "require_localnet"') From 1b1a414fcffa08f1a1e5cc45c4c5b269396f6539 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Tue, 5 Nov 2024 11:59:00 +0200 Subject: [PATCH 66/74] fix windows build --- .github/workflows/build-windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index e7010de2..b6f87291 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -47,7 +47,7 @@ jobs: shell: bash run: | export PYTHONPATH=. - pytest -m "not skip_on_windows" . + pytest -m "not skip_on_windows and not require_localnet" . - name: Run CLI tests shell: bash run: | From 40674117db339547eea73f11794d578bea5ffb49 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Tue, 5 Nov 2024 14:15:09 +0200 Subject: [PATCH 67/74] remove duplicated bash tests and added teardown for localnet tests. --- .github/workflows/test-localnet-tests.yml | 2 + .../tests/test_cli_contracts.sh | 119 ------------------ multiversx_sdk_cli/tests/test_cli_dns.sh | 113 ----------------- .../tests/test_cli_validators.sh | 44 ------- 4 files changed, 2 insertions(+), 276 deletions(-) delete mode 100755 multiversx_sdk_cli/tests/test_cli_contracts.sh delete mode 100644 multiversx_sdk_cli/tests/test_cli_dns.sh delete mode 100755 multiversx_sdk_cli/tests/test_cli_validators.sh diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index c79969c9..9ff0eee2 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -52,4 +52,6 @@ jobs: - name: Test localnet dependent tests run: | pytest -m require_localnet . + python3 -m multiversx_sdk_cli.cli localnet stop --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml + diff --git a/multiversx_sdk_cli/tests/test_cli_contracts.sh b/multiversx_sdk_cli/tests/test_cli_contracts.sh deleted file mode 100755 index bf7f9fa6..00000000 --- a/multiversx_sdk_cli/tests/test_cli_contracts.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env bash - -source "./shared.sh" - -testTrivialCommands() { - echo "testTrivialCommands" - ${CLI} contract templates -} - -testCreateContracts() { - echo "testCreateContracts" - ${CLI} contract new --template adder --path ${SANDBOX} || return 1 - ${CLI} contract new --template crypto-zombies --path ${SANDBOX} || return 1 - ${CLI} contract new --template empty --path ${SANDBOX} || return 1 -} - -testBuildContracts() { - echo "testBuildContracts" - - # Improve compilation time by reusing build artifacts for Rust projects - export TARGET_DIR=$(pwd)/${SANDBOX}/TARGET - mkdir -p ${TARGET_DIR} - - ${CLI} contract build --path=${SANDBOX}/adder --target-dir=${TARGET_DIR} || return 1 - assertFileExists ${SANDBOX}/adder/output/adder.wasm || return 1 - assertFileExists ${SANDBOX}/adder/output/adder.abi.json || return 1 - - ${CLI} contract build --path=${SANDBOX}/crypto-zombies --target-dir=${TARGET_DIR} || return 1 - assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.wasm || return 1 - assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.abi.json || return 1 - - ${CLI} contract build --path=${SANDBOX}/empty --target-dir=${TARGET_DIR} || return 1 - assertFileExists ${SANDBOX}/empty/output/empty.wasm || return 1 - assertFileExists ${SANDBOX}/empty/output/empty.abi.json || return 1 -} - -testRunScenarios() { - echo "testRunScenarios" - ${CLI} --verbose contract test --path=${SANDBOX}/adder || return 1 - ${CLI} --verbose contract test --path=${SANDBOX}/empty || return 1 -} - -testWasmName() { - echo "testWasmName" - - ${CLI} contract clean --path ${SANDBOX}/adder - assertFileDoesNotExist ${SANDBOX}/adder/output/adder-2.wasm || return 1 - ${CLI} contract build --path=${SANDBOX}/adder --target-dir=${TARGET_DIR} --wasm-name adder-2 || return 1 - assertFileExists ${SANDBOX}/adder/output/adder-2.wasm || return 1 - assertFileExists ${SANDBOX}/adder/output/adder.abi.json || return 1 -} - -testCleanContracts() { - echo "testCleanContracts" - - assertFileExists ${SANDBOX}/adder/output/adder.wasm || return 1 - assertFileExists ${SANDBOX}/adder/output/adder.abi.json || return 1 - ${CLI} contract clean --path ${SANDBOX}/adder || return 1 - assertFileDoesNotExist ${SANDBOX}/adder/output/adder.wasm || return 1 - assertFileDoesNotExist ${SANDBOX}/adder/output/adder.abi.json || return 1 - - assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.wasm || return 1 - assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.abi.json || return 1 - ${CLI} contract clean --path ${SANDBOX}/crypto-zombies || return 1 - assertFileDoesNotExist ${SANDBOX}/crypto-zombies/output/crypto-zombies.wasm || return 1 - assertFileDoesNotExist ${SANDBOX}/crypto-zombies/output/crypto-zombies.abi.json || return 1 - - assertFileExists ${SANDBOX}/empty/output/empty.wasm || return 1 - assertFileExists ${SANDBOX}/empty/output/empty.abi.json || return 1 - ${CLI} contract clean --path ${SANDBOX}/empty || return 1 - assertFileDoesNotExist ${SANDBOX}/empty/output/empty.wasm || return 1 - assertFileDoesNotExist ${SANDBOX}/empty/output/empty.abi.json || return 1 -} - -testVerifyContract(){ - echo "testVerifyContract" - - nohup python3 local_verify_server.py >/dev/null 2>&1 & - sleep 1 - - query_response=$(curl -s localhost:7777/verify -X POST) - - command_response=$(${CLI} contract verify erd1qqqqqqqqqqqqqpgquzmh78klkqwt0p4rjys0qtp3la07gz4d396qn50nnm \ - --verifier-url=http://localhost:7777 --packaged-src=testdata/dummy.json \ - --pem=testdata/walletKey.pem --docker-image=multiversx/sdk-rust-contract-builder:v4.0.0) - - result_curl=$(echo $query_response | awk -F ": " '{ print $2 }' | awk -F'"' '{print $2}') - result_cli=$(echo $command_response | awk -F ": " '{ print $2 }' | awk -F'"' '{print $2}') - - if [[ $result_curl == $result_cli ]]; - then - echo "Test passed!" - else - return 1 - fi - - pkill -f local_verify_server.py -} - -testReproducibleBuild() { - echo "testReproducibleBuild" - - wget -O ${SANDBOX}/example.zip https://github.com/multiversx/mx-reproducible-contract-build-example-sc/archive/refs/tags/v0.2.1.zip || return 1 - unzip ${SANDBOX}/example.zip -d ${SANDBOX} || return 1 - ${CLI} contract reproducible-build ${SANDBOX}/mx-reproducible-contract-build-example-sc-0.2.1 --docker-image=multiversx/sdk-rust-contract-builder:v4.1.2 --no-docker-interactive --no-docker-tty || return 1 - assertFileExists ${SANDBOX}/mx-reproducible-contract-build-example-sc-0.2.1/output-docker/artifacts.json || return 1 -} - -testAll() { - ${CLI} config set dependencies.rust.tag ${RUST_VERSION} - - cleanSandbox || return 1 - testTrivialCommands || return 1 - testCreateContracts || return 1 - testBuildContracts || return 1 - testRunScenarios || return 1 - testCleanContracts || return 1 - testWasmName || return 1 -} diff --git a/multiversx_sdk_cli/tests/test_cli_dns.sh b/multiversx_sdk_cli/tests/test_cli_dns.sh deleted file mode 100644 index fa3c9340..00000000 --- a/multiversx_sdk_cli/tests/test_cli_dns.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env bash - -source "./shared.sh" - -REGISTRATION_COST=100 - -testOnline() { - testRegistrationOnline || return 1 - # Wait for nonces to be incremented (at source shards) - sleep 15 - testTransactionsWithUsernamesOnline || return 1 -} - -testRegistrationOnline() { - ${CLI} --verbose dns register --name="testuser" --pem=${TestUser} --value=${REGISTRATION_COST} \ - --recall-nonce --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txRegisterUser.txt --send --proxy=${PROXY} || return 1 - - ${CLI} --verbose dns register --name="testuser2" --pem=${TestUser2} --value=${REGISTRATION_COST} \ - --recall-nonce --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txRegisterUser2.txt --send --proxy=${PROXY} || return 1 -} - -testTransactionsWithUsernamesOnline() { - ${CLI} --verbose tx new --pem=${TestUser} --receiver=${TestUser2} \ - --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txA.txt --send --proxy=${PROXY} || return 1 - - sleep 10 - - ${CLI} --verbose tx new --pem=${TestUser} --receiver=${TestUser2} --receiver-username="testuser2" \ - --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txB.txt --send --proxy=${PROXY} || return 1 - - sleep 10 - - ${CLI} --verbose tx new --pem=${TestUser} --receiver=${TestUser2} --receiver-username="testuser2foo" \ - --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txC.txt --send --proxy=${PROXY} || return 1 - - sleep 10 - - ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver=${TestUser2} --receiver-username="testuser2" \ - --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txD.txt --send --proxy=${PROXY} || return 1 - - sleep 10 - - ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver=${TestUser2} \ - --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txF.txt --send --proxy=${PROXY} || return 1 - - sleep 10 - - ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuserfoo" --receiver=${TestUser2} \ - --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txG.txt --send --proxy=${PROXY} || return 1 -} - - -testOffline() { - testRegistrationOffline || return 1 - testTransactionsWithUsernamesOffline || return 1 -} - -testRegistrationOffline() { - ${CLI} --verbose dns register --name="testuser" --pem=${TestUser} --value=${REGISTRATION_COST} \ - --nonce=7 --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txRegisterUser.txt || return 1 - assertFileExists ${SANDBOX}/txRegisterUser.txt || return 1 - - ${CLI} --verbose dns register --name="testuser2" --pem=${TestUser2} --value=${REGISTRATION_COST} \ - --nonce=8 --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txRegisterUser2.txt || return 1 - assertFileExists ${SANDBOX}/txRegisterUser2.txt || return 1 -} - -testTransactionsWithUsernamesOffline() { - ${CLI} --verbose tx new --pem=${TestUser} --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" \ - --value="1${DENOMINATION}" --nonce=42 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txA.txt || return 1 - assertFileExists ${SANDBOX}/txA.txt || return 1 - - ${CLI} --verbose tx new --pem=${TestUser} --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" --receiver-username="testuser2" \ - --value="1${DENOMINATION}" --nonce=43 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txB.txt || return 1 - assertFileExists ${SANDBOX}/txB.txt || return 1 - - ${CLI} --verbose tx new --pem=${TestUser} --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" --receiver-username="testuser2foo" \ - --value="1${DENOMINATION}" --nonce=44 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txC.txt || return 1 - assertFileExists ${SANDBOX}/txC.txt || return 1 - - ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" --receiver-username="testuser2" \ - --value="1${DENOMINATION}" --nonce=45 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txD.txt || return 1 - assertFileExists ${SANDBOX}/txD.txt || return 1 - - ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" \ - --value="1${DENOMINATION}" --nonce=46 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txF.txt || return 1 - assertFileExists ${SANDBOX}/txF.txt || return 1 - - ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuserfoo" --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" \ - --value="1${DENOMINATION}" --nonce=47 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txG.txt || return 1 - assertFileExists ${SANDBOX}/txG.txt || return 1 -} - -testAll() { - testOnline || return 1 - testOffline || return 1 -} diff --git a/multiversx_sdk_cli/tests/test_cli_validators.sh b/multiversx_sdk_cli/tests/test_cli_validators.sh deleted file mode 100755 index d489c9c0..00000000 --- a/multiversx_sdk_cli/tests/test_cli_validators.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -source "./shared.sh" - -testAll() { - BLS_KEY="e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" - REWARD_ADDRESS="erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8" - - echo "Stake with recall nonce" - ${CLI} --verbose validator stake --pem="${USERS}/alice.pem" --value="2500${DENOMINATION}" --validators-file=./testdata/validators.json --reward-address=${REWARD_ADDRESS} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - echo "Stake with provided nonce" - ${CLI} --verbose validator stake --pem="${USERS}/bob.pem" --value="2500${DENOMINATION}" --validators-file=./testdata/validators.json --reward-address=${REWARD_ADDRESS} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --nonce=300 || return 1 - - - echo "Stake with topUP" - ${CLI} --verbose validator stake --top-up --pem="${USERS}/carol.pem" --value="2711${DENOMINATION}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - - echo "Unstake" - ${CLI} --verbose validator unstake --pem="${USERS}/dan.pem" --nodes-public-keys="${BLS_KEY}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - echo "Unbond" - ${CLI} --verbose validator unbond --pem="${USERS}/eve.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - echo "Unjail" - ${CLI} --verbose validator unjail --pem="${USERS}/frank.pem" --value="2500${DENOMINATION}" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - echo "Change reward address" - ${CLI} --verbose validator change-reward-address --pem="${USERS}/grace.pem" --reward-address=${REWARD_ADDRESS} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - - echo "UnstakeNodes" - ${CLI} --verbose validator unstake-nodes --pem="${USERS}/heidi.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - - echo "UnstakeTokens" - ${CLI} --verbose validator unstake-tokens --pem="${USERS}/ivan.pem" --unstake-value="11${DENOMINATION}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - - echo "UnbondNodes" - ${CLI} --verbose validator unbond-nodes --pem="${USERS}/judy.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - - echo "UnbondTokens" - ${CLI} --verbose validator unbond-tokens --pem="${USERS}/mallory.pem" --unbond-value="20${DENOMINATION}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - - echo "CleanRegistrationData" - ${CLI} --verbose validator clean-registered-data --pem="${USERS}/mike.pem" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - - echo "ReStakeUnstakedNodes" - ${CLI} --verbose validator restake-unstaked-nodes --pem="${USERS}/alice.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 -} From 572725d84e36e13f2af7795456c8277c341dfe41 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Tue, 5 Nov 2024 16:35:32 +0200 Subject: [PATCH 68/74] Revert "remove duplicated bash tests and added teardown for localnet tests." This reverts commit 40674117db339547eea73f11794d578bea5ffb49. --- .github/workflows/test-localnet-tests.yml | 2 - .../tests/test_cli_contracts.sh | 119 ++++++++++++++++++ multiversx_sdk_cli/tests/test_cli_dns.sh | 113 +++++++++++++++++ .../tests/test_cli_validators.sh | 44 +++++++ 4 files changed, 276 insertions(+), 2 deletions(-) create mode 100755 multiversx_sdk_cli/tests/test_cli_contracts.sh create mode 100644 multiversx_sdk_cli/tests/test_cli_dns.sh create mode 100755 multiversx_sdk_cli/tests/test_cli_validators.sh diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 9ff0eee2..c79969c9 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -52,6 +52,4 @@ jobs: - name: Test localnet dependent tests run: | pytest -m require_localnet . - python3 -m multiversx_sdk_cli.cli localnet stop --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml - diff --git a/multiversx_sdk_cli/tests/test_cli_contracts.sh b/multiversx_sdk_cli/tests/test_cli_contracts.sh new file mode 100755 index 00000000..bf7f9fa6 --- /dev/null +++ b/multiversx_sdk_cli/tests/test_cli_contracts.sh @@ -0,0 +1,119 @@ +#!/usr/bin/env bash + +source "./shared.sh" + +testTrivialCommands() { + echo "testTrivialCommands" + ${CLI} contract templates +} + +testCreateContracts() { + echo "testCreateContracts" + ${CLI} contract new --template adder --path ${SANDBOX} || return 1 + ${CLI} contract new --template crypto-zombies --path ${SANDBOX} || return 1 + ${CLI} contract new --template empty --path ${SANDBOX} || return 1 +} + +testBuildContracts() { + echo "testBuildContracts" + + # Improve compilation time by reusing build artifacts for Rust projects + export TARGET_DIR=$(pwd)/${SANDBOX}/TARGET + mkdir -p ${TARGET_DIR} + + ${CLI} contract build --path=${SANDBOX}/adder --target-dir=${TARGET_DIR} || return 1 + assertFileExists ${SANDBOX}/adder/output/adder.wasm || return 1 + assertFileExists ${SANDBOX}/adder/output/adder.abi.json || return 1 + + ${CLI} contract build --path=${SANDBOX}/crypto-zombies --target-dir=${TARGET_DIR} || return 1 + assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.wasm || return 1 + assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.abi.json || return 1 + + ${CLI} contract build --path=${SANDBOX}/empty --target-dir=${TARGET_DIR} || return 1 + assertFileExists ${SANDBOX}/empty/output/empty.wasm || return 1 + assertFileExists ${SANDBOX}/empty/output/empty.abi.json || return 1 +} + +testRunScenarios() { + echo "testRunScenarios" + ${CLI} --verbose contract test --path=${SANDBOX}/adder || return 1 + ${CLI} --verbose contract test --path=${SANDBOX}/empty || return 1 +} + +testWasmName() { + echo "testWasmName" + + ${CLI} contract clean --path ${SANDBOX}/adder + assertFileDoesNotExist ${SANDBOX}/adder/output/adder-2.wasm || return 1 + ${CLI} contract build --path=${SANDBOX}/adder --target-dir=${TARGET_DIR} --wasm-name adder-2 || return 1 + assertFileExists ${SANDBOX}/adder/output/adder-2.wasm || return 1 + assertFileExists ${SANDBOX}/adder/output/adder.abi.json || return 1 +} + +testCleanContracts() { + echo "testCleanContracts" + + assertFileExists ${SANDBOX}/adder/output/adder.wasm || return 1 + assertFileExists ${SANDBOX}/adder/output/adder.abi.json || return 1 + ${CLI} contract clean --path ${SANDBOX}/adder || return 1 + assertFileDoesNotExist ${SANDBOX}/adder/output/adder.wasm || return 1 + assertFileDoesNotExist ${SANDBOX}/adder/output/adder.abi.json || return 1 + + assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.wasm || return 1 + assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.abi.json || return 1 + ${CLI} contract clean --path ${SANDBOX}/crypto-zombies || return 1 + assertFileDoesNotExist ${SANDBOX}/crypto-zombies/output/crypto-zombies.wasm || return 1 + assertFileDoesNotExist ${SANDBOX}/crypto-zombies/output/crypto-zombies.abi.json || return 1 + + assertFileExists ${SANDBOX}/empty/output/empty.wasm || return 1 + assertFileExists ${SANDBOX}/empty/output/empty.abi.json || return 1 + ${CLI} contract clean --path ${SANDBOX}/empty || return 1 + assertFileDoesNotExist ${SANDBOX}/empty/output/empty.wasm || return 1 + assertFileDoesNotExist ${SANDBOX}/empty/output/empty.abi.json || return 1 +} + +testVerifyContract(){ + echo "testVerifyContract" + + nohup python3 local_verify_server.py >/dev/null 2>&1 & + sleep 1 + + query_response=$(curl -s localhost:7777/verify -X POST) + + command_response=$(${CLI} contract verify erd1qqqqqqqqqqqqqpgquzmh78klkqwt0p4rjys0qtp3la07gz4d396qn50nnm \ + --verifier-url=http://localhost:7777 --packaged-src=testdata/dummy.json \ + --pem=testdata/walletKey.pem --docker-image=multiversx/sdk-rust-contract-builder:v4.0.0) + + result_curl=$(echo $query_response | awk -F ": " '{ print $2 }' | awk -F'"' '{print $2}') + result_cli=$(echo $command_response | awk -F ": " '{ print $2 }' | awk -F'"' '{print $2}') + + if [[ $result_curl == $result_cli ]]; + then + echo "Test passed!" + else + return 1 + fi + + pkill -f local_verify_server.py +} + +testReproducibleBuild() { + echo "testReproducibleBuild" + + wget -O ${SANDBOX}/example.zip https://github.com/multiversx/mx-reproducible-contract-build-example-sc/archive/refs/tags/v0.2.1.zip || return 1 + unzip ${SANDBOX}/example.zip -d ${SANDBOX} || return 1 + ${CLI} contract reproducible-build ${SANDBOX}/mx-reproducible-contract-build-example-sc-0.2.1 --docker-image=multiversx/sdk-rust-contract-builder:v4.1.2 --no-docker-interactive --no-docker-tty || return 1 + assertFileExists ${SANDBOX}/mx-reproducible-contract-build-example-sc-0.2.1/output-docker/artifacts.json || return 1 +} + +testAll() { + ${CLI} config set dependencies.rust.tag ${RUST_VERSION} + + cleanSandbox || return 1 + testTrivialCommands || return 1 + testCreateContracts || return 1 + testBuildContracts || return 1 + testRunScenarios || return 1 + testCleanContracts || return 1 + testWasmName || return 1 +} diff --git a/multiversx_sdk_cli/tests/test_cli_dns.sh b/multiversx_sdk_cli/tests/test_cli_dns.sh new file mode 100644 index 00000000..fa3c9340 --- /dev/null +++ b/multiversx_sdk_cli/tests/test_cli_dns.sh @@ -0,0 +1,113 @@ +#!/usr/bin/env bash + +source "./shared.sh" + +REGISTRATION_COST=100 + +testOnline() { + testRegistrationOnline || return 1 + # Wait for nonces to be incremented (at source shards) + sleep 15 + testTransactionsWithUsernamesOnline || return 1 +} + +testRegistrationOnline() { + ${CLI} --verbose dns register --name="testuser" --pem=${TestUser} --value=${REGISTRATION_COST} \ + --recall-nonce --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txRegisterUser.txt --send --proxy=${PROXY} || return 1 + + ${CLI} --verbose dns register --name="testuser2" --pem=${TestUser2} --value=${REGISTRATION_COST} \ + --recall-nonce --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txRegisterUser2.txt --send --proxy=${PROXY} || return 1 +} + +testTransactionsWithUsernamesOnline() { + ${CLI} --verbose tx new --pem=${TestUser} --receiver=${TestUser2} \ + --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txA.txt --send --proxy=${PROXY} || return 1 + + sleep 10 + + ${CLI} --verbose tx new --pem=${TestUser} --receiver=${TestUser2} --receiver-username="testuser2" \ + --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txB.txt --send --proxy=${PROXY} || return 1 + + sleep 10 + + ${CLI} --verbose tx new --pem=${TestUser} --receiver=${TestUser2} --receiver-username="testuser2foo" \ + --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txC.txt --send --proxy=${PROXY} || return 1 + + sleep 10 + + ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver=${TestUser2} --receiver-username="testuser2" \ + --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txD.txt --send --proxy=${PROXY} || return 1 + + sleep 10 + + ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver=${TestUser2} \ + --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txF.txt --send --proxy=${PROXY} || return 1 + + sleep 10 + + ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuserfoo" --receiver=${TestUser2} \ + --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txG.txt --send --proxy=${PROXY} || return 1 +} + + +testOffline() { + testRegistrationOffline || return 1 + testTransactionsWithUsernamesOffline || return 1 +} + +testRegistrationOffline() { + ${CLI} --verbose dns register --name="testuser" --pem=${TestUser} --value=${REGISTRATION_COST} \ + --nonce=7 --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txRegisterUser.txt || return 1 + assertFileExists ${SANDBOX}/txRegisterUser.txt || return 1 + + ${CLI} --verbose dns register --name="testuser2" --pem=${TestUser2} --value=${REGISTRATION_COST} \ + --nonce=8 --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txRegisterUser2.txt || return 1 + assertFileExists ${SANDBOX}/txRegisterUser2.txt || return 1 +} + +testTransactionsWithUsernamesOffline() { + ${CLI} --verbose tx new --pem=${TestUser} --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" \ + --value="1${DENOMINATION}" --nonce=42 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txA.txt || return 1 + assertFileExists ${SANDBOX}/txA.txt || return 1 + + ${CLI} --verbose tx new --pem=${TestUser} --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" --receiver-username="testuser2" \ + --value="1${DENOMINATION}" --nonce=43 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txB.txt || return 1 + assertFileExists ${SANDBOX}/txB.txt || return 1 + + ${CLI} --verbose tx new --pem=${TestUser} --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" --receiver-username="testuser2foo" \ + --value="1${DENOMINATION}" --nonce=44 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txC.txt || return 1 + assertFileExists ${SANDBOX}/txC.txt || return 1 + + ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" --receiver-username="testuser2" \ + --value="1${DENOMINATION}" --nonce=45 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txD.txt || return 1 + assertFileExists ${SANDBOX}/txD.txt || return 1 + + ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" \ + --value="1${DENOMINATION}" --nonce=46 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txF.txt || return 1 + assertFileExists ${SANDBOX}/txF.txt || return 1 + + ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuserfoo" --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" \ + --value="1${DENOMINATION}" --nonce=47 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ + --outfile=${SANDBOX}/txG.txt || return 1 + assertFileExists ${SANDBOX}/txG.txt || return 1 +} + +testAll() { + testOnline || return 1 + testOffline || return 1 +} diff --git a/multiversx_sdk_cli/tests/test_cli_validators.sh b/multiversx_sdk_cli/tests/test_cli_validators.sh new file mode 100755 index 00000000..d489c9c0 --- /dev/null +++ b/multiversx_sdk_cli/tests/test_cli_validators.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +source "./shared.sh" + +testAll() { + BLS_KEY="e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" + REWARD_ADDRESS="erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8" + + echo "Stake with recall nonce" + ${CLI} --verbose validator stake --pem="${USERS}/alice.pem" --value="2500${DENOMINATION}" --validators-file=./testdata/validators.json --reward-address=${REWARD_ADDRESS} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 + echo "Stake with provided nonce" + ${CLI} --verbose validator stake --pem="${USERS}/bob.pem" --value="2500${DENOMINATION}" --validators-file=./testdata/validators.json --reward-address=${REWARD_ADDRESS} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --nonce=300 || return 1 + + + echo "Stake with topUP" + ${CLI} --verbose validator stake --top-up --pem="${USERS}/carol.pem" --value="2711${DENOMINATION}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 + + echo "Unstake" + ${CLI} --verbose validator unstake --pem="${USERS}/dan.pem" --nodes-public-keys="${BLS_KEY}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 + echo "Unbond" + ${CLI} --verbose validator unbond --pem="${USERS}/eve.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 + echo "Unjail" + ${CLI} --verbose validator unjail --pem="${USERS}/frank.pem" --value="2500${DENOMINATION}" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 + echo "Change reward address" + ${CLI} --verbose validator change-reward-address --pem="${USERS}/grace.pem" --reward-address=${REWARD_ADDRESS} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 + + echo "UnstakeNodes" + ${CLI} --verbose validator unstake-nodes --pem="${USERS}/heidi.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 + + echo "UnstakeTokens" + ${CLI} --verbose validator unstake-tokens --pem="${USERS}/ivan.pem" --unstake-value="11${DENOMINATION}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 + + echo "UnbondNodes" + ${CLI} --verbose validator unbond-nodes --pem="${USERS}/judy.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 + + echo "UnbondTokens" + ${CLI} --verbose validator unbond-tokens --pem="${USERS}/mallory.pem" --unbond-value="20${DENOMINATION}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 + + echo "CleanRegistrationData" + ${CLI} --verbose validator clean-registered-data --pem="${USERS}/mike.pem" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 + + echo "ReStakeUnstakedNodes" + ${CLI} --verbose validator restake-unstaked-nodes --pem="${USERS}/alice.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 +} From eb4228918c4380499aae3fb12d00554975840ab6 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Tue, 5 Nov 2024 16:35:54 +0200 Subject: [PATCH 69/74] bring back bash tests as they are used in other tests. --- .github/workflows/test-localnet-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index c79969c9..2ad02795 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -52,4 +52,4 @@ jobs: - name: Test localnet dependent tests run: | pytest -m require_localnet . - + python3 -m multiversx_sdk_cli.cli localnet stop --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml From 10ffa3c0ac360418b48453bf2aeba882c49207a1 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Tue, 5 Nov 2024 17:04:42 +0200 Subject: [PATCH 70/74] added teardown for localnet. --- .github/workflows/test-localnet-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 2ad02795..8c62ad80 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -52,4 +52,4 @@ jobs: - name: Test localnet dependent tests run: | pytest -m require_localnet . - python3 -m multiversx_sdk_cli.cli localnet stop --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml + python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml From d382db0e57a86f60fb38b7bb33837603111fb137 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Tue, 5 Nov 2024 17:16:22 +0200 Subject: [PATCH 71/74] clean unused bash tests. --- .github/workflows/build-windows.yml | 4 +- .github/workflows/build.yml | 5 - multiversx_sdk_cli/tests/test_cli_all.sh | 4 - multiversx_sdk_cli/tests/test_cli_dns.sh | 113 ------------------ multiversx_sdk_cli/tests/test_cli_tx.sh | 29 ----- .../tests/test_cli_validators.sh | 44 ------- 6 files changed, 1 insertion(+), 198 deletions(-) delete mode 100644 multiversx_sdk_cli/tests/test_cli_dns.sh delete mode 100644 multiversx_sdk_cli/tests/test_cli_tx.sh delete mode 100755 multiversx_sdk_cli/tests/test_cli_validators.sh diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index b6f87291..df4528a9 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -54,6 +54,4 @@ jobs: export PROXY=https://testnet-gateway.multiversx.com export CHAIN_ID=T cd ./multiversx_sdk_cli/tests - source ./test_cli_tx.sh && testAll || return 1 - source ./test_cli_dns.sh && testOffline || return 1 - source ./test_cli_validators.sh && testAll || return 1 + testAll || return 1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9dda9a37..044f4b88 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,8 +44,3 @@ jobs: run: | export PYTHONPATH=. pytest . - - name: Run CLI tests - run: | - cd ./multiversx_sdk_cli/tests - source ./test_cli_contracts.sh && testAll || return 1 - source ./test_cli_dns.sh && testOffline || return 1 diff --git a/multiversx_sdk_cli/tests/test_cli_all.sh b/multiversx_sdk_cli/tests/test_cli_all.sh index 28cb34f2..95cd2418 100644 --- a/multiversx_sdk_cli/tests/test_cli_all.sh +++ b/multiversx_sdk_cli/tests/test_cli_all.sh @@ -6,12 +6,8 @@ USE_PROXY=$1 testAll() { pushd $SCRIPT_DIR source ./shared.sh - source ./test_cli_contracts.sh && testAll - source ./test_cli_dns.sh && testAll if [ -n "$USE_PROXY" ]; then - source ./test_cli_validators.sh && testAll - source ./test_cli_tx.sh && testAll source ./test_cli_config.sh && testAll fi popd diff --git a/multiversx_sdk_cli/tests/test_cli_dns.sh b/multiversx_sdk_cli/tests/test_cli_dns.sh deleted file mode 100644 index fa3c9340..00000000 --- a/multiversx_sdk_cli/tests/test_cli_dns.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env bash - -source "./shared.sh" - -REGISTRATION_COST=100 - -testOnline() { - testRegistrationOnline || return 1 - # Wait for nonces to be incremented (at source shards) - sleep 15 - testTransactionsWithUsernamesOnline || return 1 -} - -testRegistrationOnline() { - ${CLI} --verbose dns register --name="testuser" --pem=${TestUser} --value=${REGISTRATION_COST} \ - --recall-nonce --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txRegisterUser.txt --send --proxy=${PROXY} || return 1 - - ${CLI} --verbose dns register --name="testuser2" --pem=${TestUser2} --value=${REGISTRATION_COST} \ - --recall-nonce --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txRegisterUser2.txt --send --proxy=${PROXY} || return 1 -} - -testTransactionsWithUsernamesOnline() { - ${CLI} --verbose tx new --pem=${TestUser} --receiver=${TestUser2} \ - --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txA.txt --send --proxy=${PROXY} || return 1 - - sleep 10 - - ${CLI} --verbose tx new --pem=${TestUser} --receiver=${TestUser2} --receiver-username="testuser2" \ - --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txB.txt --send --proxy=${PROXY} || return 1 - - sleep 10 - - ${CLI} --verbose tx new --pem=${TestUser} --receiver=${TestUser2} --receiver-username="testuser2foo" \ - --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txC.txt --send --proxy=${PROXY} || return 1 - - sleep 10 - - ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver=${TestUser2} --receiver-username="testuser2" \ - --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txD.txt --send --proxy=${PROXY} || return 1 - - sleep 10 - - ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver=${TestUser2} \ - --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txF.txt --send --proxy=${PROXY} || return 1 - - sleep 10 - - ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuserfoo" --receiver=${TestUser2} \ - --value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txG.txt --send --proxy=${PROXY} || return 1 -} - - -testOffline() { - testRegistrationOffline || return 1 - testTransactionsWithUsernamesOffline || return 1 -} - -testRegistrationOffline() { - ${CLI} --verbose dns register --name="testuser" --pem=${TestUser} --value=${REGISTRATION_COST} \ - --nonce=7 --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txRegisterUser.txt || return 1 - assertFileExists ${SANDBOX}/txRegisterUser.txt || return 1 - - ${CLI} --verbose dns register --name="testuser2" --pem=${TestUser2} --value=${REGISTRATION_COST} \ - --nonce=8 --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txRegisterUser2.txt || return 1 - assertFileExists ${SANDBOX}/txRegisterUser2.txt || return 1 -} - -testTransactionsWithUsernamesOffline() { - ${CLI} --verbose tx new --pem=${TestUser} --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" \ - --value="1${DENOMINATION}" --nonce=42 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txA.txt || return 1 - assertFileExists ${SANDBOX}/txA.txt || return 1 - - ${CLI} --verbose tx new --pem=${TestUser} --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" --receiver-username="testuser2" \ - --value="1${DENOMINATION}" --nonce=43 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txB.txt || return 1 - assertFileExists ${SANDBOX}/txB.txt || return 1 - - ${CLI} --verbose tx new --pem=${TestUser} --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" --receiver-username="testuser2foo" \ - --value="1${DENOMINATION}" --nonce=44 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txC.txt || return 1 - assertFileExists ${SANDBOX}/txC.txt || return 1 - - ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" --receiver-username="testuser2" \ - --value="1${DENOMINATION}" --nonce=45 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txD.txt || return 1 - assertFileExists ${SANDBOX}/txD.txt || return 1 - - ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" \ - --value="1${DENOMINATION}" --nonce=46 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txF.txt || return 1 - assertFileExists ${SANDBOX}/txF.txt || return 1 - - ${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuserfoo" --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" \ - --value="1${DENOMINATION}" --nonce=47 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ - --outfile=${SANDBOX}/txG.txt || return 1 - assertFileExists ${SANDBOX}/txG.txt || return 1 -} - -testAll() { - testOnline || return 1 - testOffline || return 1 -} diff --git a/multiversx_sdk_cli/tests/test_cli_tx.sh b/multiversx_sdk_cli/tests/test_cli_tx.sh deleted file mode 100644 index 618073bb..00000000 --- a/multiversx_sdk_cli/tests/test_cli_tx.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -source "./shared.sh" - -BOB="erd1cux02zersde0l7hhklzhywcxk4u9n4py5tdxyx7vrvhnza2r4gmq4vw35r" - -testAll() { - cleanSandbox || return 1 - - echo "tx new, don't --send" - ${CLI} --verbose tx new --pem="${USERS}/alice.pem" --receiver=${BOB} --proxy=${PROXY} --value="1${DENOMINATION}" --recall-nonce --data="foo" --gas-limit=70000 --chain=${CHAIN_ID} --outfile=${SANDBOX}/txA.txt || return 1 - echo "tx send" - ${CLI} --verbose tx send --infile=${SANDBOX}/txA.txt --proxy=${PROXY} || return 1 - echo "tx new --send" - ${CLI} --verbose tx new --pem="${USERS}/bob.pem" --receiver=${BOB} --value="1${DENOMINATION}" --recall-nonce --data="foo" --gas-limit=60000 --chain=${CHAIN_ID} --send --outfile=${SANDBOX}/txB.txt --proxy=${PROXY} || return 1 - echo "tx new with --data-file" - echo '"{hello world!}"' > ${SANDBOX}/dummy.txt - ${CLI} --verbose tx new --pem="${USERS}/carol.pem" --receiver=${BOB} --value="1${DENOMINATION}" --recall-nonce --data-file=${SANDBOX}/dummy.txt --gas-limit=70000 --chain=${CHAIN_ID} --proxy=${PROXY} || return 1 - - echo "tx new --relay" - ${CLI} --verbose tx new --pem="${USERS}/dan.pem" --receiver=${BOB} --proxy=${PROXY} --value="1${DENOMINATION}" --nonce=1 --data="foo" --gas-limit=70000 --chain=${CHAIN_ID} --outfile=${SANDBOX}/txInner.txt --relay || return 1 - ${CLI} --verbose tx new --pem="${USERS}/eve.pem" --receiver=${BOB} --proxy=${PROXY} --value="1${DENOMINATION}" --recall-nonce --data-file=${SANDBOX}/txInner.txt --gas-limit=200000 --chain=${CHAIN_ID} --outfile=${SANDBOX}/txWrapper.txt || return 1 - - echo "tx new --simulate" - ${CLI} --verbose tx new --simulate --pem="${USERS}/frank.pem" --receiver=${BOB} --value="1${DENOMINATION}" --recall-nonce --data="foo" --gas-limit=70000 --chain=${CHAIN_ID} --proxy=${PROXY} || return 1 - - echo "tx new --send --wait-result" - ${CLI} --verbose tx new --send --wait-result --pem="${USERS}/grace.pem" --receiver=${BOB} --value="1${DENOMINATION}" --recall-nonce --data="foo" --gas-limit=70000 --chain=${CHAIN_ID} --proxy=${PROXY} || return 1 -} diff --git a/multiversx_sdk_cli/tests/test_cli_validators.sh b/multiversx_sdk_cli/tests/test_cli_validators.sh deleted file mode 100755 index d489c9c0..00000000 --- a/multiversx_sdk_cli/tests/test_cli_validators.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -source "./shared.sh" - -testAll() { - BLS_KEY="e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" - REWARD_ADDRESS="erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8" - - echo "Stake with recall nonce" - ${CLI} --verbose validator stake --pem="${USERS}/alice.pem" --value="2500${DENOMINATION}" --validators-file=./testdata/validators.json --reward-address=${REWARD_ADDRESS} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - echo "Stake with provided nonce" - ${CLI} --verbose validator stake --pem="${USERS}/bob.pem" --value="2500${DENOMINATION}" --validators-file=./testdata/validators.json --reward-address=${REWARD_ADDRESS} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --nonce=300 || return 1 - - - echo "Stake with topUP" - ${CLI} --verbose validator stake --top-up --pem="${USERS}/carol.pem" --value="2711${DENOMINATION}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - - echo "Unstake" - ${CLI} --verbose validator unstake --pem="${USERS}/dan.pem" --nodes-public-keys="${BLS_KEY}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - echo "Unbond" - ${CLI} --verbose validator unbond --pem="${USERS}/eve.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - echo "Unjail" - ${CLI} --verbose validator unjail --pem="${USERS}/frank.pem" --value="2500${DENOMINATION}" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - echo "Change reward address" - ${CLI} --verbose validator change-reward-address --pem="${USERS}/grace.pem" --reward-address=${REWARD_ADDRESS} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - - echo "UnstakeNodes" - ${CLI} --verbose validator unstake-nodes --pem="${USERS}/heidi.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - - echo "UnstakeTokens" - ${CLI} --verbose validator unstake-tokens --pem="${USERS}/ivan.pem" --unstake-value="11${DENOMINATION}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - - echo "UnbondNodes" - ${CLI} --verbose validator unbond-nodes --pem="${USERS}/judy.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - - echo "UnbondTokens" - ${CLI} --verbose validator unbond-tokens --pem="${USERS}/mallory.pem" --unbond-value="20${DENOMINATION}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - - echo "CleanRegistrationData" - ${CLI} --verbose validator clean-registered-data --pem="${USERS}/mike.pem" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 - - echo "ReStakeUnstakedNodes" - ${CLI} --verbose validator restake-unstaked-nodes --pem="${USERS}/alice.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 -} From 7ab16ba09f8aee9f102d662bed6c2ada3a58b865 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Wed, 6 Nov 2024 10:26:02 +0200 Subject: [PATCH 72/74] remove cli tests for windows. --- .github/workflows/build-windows.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index df4528a9..b157b6e8 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -48,10 +48,3 @@ jobs: run: | export PYTHONPATH=. pytest -m "not skip_on_windows and not require_localnet" . - - name: Run CLI tests - shell: bash - run: | - export PROXY=https://testnet-gateway.multiversx.com - export CHAIN_ID=T - cd ./multiversx_sdk_cli/tests - testAll || return 1 From ca1d4fd9a178e7076ab19764d1155a4e955d2eda Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Wed, 6 Nov 2024 10:27:22 +0200 Subject: [PATCH 73/74] remove deleted shell scripts. --- multiversx_sdk_cli/tests/test_cli_all.sh | 3 +++ 1 file changed, 3 insertions(+) mode change 100644 => 100755 multiversx_sdk_cli/tests/test_cli_all.sh diff --git a/multiversx_sdk_cli/tests/test_cli_all.sh b/multiversx_sdk_cli/tests/test_cli_all.sh old mode 100644 new mode 100755 index 95cd2418..cd49eb4a --- a/multiversx_sdk_cli/tests/test_cli_all.sh +++ b/multiversx_sdk_cli/tests/test_cli_all.sh @@ -3,6 +3,9 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" USE_PROXY=$1 +source ./shared.sh +source ./test_cli_validators.sh && testAll + testAll() { pushd $SCRIPT_DIR source ./shared.sh From 8d2ee9a5a8c81667795df652ec446c31207efec1 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Tue, 19 Nov 2024 07:10:59 +0200 Subject: [PATCH 74/74] removed unnecessary shell scripts. --- multiversx_sdk_cli/tests/test_cli_all.sh | 17 ----------------- multiversx_sdk_cli/tests/test_cli_config.sh | 14 -------------- 2 files changed, 31 deletions(-) delete mode 100755 multiversx_sdk_cli/tests/test_cli_all.sh delete mode 100644 multiversx_sdk_cli/tests/test_cli_config.sh diff --git a/multiversx_sdk_cli/tests/test_cli_all.sh b/multiversx_sdk_cli/tests/test_cli_all.sh deleted file mode 100755 index cd49eb4a..00000000 --- a/multiversx_sdk_cli/tests/test_cli_all.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -USE_PROXY=$1 - -source ./shared.sh -source ./test_cli_validators.sh && testAll - -testAll() { - pushd $SCRIPT_DIR - source ./shared.sh - - if [ -n "$USE_PROXY" ]; then - source ./test_cli_config.sh && testAll - fi - popd -} diff --git a/multiversx_sdk_cli/tests/test_cli_config.sh b/multiversx_sdk_cli/tests/test_cli_config.sh deleted file mode 100644 index d6609f52..00000000 --- a/multiversx_sdk_cli/tests/test_cli_config.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -source "./shared.sh" - -testAll() { - set -x - - ${CLI} --verbose config set proxy "https://testnet-api.multiversx.com" - ${CLI} --verbose config get proxy - ${CLI} --verbose config set txVersion 1 - ${CLI} --verbose config get txVersion - - set +x -}