Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d86764b
New workflow file
Arondondon Nov 25, 2024
c660b25
Added org metadata test
Arondondon Nov 25, 2024
9ce93fb
Update test.yml
Deralden Nov 25, 2024
71f8681
Update test.yml part 2
Deralden Nov 25, 2024
51fe531
Update dev.yml
Deralden Nov 25, 2024
06f528a
Fixed tests
Arondondon Nov 25, 2024
bb819f0
Fixed tests sequence
Arondondon Nov 25, 2024
cd89c3e
Fixed tests sequence x2
Arondondon Nov 25, 2024
36b01fb
[SPT-777] Added new tests: unset, channel, client call, create/delete…
MorozovMisha Jan 17, 2025
ad997f5
[SPT-777] Fixed new tests
MorozovMisha Jan 20, 2025
454c1bb
[SPT-777] Fixed last failture
MorozovMisha Jan 20, 2025
780f999
[SPT-777] Fixed two errors in TestClient
MorozovMisha Jan 24, 2025
2ef8fdd
[SPT-777] Fixed version control
MorozovMisha Jan 27, 2025
ae67a77
[SPT-777] Fixed errors with infura
MorozovMisha Jan 29, 2025
9bc1ce4
[SPT-777] New functional tests: account transfer; channel print, clai…
MorozovMisha Jan 31, 2025
5ca6eab
[SPT-777] Fixed errors and added logs
MorozovMisha Jan 31, 2025
8350009
[SPT-777] Added more logs to fix error
MorozovMisha Jan 31, 2025
ac3aaa5
[SPT-777] Fixed channel errors
MorozovMisha Jan 31, 2025
5e9b465
[SPT-777] Fixed last failture
MorozovMisha Jan 31, 2025
dca668c
[SPT-777] Fixed asserrtation failture
MorozovMisha Jan 31, 2025
6652f27
[SPT-777] New functional tests: organization lists, organization and …
MorozovMisha Feb 3, 2025
f7ae101
[SPT-777] Fixed channel claim command and channel open amount
MorozovMisha Feb 3, 2025
c460d4a
[SPT-777] Fixed channel claim test
MorozovMisha Feb 3, 2025
ddedf9e
[SPT-777] New functional tests: call low-level; get-api-registry; met…
MorozovMisha Feb 4, 2025
cf8ccc1
[SPT-777] New functional tests: service metadata daemon, endpoints
MorozovMisha Feb 4, 2025
c6bf9ce
[SPT-777] Fixed input data for test
MorozovMisha Feb 4, 2025
9ef15cc
[SPT-777] Checking for an open channel
MorozovMisha Feb 5, 2025
a941076
[SPT-777] The method of rounding numbers has been replaced. Also upda…
MorozovMisha Feb 5, 2025
b2495a3
[SPT-777] Updated 'network create' command
MorozovMisha Feb 5, 2025
b3ace02
[SPT-777] checking for channel availability
MorozovMisha Feb 5, 2025
7886224
[SPT-777] fixed network create command
MorozovMisha Feb 5, 2025
18e98a2
[SPT-777] Added new tests: channel print-filter-recipient, print-all;…
MorozovMisha Feb 6, 2025
5f36ce9
[SPT-777] Fixed channel_id declaring
MorozovMisha Feb 6, 2025
3a2d30d
[SPT-777] Added second org to open new channel
MorozovMisha Feb 6, 2025
7bc8693
[SPT-777] Fixed AssertationError and incorrect function name
MorozovMisha Feb 6, 2025
7672902
[SPT-777] Added contract tests
MorozovMisha Feb 6, 2025
60d531f
[SPT-777] removed the dependency for the test execution order
MorozovMisha Feb 7, 2025
6d6841c
[SPT-777] New structure of functional tests
MorozovMisha Feb 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ jobs:
export FORMER_SNET_TEST_INFURA_KEY=${{ secrets.FORM_INF_KEY }}
export PIP_BREAK_SYSTEM_PACKAGES=1
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
# sh -ex ./snet/cli/test/utils/run_all_functional.sh
# sh -ex ./snet/cli/test/utils/run_all_functional.sh
python3 ./snet/cli/test/functional_tests/test_entry_point.py
python3 ./snet/cli/test/functional_tests/func_tests.py
1 change: 1 addition & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ jobs:
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
# sh -ex ./snet/cli/test/utils/run_all_functional.sh
python3 ./snet/cli/test/functional_tests/test_entry_point.py
python3 ./snet/cli/test/functional_tests/func_tests.py
66 changes: 66 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: tests_functional_tests_update
on:
push:
branches: [ "functional-tests-update" ]
# pull_request:
# branches: [ "development" ]
workflow_dispatch:

