Skip to content

Commit 6c9d6a5

Browse files
committed
Updates tests for btwallet 3.0.0
1 parent a34920f commit 6c9d6a5

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

requirements/prod.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ scalecodec==1.2.11
2424
substrate-interface~=1.7.9
2525
uvicorn
2626
websockets>=14.1
27-
bittensor-wallet>=2.1.3
27+
bittensor-wallet>=3.0.0
2828
bittensor-commit-reveal>=0.1.0

tests/integration_tests/utils/test_init.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,51 @@
77
from bittensor import utils
88

99

10-
def test_unlock_key(monkeypatch):
10+
def test_unlock_through_env():
1111
# Ensure path is clean before we run the tests
12-
if os.path.exists("/tmp/bittensor-tests-wallets"):
12+
if os.path.exists("/tmp/bittensor-tests-wallets/"):
1313
shutil.rmtree("/tmp/bittensor-tests-wallets")
1414

1515
wallet = Wallet(path="/tmp/bittensor-tests-wallets")
16+
17+
# Set up the coldkey
1618
cold_kf = Keyfile("/tmp/bittensor-tests-wallets/default/coldkey", name="default")
1719
kp = Keypair.create_from_mnemonic(
1820
"stool feel open east woman high can denial forget screen trust salt"
1921
)
2022
cold_kf.set_keypair(kp, False, False)
2123
cold_kf.encrypt("1234password1234")
22-
hot_kf = Keyfile("/tmp/bittensor-tests-wallets/default/hotkey", name="default")
24+
25+
# Set up the hotkey
26+
hot_kf = Keyfile(
27+
"/tmp/bittensor-tests-wallets/default/hotkeys/default", name="default"
28+
)
2329
hkp = Keypair.create_from_mnemonic(
2430
"stool feel open east woman high can denial forget screen trust salt"
2531
)
2632
hot_kf.set_keypair(hkp, False, False)
2733
hot_kf.encrypt("1234hotkey1234")
28-
monkeypatch.setattr("getpass.getpass", lambda _: "badpassword1234")
34+
35+
# Save a wrong password to the environment for CK
36+
cold_kf.save_password_to_env("badpassword")
2937
result = utils.unlock_key(wallet)
3038
assert result.success is False
31-
monkeypatch.setattr("getpass.getpass", lambda _: "1234password1234")
39+
40+
# Save correct password to the environment for CK
41+
cold_kf.save_password_to_env("1234password1234")
3242
result = utils.unlock_key(wallet)
3343
assert result.success is True
34-
monkeypatch.setattr("getpass.getpass", lambda _: "badpassword1234")
44+
45+
# Save a wrong password to the environment for HK
46+
hot_kf.save_password_to_env("badpassword")
3547
result = utils.unlock_key(wallet, "hotkey")
3648
assert result.success is False
49+
50+
# Save correct password to the environment for HK
51+
hot_kf.save_password_to_env("1234hotkey1234")
52+
result = utils.unlock_key(wallet, "hotkey")
53+
assert result.success is True
54+
3755
with pytest.raises(ValueError):
3856
utils.unlock_key(wallet, "mycoldkey")
3957

tests/unit_tests/test_config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ def test_py_config_parsed_successfully_rust_wallet():
1919
config.wallet.hotkey = "new_hotkey"
2020
config.wallet.path = "/some/not_default/path"
2121

22+
# Pass in the whole bittensor config
2223
wallet = bittensor.wallet(config=config)
23-
24-
# Asserts
2524
assert wallet.name == config.wallet.name
2625
assert wallet.hotkey_str == config.wallet.hotkey
2726
assert wallet.path == config.wallet.path
27+
28+
# Pass in only the btwallet's config
29+
wallet_two = bittensor.wallet(config=config.wallet)
30+
assert wallet_two.name == config.wallet.name
31+
assert wallet_two.hotkey_str == config.wallet.hotkey
32+
assert wallet_two.path == config.wallet.path

0 commit comments

Comments
 (0)