Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallet List Command e2e test #2207

Merged
merged 5 commits into from
Aug 8, 2024
Merged
Changes from all commits
Commits
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
72 changes: 72 additions & 0 deletions tests/e2e_tests/subcommands/wallet/test_list.py
Original file line number Diff line number Diff line change
@@ -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(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-list-{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
Loading