jobs:
run_tests_functional_tests_update:
runs-on: ubuntu-latest
container: node:20-bookworm
steps:

- name: install packs
run: |
apt update
apt install -y libudev-dev libusb-1.0-0-dev curl jq
apt install -y python3-pip python3.11-venv

- name: clone repo
uses: actions/checkout@v3

- name: install pip packages
run: |
pip3 install -r requirements.txt --break-system-packages
# pip3 install nose --break-system-packages
# pip3 uninstall pyreadline --break-system-packages
# pip3 install pyreadline3 --break-system-packages

- name: install snet-cli
run: |
# ./scripts/blockchain install
pip3 install -e . --break-system-packages

# - name: install platform-contracts
# run: |
# cd ..
# git clone https://github.com/singnet/platform-contracts.git
# cd platform-contracts
# npm install
# npm install ganache-cli
# npm run-script compile

# - name: build example service
# run: |
# git clone https://github.com/singnet/example-service.git
# cd example-service
# pip3 install -r requirements.txt --break-system-packages
# sh buildproto.sh

# - name: unit tests
# run: |
# cd ./snet/cli/test
# nosetests -v --with-doctest

- name: functional tests for cli
run: |
export SNET_TEST_WALLET_PRIVATE_KEY=${{ secrets.PRIV_KEY }}
export SNET_TEST_INFURA_KEY=${{ secrets.INF_KEY }}
export SNET_TEST_WALLET_ADDRESS=${{ secrets.ADDR }}
export FORMER_SNET_TEST_INFURA_KEY=${{ secrets.FORM_INF_KEY }}
export PIP_BREAK_SYSTEM_PACKAGES=1
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
# sh -ex ./snet/cli/test/utils/run_all_functional.sh
python3 ./snet/cli/test/functional_tests/test_entry_point.py
2 changes: 1 addition & 1 deletion snet/cli/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ def add_mpe_service_options(parser):
p.add_argument("name", help="Name of the contributor")
p.add_argument("email_id", help="Email of the contributor")

p = subparsers.add_parser("metadata-remove-contributor", help="Add contributor")
p = subparsers.add_parser("metadata-remove-contributor", help="Remove contributor")
p.set_defaults(fn="metadata_remove_contributor")
add_p_metadata_file_opt(p)
p.add_argument("email_id", help="Email of the contributor")
Expand Down
2 changes: 1 addition & 1 deletion snet/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def set_session_field(self, key, value, out_f):
self.set_identity_field(session_identity, key, value)
print("set {}={} for identity={}".format(key, value, session_identity), file=out_f)
else:
all_keys = get_session_network_keys() + get_session_identity_keys() + ["default_ipfs_endpoint"]
all_keys = get_session_keys()
raise Exception("key {} not in {}".format(key, all_keys))

def unset_session_field(self, key, out_f):
Expand Down
98 changes: 8 additions & 90 deletions snet/cli/test/functional_tests/func_tests.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import warnings
import argcomplete
import unittest
import unittest.mock as mock
import shutil
import os

from snet.cli.commands.commands import BlockchainCommand

