From 04ff4ac5e39eefab6a4804059588cd227e14f613 Mon Sep 17 00:00:00 2001 From: Gus Date: Fri, 2 Aug 2024 08:11:27 -0400 Subject: [PATCH 1/3] test: subnet list e2e --- .../e2e_tests/subcommands/subnet/test_list.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/e2e_tests/subcommands/subnet/test_list.py diff --git a/tests/e2e_tests/subcommands/subnet/test_list.py b/tests/e2e_tests/subcommands/subnet/test_list.py new file mode 100644 index 0000000000..6fe57c1c78 --- /dev/null +++ b/tests/e2e_tests/subcommands/subnet/test_list.py @@ -0,0 +1,29 @@ +import bittensor +from bittensor.commands import RegisterSubnetworkCommand +from tests.e2e_tests.utils import setup_wallet + +""" +Test the list command before and after registering subnets. + +Verify that: +* list of subnets gets displayed +------------------------- +* Register a subnets +* Ensure is visible in list cmd +""" + + +def test_list_command(local_chain, capsys): + # Register root as Alice + keypair, exec_command, wallet = setup_wallet("//Alice") + + subtensor = bittensor.subtensor(network="ws://localhost:9945") + + subnets = subtensor.get_subnets() + + assert len(subnets) == 2 + + exec_command(RegisterSubnetworkCommand, ["s", "create"]) + # Verify subnet 1 created successfully + subnets = subtensor.get_subnets() + assert len(subnets) == 3 From 38e55a54897c42742f227bf7f13c740b324ff4a9 Mon Sep 17 00:00:00 2001 From: Gus Date: Tue, 6 Aug 2024 07:23:42 -0400 Subject: [PATCH 2/3] updates to use local_chain fixture --- tests/e2e_tests/subcommands/subnet/test_list.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/e2e_tests/subcommands/subnet/test_list.py b/tests/e2e_tests/subcommands/subnet/test_list.py index 6fe57c1c78..9119451e07 100644 --- a/tests/e2e_tests/subcommands/subnet/test_list.py +++ b/tests/e2e_tests/subcommands/subnet/test_list.py @@ -17,13 +17,14 @@ def test_list_command(local_chain, capsys): # Register root as Alice keypair, exec_command, wallet = setup_wallet("//Alice") - subtensor = bittensor.subtensor(network="ws://localhost:9945") + netuids = [0, 3] - subnets = subtensor.get_subnets() - - assert len(subnets) == 2 + assert local_chain.query("SubtensorModule", "NetworksAdded", netuids).serialize() exec_command(RegisterSubnetworkCommand, ["s", "create"]) + + netuids.append(1) + netuids.sort() + # Verify subnet 1 created successfully - subnets = subtensor.get_subnets() - assert len(subnets) == 3 + assert local_chain.query("SubtensorModule", "NetworksAdded", netuids).serialize() From 8e2fe29c9f95a7b48f9f871eb01d88b1cd3079c5 Mon Sep 17 00:00:00 2001 From: Gus Date: Tue, 6 Aug 2024 08:51:56 -0400 Subject: [PATCH 3/3] fixes test --- tests/e2e_tests/subcommands/subnet/test_list.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/e2e_tests/subcommands/subnet/test_list.py b/tests/e2e_tests/subcommands/subnet/test_list.py index 9119451e07..74b79a2dfb 100644 --- a/tests/e2e_tests/subcommands/subnet/test_list.py +++ b/tests/e2e_tests/subcommands/subnet/test_list.py @@ -17,14 +17,13 @@ def test_list_command(local_chain, capsys): # Register root as Alice keypair, exec_command, wallet = setup_wallet("//Alice") - netuids = [0, 3] + netuid = 0 - assert local_chain.query("SubtensorModule", "NetworksAdded", netuids).serialize() + assert local_chain.query("SubtensorModule", "NetworksAdded", [netuid]).serialize() exec_command(RegisterSubnetworkCommand, ["s", "create"]) - netuids.append(1) - netuids.sort() + netuid - 1 # Verify subnet 1 created successfully - assert local_chain.query("SubtensorModule", "NetworksAdded", netuids).serialize() + assert local_chain.query("SubtensorModule", "NetworksAdded", [netuid]).serialize()