Skip to content

Commit ba519d7

Browse files
committed
adds e2e test
1 parent 0710029 commit ba519d7

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

tests/e2e_tests/test_wallet_interactions.py

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,3 +510,111 @@ def test_wallet_identities(local_chain, wallet_setup):
510510
assert "Message signed successfully" in sign_using_coldkey.stdout
511511

512512
print("✅ Passed wallet set-id, get-id, sign command")
513+
514+
515+
def test_wallet_associate_hotkey(local_chain, wallet_setup):
516+
"""
517+
Test the associating hotkeys and their different cases.
518+
519+
Steps:
520+
1. Create wallets for Alice, Bob, and Charlie
521+
2. Associate a hotkey with Alice's wallet using hotkey name
522+
3. Verify the association is successful
523+
4. Try to associate Alice's hotkey with Bob's wallet (should fail)
524+
5. Try to associate Alice's hotkey again (should show already associated)
525+
6. Associate Charlie's hotkey with Bob's wallet using SS58 address
526+
527+
Raises:
528+
AssertionError: If any of the checks or verifications fail
529+
"""
530+
print("Testing wallet associate-hotkey command 🧪")
531+
532+
_, wallet_alice, wallet_path_alice, exec_command_alice = wallet_setup("//Alice")
533+
_, wallet_bob, wallet_path_bob, exec_command_bob = wallet_setup("//Bob")
534+
_, wallet_charlie, _, _ = wallet_setup("//Charlie")
535+
536+
# Associate Alice's default hotkey with her wallet
537+
result = exec_command_alice(
538+
command="wallet",
539+
sub_command="associate-hotkey",
540+
extra_args=[
541+
"--wallet-path",
542+
wallet_path_alice,
543+
"--chain",
544+
"ws://127.0.0.1:9945",
545+
"--wallet-name",
546+
wallet_alice.name,
547+
"--wallet-hotkey",
548+
wallet_alice.hotkey_str,
549+
"--no-prompt",
550+
],
551+
)
552+
553+
# Assert successful association
554+
assert "Successfully associated hotkey" in result.stdout
555+
assert wallet_alice.hotkey.ss58_address in result.stdout
556+
assert wallet_alice.coldkeypub.ss58_address in result.stdout
557+
558+
# Try to associate Alice's hotkey with Bob's wallet (should fail)
559+
result = exec_command_bob(
560+
command="wallet",
561+
sub_command="associate-hotkey",
562+
extra_args=[
563+
"--wallet-path",
564+
wallet_path_bob,
565+
"--chain",
566+
"ws://127.0.0.1:9945",
567+
"--wallet-name",
568+
wallet_bob.name,
569+
"--hotkey-ss58",
570+
wallet_alice.hotkey.ss58_address,
571+
"--no-prompt",
572+
],
573+
)
574+
575+
assert "Warning" in result.stdout
576+
assert "is already associated with" in result.stdout
577+
578+
# Try to associate Alice's hotkey again with Alice's wallet
579+
result = exec_command_alice(
580+
command="wallet",
581+
sub_command="associate-hotkey",
582+
extra_args=[
583+
"--wallet-path",
584+
wallet_path_alice,
585+
"--chain",
586+
"ws://127.0.0.1:9945",
587+
"--wallet-name",
588+
wallet_alice.name,
589+
"--wallet-hotkey",
590+
wallet_alice.hotkey_str,
591+
"--no-prompt",
592+
],
593+
)
594+
595+
assert "is already associated with" in result.stdout
596+
assert "wallet" in result.stdout
597+
assert wallet_alice.name in result.stdout
598+
599+
# Associate Charlie's hotkey with Bob's wallet using SS58 address
600+
result = exec_command_bob(
601+
command="wallet",
602+
sub_command="associate-hotkey",
603+
extra_args=[
604+
"--wallet-path",
605+
wallet_path_bob,
606+
"--chain",
607+
"ws://127.0.0.1:9945",
608+
"--wallet-name",
609+
wallet_bob.name,
610+
"--hotkey-ss58",
611+
wallet_charlie.hotkey.ss58_address,
612+
"--no-prompt",
613+
],
614+
)
615+
616+
assert "Successfully associated hotkey" in result.stdout
617+
assert wallet_charlie.hotkey.ss58_address in result.stdout
618+
assert wallet_bob.coldkeypub.ss58_address in result.stdout
619+
620+
print("✅ Passed wallet associate-hotkey command")

0 commit comments

Comments
 (0)