Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Arondondon committed Nov 25, 2024
1 parent 51fe531 commit 06f528a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
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
Expand Down
29 changes: 28 additions & 1 deletion snet/cli/test/functional_tests/func_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,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 = "main"


class StringOutput:
def __init__(self):
Expand All @@ -37,21 +43,42 @@ def execute(args_list, parser, conf):
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 TestMainPreparations(BaseTest):
def setUp(self):
super().setUp()

def test_1_set_infura(self):
execute(["set", "default_eth_rpc_endpoint", INFURA], self.parser, self.conf)
result = execute(["session"], self.parser, self.conf)
assert INFURA_KEY in result

def test_2_identity_create(self):
execute(["identity", "create", IDENTITY, "key", "--private-key", PRIVATE_KEY, "-de"], self.parser, self.conf)
result = execute(["session"], self.parser, self.conf)
assert f"identity: {IDENTITY}" in result

def test_3_set_network(self):
execute(["network", "sepolia"], self.parser, self.conf)
result = execute(["session"], self.parser, self.conf)
assert "network: sepolia" in result


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"
assert result.split("\n")[0].split()[1] == ADDR

class TestDepositWithdraw(BaseTest):
def setUp(self):
Expand Down

0 comments on commit 06f528a

Please sign in to comment.