From 8b4175fea79d84863fa06d6527b5077ac06a02ce Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Thu, 26 Sep 2024 17:49:51 +0200 Subject: [PATCH 1/2] Ask for wallet name for `root my-delegates` only if `--all` is not specified. If `--all` is specified, ask for the path. --- bittensor_cli/cli.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index 2582da7d4..ee619bf89 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -2805,7 +2805,10 @@ def root_my_delegates( """ self.verbosity_handler(quiet, verbose) wallet = self.wallet_ask( - wallet_name, wallet_path, wallet_hotkey, ask_for=[WO.NAME] + wallet_name, + wallet_path, + wallet_hotkey, + ask_for=([WO.NAME] if not all_wallets else [WO.PATH]), ) self._run_command( root.my_delegates( From 1efcd12e6d599f06db7810f3ecc0f602984b4067 Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Thu, 26 Sep 2024 17:57:58 +0200 Subject: [PATCH 2/2] Add validation. --- bittensor_cli/cli.py | 1 + setup.py | 3 ++- tests/e2e_tests/test_senate.py | 6 +++--- tests/e2e_tests/utils.py | 12 +++++++++--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index ee619bf89..9b9ada90c 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -2809,6 +2809,7 @@ def root_my_delegates( wallet_path, wallet_hotkey, ask_for=([WO.NAME] if not all_wallets else [WO.PATH]), + validate=WV.WALLET if not all_wallets else WV.NONE ) self._run_command( root.my_delegates( diff --git a/setup.py b/setup.py index f5f23114f..f9c92cda8 100644 --- a/setup.py +++ b/setup.py @@ -64,7 +64,8 @@ def read_requirements(path): long_description_content_type="text/markdown", url="https://github.com/opentensor/btcli", author="bittensor.com", - packages=find_packages(exclude=["tests", "tests.*", "*/tests/*", "*/tests"]) + ['bittensor_cli.src.bittensor.templates'], + packages=find_packages(exclude=["tests", "tests.*", "*/tests/*", "*/tests"]) + + ["bittensor_cli.src.bittensor.templates"], include_package_data=True, package_data={ "": ["templates/*"], diff --git a/tests/e2e_tests/test_senate.py b/tests/e2e_tests/test_senate.py index f3b3ac7fb..83ad9082a 100644 --- a/tests/e2e_tests/test_senate.py +++ b/tests/e2e_tests/test_senate.py @@ -88,7 +88,7 @@ def test_senate(local_chain, wallet_setup): # Assert Bob is now part of the senate assert wallet_bob.hotkey.ss58_address in root_senate_after_reg.stdout - + # Manually add a proposal on the chain & assert success = asyncio.run(call_add_proposal(local_chain, wallet_bob)) assert success is True @@ -154,10 +154,10 @@ def test_senate(local_chain, wallet_setup): assert proposals_after_aye_output[5] == "Aye" # Aye votes increased to 1 - assert proposals_after_aye_output[2] == '1' + assert proposals_after_aye_output[2] == "1" # Nay votes remain 0 - assert proposals_after_aye_output[3] == '0' + assert proposals_after_aye_output[3] == "0" # Register Alice to the root network (0) # Registering to root automatically makes you a senator if eligible diff --git a/tests/e2e_tests/utils.py b/tests/e2e_tests/utils.py index 53761e90f..f5a70e706 100644 --- a/tests/e2e_tests/utils.py +++ b/tests/e2e_tests/utils.py @@ -11,7 +11,9 @@ from bittensor_wallet import Wallet if TYPE_CHECKING: - from bittensor_cli.src.bittensor.async_substrate_interface import AsyncSubstrateInterface + from bittensor_cli.src.bittensor.async_substrate_interface import ( + AsyncSubstrateInterface, + ) template_path = os.getcwd() + "/neurons/" templates_repo = "templates repository" @@ -287,7 +289,9 @@ def uninstall_templates(install_dir): shutil.rmtree(install_dir) -async def call_add_proposal(substrate: "AsyncSubstrateInterface", wallet: Wallet) -> bool: +async def call_add_proposal( + substrate: "AsyncSubstrateInterface", wallet: Wallet +) -> bool: async with substrate: proposal_call = await substrate.compose_call( call_module="System", @@ -304,7 +308,9 @@ async def call_add_proposal(substrate: "AsyncSubstrateInterface", wallet: Wallet }, ) - extrinsic = await substrate.create_signed_extrinsic(call=call, keypair=wallet.coldkey) + extrinsic = await substrate.create_signed_extrinsic( + call=call, keypair=wallet.coldkey + ) response = await substrate.submit_extrinsic( extrinsic, wait_for_inclusion=True,