Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/e2e-subtensor-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
os:
- ubuntu-latest
test-file: ${{ fromJson(needs.find-tests.outputs.test-files) }}
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Check-out repository
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3326,7 +3326,7 @@ def wallet_set_id(
network: Optional[list[str]] = Options.network,
name: str = typer.Option(
"",
"--name",
"--id-name",
help="The display name for the identity.",
),
web_url: str = typer.Option(
Expand Down Expand Up @@ -6427,7 +6427,7 @@ def subnets_set_identity(
network: Optional[list[str]] = Options.network,
netuid: int = Options.netuid,
subnet_name: Optional[str] = typer.Option(
None, "--subnet-name", "--name", help="Name of the subnet"
None, "--subnet-name", "--sn-name", help="Name of the subnet"
),
github_repo: Optional[str] = typer.Option(
None, "--github-repo", "--repo", help="GitHub repository URL"
Expand Down
18 changes: 16 additions & 2 deletions bittensor_cli/src/commands/liquidity/liquidity.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ async def get_liquidity_list(
block_hash=block_hash,
),
)
if len(positions_response.records) == 0:
return False, "No liquidity positions found.", []

current_sqrt_price = fixed_to_float(current_sqrt_price)
fee_global_tao = fixed_to_float(fee_global_tao)
Expand Down Expand Up @@ -459,9 +461,21 @@ async def show_liquidity_list(
netuid: int,
json_output: bool = False,
) -> None:
current_price_, (success, err_msg, positions) = await asyncio.gather(
subtensor.subnet(netuid=netuid), get_liquidity_list(subtensor, wallet, netuid)
current_price_, liquidity_list_ = await asyncio.gather(
subtensor.subnet(netuid=netuid),
get_liquidity_list(subtensor, wallet, netuid),
return_exceptions=True,
)
if isinstance(current_price_, Exception):
success = False
err_msg = str(current_price_)
positions = []
elif isinstance(liquidity_list_, Exception):
success = False
err_msg = str(liquidity_list_)
positions = []
else:
(success, err_msg, positions) = liquidity_list_
if not success:
if json_output:
json_console.print(
Expand Down
7 changes: 4 additions & 3 deletions bittensor_cli/src/commands/stake/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,10 @@ async def stake_extrinsic(
success, er_msg, ext_receipt = await coroutine
successes[ni][staking_address] = success
error_messages[ni][staking_address] = er_msg
extrinsic_ids[ni][
staking_address
] = await ext_receipt.get_extrinsic_identifier()
if success:
extrinsic_ids[ni][
staking_address
] = await ext_receipt.get_extrinsic_identifier()
if json_output:
json_console.print_json(
data={
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ authors = [
]
license = { file = "LICENSE" }
scripts = { btcli = "bittensor_cli.cli:main" }
requires-python = ">=3.9,<3.14"
requires-python = ">=3.9,<3.15"
dependencies = [
"wheel",
"async-substrate-interface>=1.5.2",
Expand Down
150 changes: 121 additions & 29 deletions tests/e2e_tests/test_liquidity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import json
import re
import time

from bittensor_cli.src.bittensor.balances import Balance
from .utils import turn_off_hyperparam_freeze_window
Expand All @@ -16,25 +17,6 @@


def test_liquidity(local_chain, wallet_setup):
def liquidity_list():
return exec_command_alice(
command="liquidity",
sub_command="list",
extra_args=[
"--wallet-path",
wallet_path_alice,
"--chain",
"ws://127.0.0.1:9945",
"--wallet-name",
wallet_alice.name,
"--wallet-hotkey",
wallet_alice.hotkey_str,
"--netuid",
netuid,
"--json-output",
],
)

wallet_path_alice = "//Alice"
netuid = 2

Expand All @@ -48,6 +30,7 @@ def liquidity_list():
print(
"Skipping turning off hyperparams freeze window. This indicates the call does not exist on the chain you are testing."
)
time.sleep(10)

# Register a subnet with sudo as Alice
result = exec_command_alice(
Expand Down Expand Up @@ -88,7 +71,23 @@ def liquidity_list():
assert isinstance(result_output["extrinsic_identifier"], str)

# verify no results for list thus far (subnet not yet started)
liquidity_list_result = liquidity_list()
liquidity_list_result = exec_command_alice(
command="liquidity",
sub_command="list",
extra_args=[
"--wallet-path",
wallet_path_alice,
"--chain",
"ws://127.0.0.1:9945",
"--wallet-name",
wallet_alice.name,
"--wallet-hotkey",
wallet_alice.hotkey_str,
"--netuid",
netuid,
"--json-output",
],
)
result_output = json.loads(liquidity_list_result.stdout)
assert result_output["success"] is False
assert f"Subnet with netuid: {netuid} is not active" in result_output["err_msg"]
Expand Down Expand Up @@ -118,10 +117,51 @@ def liquidity_list():
), start_subnet_emissions.stderr
assert "Your extrinsic has been included " in start_subnet_emissions.stdout

liquidity_list_result = liquidity_list()
stake_to_enable_v3 = exec_command_alice(
command="stake",
sub_command="add",
extra_args=[
"--netuid",
"2",
"--wallet-path",
wallet_path_alice,
"--wallet-name",
wallet_alice.name,
"--hotkey",
wallet_alice.hotkey_str,
"--chain",
"ws://127.0.0.1:9945",
"--amount",
"1",
"--unsafe",
"--no-prompt",
"--era",
"144",
],
)
assert "✅ Finalized" in stake_to_enable_v3.stdout, stake_to_enable_v3.stderr
time.sleep(10)
liquidity_list_result = exec_command_alice(
command="liquidity",
sub_command="list",
extra_args=[
"--wallet-path",
wallet_path_alice,
"--chain",
"ws://127.0.0.1:9945",
"--wallet-name",
wallet_alice.name,
"--wallet-hotkey",
wallet_alice.hotkey_str,
"--netuid",
netuid,
"--json-output",
],
)
print(">>>", liquidity_list_result.stdout, liquidity_list_result.stderr)
result_output = json.loads(liquidity_list_result.stdout)
assert result_output["success"] is True
assert result_output["err_msg"] == ""
assert result_output["success"] is False
assert result_output["err_msg"] == "No liquidity positions found."
assert result_output["positions"] == []

enable_user_liquidity = exec_command_alice(
Expand Down Expand Up @@ -179,13 +219,29 @@ def liquidity_list():
assert add_liquidity_result["message"] == ""
assert isinstance(add_liquidity_result["extrinsic_identifier"], str)

liquidity_list_result = liquidity_list()
liquidity_list_result = exec_command_alice(
command="liquidity",
sub_command="list",
extra_args=[
"--wallet-path",
wallet_path_alice,
"--chain",
"ws://127.0.0.1:9945",
"--wallet-name",
wallet_alice.name,
"--wallet-hotkey",
wallet_alice.hotkey_str,
"--netuid",
netuid,
"--json-output",
],
)
print(">>>", liquidity_list_result.stdout, liquidity_list_result.stderr)
liquidity_list_result = json.loads(liquidity_list_result.stdout)
assert liquidity_list_result["success"] is True
assert len(liquidity_list_result["positions"]) == 1
liquidity_position = liquidity_list_result["positions"][0]
assert liquidity_position["liquidity"] == 1.0
assert liquidity_position["id"] == 2
assert liquidity_position["fees_tao"] == 0.0
assert liquidity_position["fees_alpha"] == 0.0
assert liquidity_position["netuid"] == netuid
Expand Down Expand Up @@ -218,10 +274,27 @@ def liquidity_list():
assert modify_liquidity_result["success"] is True
assert isinstance(modify_liquidity_result["extrinsic_identifier"], str)

liquidity_list_result = json.loads(liquidity_list().stdout)
llr = exec_command_alice(
command="liquidity",
sub_command="list",
extra_args=[
"--wallet-path",
wallet_path_alice,
"--chain",
"ws://127.0.0.1:9945",
"--wallet-name",
wallet_alice.name,
"--wallet-hotkey",
wallet_alice.hotkey_str,
"--netuid",
netuid,
"--json-output",
],
)
print(">>>", llr.stdout, llr.stderr)
liquidity_list_result = json.loads(llr.stdout)
assert len(liquidity_list_result["positions"]) == 1
liquidity_position = liquidity_list_result["positions"][0]
assert liquidity_position["id"] == 2
assert liquidity_position["liquidity"] == 21.0

removal = exec_command_alice(
Expand Down Expand Up @@ -249,6 +322,25 @@ def liquidity_list():
removal_result[str(liquidity_position["id"])]["extrinsic_identifier"], str
)

liquidity_list_result = json.loads(liquidity_list().stdout)
assert liquidity_list_result["success"] is True
liquidity_list_result = exec_command_alice(
command="liquidity",
sub_command="list",
extra_args=[
"--wallet-path",
wallet_path_alice,
"--chain",
"ws://127.0.0.1:9945",
"--wallet-name",
wallet_alice.name,
"--wallet-hotkey",
wallet_alice.hotkey_str,
"--netuid",
netuid,
"--json-output",
],
)
print(">>>", liquidity_list_result.stdout, liquidity_list_result.stderr)
liquidity_list_result = json.loads(liquidity_list_result.stdout)
assert liquidity_list_result["success"] is False
assert result_output["err_msg"] == "No liquidity positions found."
assert liquidity_list_result["positions"] == []
26 changes: 26 additions & 0 deletions tests/e2e_tests/test_staking_sudo.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,32 @@ def test_staking(local_chain, wallet_setup):
start_subnet_emissions.stdout
)

# Add initial stake to enable V3
for netuid_ in multiple_netuids:
stake_to_enable_v3 = exec_command_alice(
command="stake",
sub_command="add",
extra_args=[
"--netuid",
netuid_,
"--wallet-path",
wallet_path_alice,
"--wallet-name",
wallet_alice.name,
"--hotkey",
wallet_alice.hotkey_str,
"--chain",
"ws://127.0.0.1:9945",
"--amount",
"1",
"--unsafe",
"--no-prompt",
"--era",
"144",
],
)
assert "✅ Finalized" in stake_to_enable_v3.stdout, stake_to_enable_v3.stderr

# Add stake to Alice's hotkey
add_stake_single = exec_command_alice(
command="stake",
Expand Down
26 changes: 26 additions & 0 deletions tests/e2e_tests/test_unstaking.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,32 @@ def test_unstaking(local_chain, wallet_setup):
register_result.stdout
)

# Add initial stake to enable V3
for netuid_ in [0, 2, 3]:
stake_to_enable_v3 = exec_command_bob(
command="stake",
sub_command="add",
extra_args=[
"--netuid",
netuid_,
"--wallet-path",
wallet_path_bob,
"--wallet-name",
wallet_bob.name,
"--hotkey",
wallet_bob.hotkey_str,
"--chain",
"ws://127.0.0.1:9945",
"--amount",
"1",
"--unsafe",
"--no-prompt",
"--era",
"144",
],
)
assert "✅ Finalized" in stake_to_enable_v3.stdout, stake_to_enable_v3.stderr

# Add stake to subnets
for netuid in [0, 2, 3]:
stake_result = exec_command_bob(
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e_tests/test_wallet_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def test_wallet_identities(local_chain, wallet_setup):
wallet_alice.name,
"--wallet-hotkey",
wallet_alice.hotkey_str,
"--name",
"--id-name",
alice_identity["name"],
"--web-url",
alice_identity["url"],
Expand Down
Loading