Skip to content

Commit 90107ee

Browse files
Merge pull request #2722 from opentensor/fix/test-incentive
Updates test_incentive
2 parents ef7da10 + f079819 commit 90107ee

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

tests/e2e_tests/test_incentive.py

+42-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
import pytest
44

5+
from bittensor import Balance
6+
57
from tests.e2e_tests.utils.chain_interactions import (
68
sudo_set_hyperparameter_values,
79
wait_epoch,
10+
sudo_set_admin_utils,
811
)
912

1013

1114
@pytest.mark.asyncio
15+
@pytest.mark.parametrize("local_chain", [False], indirect=True)
1216
async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wallet):
1317
"""
1418
Test the incentive mechanism and interaction of miners/validators
@@ -31,6 +35,21 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa
3135
# Verify subnet <netuid> created successfully
3236
assert subtensor.subnet_exists(netuid), "Subnet wasn't created successfully"
3337

38+
# Change tempo to 10
39+
tempo_set = 10
40+
assert (
41+
sudo_set_admin_utils(
42+
local_chain,
43+
alice_wallet,
44+
call_function="sudo_set_tempo",
45+
call_params={"netuid": netuid, "tempo": tempo_set},
46+
return_error_message=True,
47+
)[0]
48+
is True
49+
)
50+
tempo = subtensor.get_subnet_hyperparameters(netuid=netuid).tempo
51+
assert tempo_set == tempo
52+
3453
# Register Bob as a neuron on the subnet
3554
assert subtensor.burned_register(
3655
bob_wallet, netuid
@@ -41,6 +60,27 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa
4160
len(subtensor.neurons(netuid=netuid)) == 2
4261
), "Alice & Bob not registered in the subnet"
4362

63+
# Add stake for Alice
64+
assert subtensor.add_stake(
65+
alice_wallet,
66+
netuid=netuid,
67+
amount=Balance.from_tao(1_000),
68+
wait_for_inclusion=True,
69+
wait_for_finalization=True,
70+
), "Failed to add stake for Alice"
71+
72+
# Wait for the first epoch to pass
73+
await wait_epoch(subtensor, netuid)
74+
75+
# Add further stake so validator permit is activated
76+
assert subtensor.add_stake(
77+
alice_wallet,
78+
netuid=netuid,
79+
amount=Balance.from_tao(1_000),
80+
wait_for_inclusion=True,
81+
wait_for_finalization=True,
82+
), "Failed to add stake for Alice"
83+
4484
# Get latest metagraph
4585
metagraph = subtensor.metagraph(netuid)
4686

@@ -70,11 +110,11 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa
70110

71111
async with templates.miner(bob_wallet, netuid):
72112
async with templates.validator(alice_wallet, netuid):
73-
# wait for the Validator to process and set_weights
113+
# Wait for the Validator to process and set_weights
74114
await asyncio.sleep(5)
75115

76116
# Wait few epochs
77-
await wait_epoch(subtensor, netuid, times=4)
117+
await wait_epoch(subtensor, netuid, times=2)
78118

79119
# Refresh metagraph
80120
metagraph = subtensor.metagraph(netuid)

0 commit comments

Comments
 (0)