Skip to content

Commit 4ebd90d

Browse files
fix: pass e2e with devnet-ready
1 parent da63e51 commit 4ebd90d

File tree

5 files changed

+59
-18
lines changed

5 files changed

+59
-18
lines changed

tests/e2e_tests/test_commitment.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import pytest
2+
from async_substrate_interface.errors import SubstrateRequestException
23

34
from bittensor import logging
4-
from async_substrate_interface.errors import SubstrateRequestException
5+
from tests.e2e_tests.utils.chain_interactions import sudo_set_admin_utils
56

67
logging.set_trace()
78

89

9-
def test_commitment(subtensor, alice_wallet):
10+
def test_commitment(local_chain, subtensor, alice_wallet):
1011
with pytest.raises(SubstrateRequestException, match="AccountNotAllowedCommit"):
1112
subtensor.set_commitment(
1213
alice_wallet,
@@ -37,14 +38,27 @@ def test_commitment(subtensor, alice_wallet):
3738
data="Hello World!",
3839
)
3940

41+
status, error = sudo_set_admin_utils(
42+
local_chain,
43+
alice_wallet,
44+
call_module="Commitments",
45+
call_function="set_max_space",
46+
call_params={
47+
"netuid": 1,
48+
"new_limit": len("Hello World!"),
49+
},
50+
)
51+
52+
assert status is True, error
53+
4054
with pytest.raises(
4155
SubstrateRequestException,
42-
match="CommitmentSetRateLimitExceeded",
56+
match="SpaceLimitExceeded",
4357
):
4458
subtensor.set_commitment(
4559
alice_wallet,
4660
netuid=1,
47-
data="Hello World!",
61+
data="Hello World!1",
4862
)
4963

5064
assert "Hello World!" == subtensor.get_commitment(
@@ -59,7 +73,7 @@ def test_commitment(subtensor, alice_wallet):
5973

6074

6175
@pytest.mark.asyncio
62-
async def test_commitment_async(async_subtensor, alice_wallet):
76+
async def test_commitment_async(local_chain, async_subtensor, alice_wallet):
6377
async with async_subtensor as sub:
6478
with pytest.raises(SubstrateRequestException, match="AccountNotAllowedCommit"):
6579
await sub.set_commitment(
@@ -91,14 +105,27 @@ async def test_commitment_async(async_subtensor, alice_wallet):
91105
data="Hello World!",
92106
)
93107

108+
status, error = sudo_set_admin_utils(
109+
local_chain,
110+
alice_wallet,
111+
call_module="Commitments",
112+
call_function="set_max_space",
113+
call_params={
114+
"netuid": 1,
115+
"new_limit": len("Hello World!"),
116+
},
117+
)
118+
119+
assert status is True, error
120+
94121
with pytest.raises(
95122
SubstrateRequestException,
96-
match="CommitmentSetRateLimitExceeded",
123+
match="SpaceLimitExceeded",
97124
):
98125
await sub.set_commitment(
99126
alice_wallet,
100127
netuid=1,
101-
data="Hello World!",
128+
data="Hello World!1",
102129
)
103130

104131
assert "Hello World!" == await sub.get_commitment(

tests/e2e_tests/test_incentive.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
import pytest
44

55
from tests.e2e_tests.utils.chain_interactions import (
6+
root_set_subtensor_hyperparameter_values,
67
sudo_set_admin_utils,
78
wait_epoch,
89
wait_interval,
910
)
1011

12+
DURATION_OF_START_CALL = 10
13+
1114

1215
@pytest.mark.asyncio
1316
async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wallet):
@@ -53,7 +56,7 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa
5356

5457
assert alice_neuron.validator_permit is True
5558
assert alice_neuron.dividends == 0
56-
assert alice_neuron.stake.tao > 0
59+
assert alice_neuron.stake.tao == 0
5760
assert alice_neuron.validator_trust == 0
5861
assert alice_neuron.incentive == 0
5962
assert alice_neuron.consensus == 0
@@ -66,6 +69,20 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa
6669
assert bob_neuron.rank == 0
6770
assert bob_neuron.trust == 0
6871

72+
subtensor.wait_for_block(DURATION_OF_START_CALL)
73+
74+
# Subnet "Start Call" https://github.com/opentensor/bits/pull/13
75+
status, error = await root_set_subtensor_hyperparameter_values(
76+
local_chain,
77+
alice_wallet,
78+
call_function="start_call",
79+
call_params={
80+
"netuid": netuid,
81+
},
82+
)
83+
84+
assert status is True, error
85+
6986
# update weights_set_rate_limit for fast-blocks
7087
tempo = subtensor.tempo(netuid)
7188
status, error = sudo_set_admin_utils(

tests/e2e_tests/test_metagraph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ def test_metagraph_info(subtensor, alice_wallet):
202202
blocks_since_last_step=1,
203203
subnet_emission=Balance(0),
204204
alpha_in=Balance.from_tao(10),
205-
alpha_out=Balance.from_tao(2),
205+
alpha_out=Balance.from_tao(1),
206206
tao_in=Balance.from_tao(10),
207-
alpha_out_emission=Balance.from_tao(1),
207+
alpha_out_emission=Balance(0),
208208
alpha_in_emission=Balance(0),
209209
tao_in_emission=Balance(0),
210-
pending_alpha_emission=Balance.from_tao(0.820004577),
210+
pending_alpha_emission=Balance(0),
211211
pending_root_emission=Balance(0),
212212
subnet_volume=Balance(0),
213213
moving_price=Balance(0),

tests/e2e_tests/test_staking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_single_operation(subtensor, alice_wallet, bob_wallet):
4040
alice_wallet,
4141
bob_wallet.hotkey.ss58_address,
4242
netuid=1,
43-
amount=Balance.from_tao(10_000),
43+
amount=Balance.from_tao(1),
4444
wait_for_inclusion=True,
4545
wait_for_finalization=True,
4646
)

tests/e2e_tests/utils/chain_interactions.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def sudo_set_admin_utils(
181181
wallet: "Wallet",
182182
call_function: str,
183183
call_params: dict,
184+
call_module: str = "AdminUtils",
184185
) -> tuple[bool, Optional[dict]]:
185186
"""
186187
Wraps the call in sudo to set hyperparameter values using AdminUtils.
@@ -195,7 +196,7 @@ def sudo_set_admin_utils(
195196
tuple[bool, Optional[dict]]: (success status, error details).
196197
"""
197198
inner_call = substrate.compose_call(
198-
call_module="AdminUtils",
199+
call_module=call_module,
199200
call_function=call_function,
200201
call_params=call_params,
201202
)
@@ -222,7 +223,6 @@ async def root_set_subtensor_hyperparameter_values(
222223
wallet: "Wallet",
223224
call_function: str,
224225
call_params: dict,
225-
return_error_message: bool = False,
226226
) -> tuple[bool, str]:
227227
"""
228228
Sets liquid alpha values using AdminUtils. Mimics setting hyperparams
@@ -240,10 +240,7 @@ async def root_set_subtensor_hyperparameter_values(
240240
wait_for_finalization=True,
241241
)
242242

243-
if return_error_message:
244-
return response.is_success, response.error_message
245-
246-
return response.is_success, ""
243+
return response.is_success, response.error_message
247244

248245

249246
def set_identity(

0 commit comments

Comments
 (0)