2
2
3
3
import pytest
4
4
5
+ from bittensor import Balance
6
+
5
7
from tests .e2e_tests .utils .chain_interactions import (
6
8
sudo_set_hyperparameter_values ,
7
9
wait_epoch ,
10
+ sudo_set_admin_utils ,
8
11
)
9
12
10
13
11
14
@pytest .mark .asyncio
15
+ @pytest .mark .parametrize ("local_chain" , [False ], indirect = True )
12
16
async def test_incentive (local_chain , subtensor , templates , alice_wallet , bob_wallet ):
13
17
"""
14
18
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
31
35
# Verify subnet <netuid> created successfully
32
36
assert subtensor .subnet_exists (netuid ), "Subnet wasn't created successfully"
33
37
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
+
34
53
# Register Bob as a neuron on the subnet
35
54
assert subtensor .burned_register (
36
55
bob_wallet , netuid
@@ -41,6 +60,27 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa
41
60
len (subtensor .neurons (netuid = netuid )) == 2
42
61
), "Alice & Bob not registered in the subnet"
43
62
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
+
44
84
# Get latest metagraph
45
85
metagraph = subtensor .metagraph (netuid )
46
86
@@ -70,11 +110,11 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa
70
110
71
111
async with templates .miner (bob_wallet , netuid ):
72
112
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
74
114
await asyncio .sleep (5 )
75
115
76
116
# Wait few epochs
77
- await wait_epoch (subtensor , netuid , times = 4 )
117
+ await wait_epoch (subtensor , netuid , times = 2 )
78
118
79
119
# Refresh metagraph
80
120
metagraph = subtensor .metagraph (netuid )
0 commit comments