Skip to content

Commit 92008e1

Browse files
authored
Merge branch 'staging' into bumps/ffi-crv3
2 parents ab07ec4 + 86f9b4d commit 92008e1

File tree

7 files changed

+43
-12
lines changed

7 files changed

+43
-12
lines changed

.github/workflows/e2e-subtensor-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090

9191
- name: Setup subtensor repo
9292
working-directory: ${{ github.workspace }}/subtensor
93-
run: git checkout testnet
93+
run: git checkout main
9494

9595
- name: Run tests
9696
run: |

bittensor/core/subtensor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from scalecodec.exceptions import RemainingScaleBytesNotEmptyException
1717
from scalecodec.type_registry import load_type_registry_preset
1818
from scalecodec.types import ScaleType
19+
from substrateinterface import Keypair
1920
from substrateinterface.base import QueryMapResult, SubstrateInterface
2021
from websockets.exceptions import InvalidStatus
2122
from websockets.sync import client as ws_client
@@ -1532,9 +1533,11 @@ def get_transfer_fee(
15321533
call_params={"dest": dest, "value": value.rao},
15331534
)
15341535

1536+
temp_keypair = Keypair(ss58_address=wallet.coldkeypub.ss58_address)
1537+
15351538
try:
15361539
payment_info = self.substrate.get_payment_info(
1537-
call=call, keypair=wallet.coldkeypub
1540+
call=call, keypair=temp_keypair
15381541
)
15391542
except Exception as e:
15401543
logging.error(f"[red]Failed to get payment info.[/red] {e}")

requirements/prod.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ scalecodec==1.2.11
2525
substrate-interface~=1.7.9
2626
uvicorn
2727
websockets>=14.1
28-
bittensor-wallet>=2.1.3
2928
bittensor-commit-reveal>=0.2.0
29+
bittensor-wallet>=3.0.0

tests/e2e_tests/test_transfer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from bittensor.core.subtensor import Subtensor
22
from bittensor.utils.balance import Balance
33
from tests.e2e_tests.utils.e2e_test_utils import setup_wallet
4+
from bittensor import logging
5+
6+
logging.set_trace()
47

58

69
def test_transfer(local_chain):

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

tests/unit_tests/test_subtensor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1739,6 +1739,8 @@ def test_get_transfer_fee(subtensor, mocker):
17391739
fake_payment_info = {"partialFee": int(2e10)}
17401740
subtensor.substrate.get_payment_info.return_value = fake_payment_info
17411741

1742+
mocker.patch.object(subtensor_module, "Keypair", return_value=mocker.MagicMock())
1743+
17421744
# Call
17431745
result = subtensor.get_transfer_fee(wallet=fake_wallet, dest=fake_dest, value=value)
17441746

@@ -1751,7 +1753,7 @@ def test_get_transfer_fee(subtensor, mocker):
17511753

17521754
subtensor.substrate.get_payment_info.assert_called_once_with(
17531755
call=subtensor.substrate.compose_call.return_value,
1754-
keypair=fake_wallet.coldkeypub,
1756+
keypair=subtensor_module.Keypair.return_value,
17551757
)
17561758

17571759
assert result == 2e10

0 commit comments

Comments
 (0)