with warnings.catch_warnings():
# Suppress the eth-typing package`s warnings related to some new networks
warnings.filterwarnings("ignore", "Network .* does not have a valid ChainId. eth-typing should be "
Expand All @@ -15,6 +11,12 @@

from snet.cli.config import Config

INFURA_KEY = os.environ.get("SNET_TEST_INFURA_KEY")
PRIVATE_KEY = os.environ.get("SNET_TEST_WALLET_PRIVATE_KEY")
ADDR = os.environ.get("SNET_TEST_WALLET_ADDRESS")
INFURA = f"https://sepolia.infura.io/v3/{INFURA_KEY}"
IDENTITY = "sepolia"


class StringOutput:
def __init__(self):
Expand All @@ -32,102 +34,18 @@ def execute(args_list, parser, conf):
except TypeError:
args = parser.parse_args(argv + ["-h"])
f = StringOutput()
getattr(args.cmd(conf, args, out_f = f), args.fn)()
getattr(args.cmd(conf, args, out_f=f), args.fn)()
return f.text
except Exception as e:
raise


class BaseTest(unittest.TestCase):
def setUp(self):
self.conf = Config()
self.parser = arguments.get_root_parser(self.conf)
argcomplete.autocomplete(self.parser)


class TestCommands(BaseTest):
def test_balance_output(self):
result = execute(["account", "balance"], self.parser, self.conf)
assert len(result.split("\n")) >= 4

def test_balance_address(self):
result = execute(["account", "balance"], self.parser, self.conf)
assert result.split("\n")[0].split()[1] == "0xe5D1fA424DE4689F9d2687353b75D7a8987900fD"

class TestDepositWithdraw(BaseTest):
def setUp(self):
super().setUp()
self.balance_1: int
self.balance_2: int
self.amount = 0.1

def test_deposit(self):
result = execute(["account", "balance"], self.parser, self.conf)
self.balance_1 = float(result.split("\n")[3].split()[1])
execute(["account", "deposit", f"{self.amount}", "-y", "-q"], self.parser, self.conf)
result = execute(["account", "balance"], self.parser, self.conf)
self.balance_2 = float(result.split("\n")[3].split()[1])
assert self.balance_2 == self.balance_1 + self.amount

def test_withdraw(self):
result = execute(["account", "balance"], self.parser, self.conf)
self.balance_1 = float(result.split("\n")[3].split()[1])
execute(["account", "withdraw", f"{self.amount}", "-y", "-q"], self.parser, self.conf)
result = execute(["account", "balance"], self.parser, self.conf)
self.balance_2 = float(result.split("\n")[3].split()[1])
assert self.balance_2 == self.balance_1 - self.amount


class TestGenerateLibrary(BaseTest):
def setUp(self):
super().setUp()
self.path = './temp_files'
self.org_id = '26072b8b6a0e448180f8c0e702ab6d2f'
self.service_id = 'Exampleservice'

def test_generate(self):
execute(["sdk", "generate-client-library", self.org_id, self.service_id, self.path], self.parser, self.conf)
assert os.path.exists(f'{self.path}/{self.org_id}/{self.service_id}/python/')

def tearDown(self):
shutil.rmtree(self.path)


class TestEncryptionKey(BaseTest):
def setUp(self):
super().setUp()
self.key = "1234567890123456789012345678901234567890123456789012345678901234"
self.password = "some_pass"
self.name = "some_name"
self.default_name = "default_name"
result = execute(["identity", "list"], self.parser, self.conf)
if self.default_name not in result:
execute(["identity", "create", self.default_name, "key", "--private-key", self.key, "-de"],
self.parser,
self.conf)

def test_1_create_identity_with_encryption_key(self):
with mock.patch('getpass.getpass', return_value=self.password):
execute(["identity", "create", self.name, "key", "--private-key", self.key],
self.parser,
self.conf)
result = execute(["identity", "list"], self.parser, self.conf)
assert self.name in result

def test_2_get_encryption_key(self):
with mock.patch('getpass.getpass', return_value=self.password):
execute(["identity", self.name], self.parser, self.conf)
cmd = BlockchainCommand(self.conf, self.parser.parse_args(['session']))
enc_key = cmd.config.get_session_field("private_key")
res_key = cmd._get_decrypted_secret(enc_key)
assert res_key == self.key

def test_3_delete_identity(self):
with mock.patch('getpass.getpass', return_value=self.password):
execute(["identity", self.default_name], self.parser, self.conf)
execute(["identity", "delete", self.name], self.parser, self.conf)
result = execute(["identity", "list"], self.parser, self.conf)
assert self.name not in result


if __name__ == "__main__":
unittest.main()
62 changes: 0 additions & 62 deletions snet/cli/test/functional_tests/mint/mint.py

This file was deleted.

39 changes: 0 additions & 39 deletions snet/cli/test/functional_tests/script10_claim_timeout_all.sh

This file was deleted.

Loading