From 453cd94338b7e6c83503709569de6f61a6a8715a Mon Sep 17 00:00:00 2001 From: Gus Date: Wed, 7 Aug 2024 09:21:51 -0400 Subject: [PATCH 1/3] test: adds wallet list command e2e test --- .../e2e_tests/subcommands/wallet/test_list.py | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 tests/e2e_tests/subcommands/wallet/test_list.py diff --git a/tests/e2e_tests/subcommands/wallet/test_list.py b/tests/e2e_tests/subcommands/wallet/test_list.py new file mode 100644 index 000000000..562dc863a --- /dev/null +++ b/tests/e2e_tests/subcommands/wallet/test_list.py @@ -0,0 +1,72 @@ +from bittensor.commands.list import ListCommand +from bittensor.commands.wallets import WalletCreateCommand +from bittensor.subtensor import subtensor + +from ...utils import setup_wallet + + +def test_wallet_list(local_chain: subtensor, capsys): + """ + Test the listing of wallets in the Bittensor network. + + Steps: + 1. Set up a default wallet + 2. List existing wallets and verify the default setup + 3. Create a new wallet + 4. List wallets again and verify the new wallet is present + + Raises: + AssertionError: If any of the checks or verifications fail + """ + + wallet_path_name = "//Alice" + base_path = f"/tmp/btcli-e2e-wallet-{wallet_path_name.strip('/')}" + keypair, exec_command, wallet = setup_wallet(wallet_path_name) + + # List initial wallets + exec_command( + ListCommand, + [ + "wallet", + "list", + ], + ) + + captured = capsys.readouterr() + # Assert the default wallet is present in the display + assert "default" in captured.out + assert "└── default" in captured.out + + # Create a new wallet + exec_command( + WalletCreateCommand, + [ + "wallet", + "create", + "--wallet.name", + "new_wallet", + "--wallet.hotkey", + "new_hotkey", + "--no_password", + "--overwrite_coldkey", + "--overwrite_hotkey", + "--no_prompt", + "--wallet.path", + base_path, + ], + ) + + # List wallets again + exec_command( + ListCommand, + [ + "wallet", + "list", + ], + ) + + captured = capsys.readouterr() + + # Verify the new wallet is displayed + assert "new_wallet" in captured.out + assert "new_hotkey" in captured.out From cbc8105f660237c0204ad9c5248e7981bfb349c1 Mon Sep 17 00:00:00 2001 From: Gus Date: Wed, 7 Aug 2024 10:16:59 -0400 Subject: [PATCH 2/3] rm local_chain --- tests/e2e_tests/subcommands/wallet/test_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e_tests/subcommands/wallet/test_list.py b/tests/e2e_tests/subcommands/wallet/test_list.py index 562dc863a..1c43ecb1c 100644 --- a/tests/e2e_tests/subcommands/wallet/test_list.py +++ b/tests/e2e_tests/subcommands/wallet/test_list.py @@ -5,7 +5,7 @@ from ...utils import setup_wallet -def test_wallet_list(local_chain: subtensor, capsys): +def test_wallet_list(capsys): """ Test the listing of wallets in the Bittensor network. From bf008bdbbbce1cc850d9da106bf6f6f685919ec1 Mon Sep 17 00:00:00 2001 From: Gus Date: Wed, 7 Aug 2024 13:30:40 -0400 Subject: [PATCH 3/3] update path --- tests/e2e_tests/subcommands/wallet/test_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e_tests/subcommands/wallet/test_list.py b/tests/e2e_tests/subcommands/wallet/test_list.py index 1c43ecb1c..15f34514b 100644 --- a/tests/e2e_tests/subcommands/wallet/test_list.py +++ b/tests/e2e_tests/subcommands/wallet/test_list.py @@ -20,7 +20,7 @@ def test_wallet_list(capsys): """ wallet_path_name = "//Alice" - base_path = f"/tmp/btcli-e2e-wallet-{wallet_path_name.strip('/')}" + base_path = f"/tmp/btcli-e2e-wallet-list-{wallet_path_name.strip('/')}" keypair, exec_command, wallet = setup_wallet(wallet_path_name) # List initial wallets