@@ -62,119 +62,6 @@ fn test_set_weights_dispatch_info_ok() {
62
62
} ) ;
63
63
}
64
64
65
- // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::weights::test_set_rootweights_validate --exact --show-output --nocapture
66
- #[ test]
67
- fn test_set_rootweights_validate ( ) {
68
- // Testing the signed extension validate function
69
- // correctly filters this transaction.
70
-
71
- new_test_ext ( 0 ) . execute_with ( || {
72
- let dests = vec ! [ 1 , 1 ] ;
73
- let weights = vec ! [ 1 , 1 ] ;
74
- let netuid = NetUid :: from ( 1 ) ;
75
- let version_key: u64 = 0 ;
76
- let coldkey = U256 :: from ( 0 ) ;
77
- let hotkey: U256 = U256 :: from ( 1 ) ; // Add the hotkey field
78
- assert_ne ! ( hotkey, coldkey) ; // Ensure hotkey is NOT the same as coldkey !!!
79
- let fee: u64 = 0 ; // FIXME: DefaultStakingFee is deprecated
80
-
81
- let who = coldkey; // The coldkey signs this transaction
82
-
83
- let call = RuntimeCall :: SubtensorModule ( SubtensorCall :: set_tao_weights {
84
- netuid,
85
- dests,
86
- weights,
87
- version_key,
88
- hotkey, // Include the hotkey field
89
- } ) ;
90
-
91
- // Create netuid
92
- add_network ( netuid, 1 , 0 ) ;
93
- // Register the hotkey
94
- SubtensorModule :: append_neuron ( netuid, & hotkey, 0 ) ;
95
- crate :: Owner :: < Test > :: insert ( hotkey, coldkey) ;
96
-
97
- SubtensorModule :: add_balance_to_coldkey_account ( & hotkey, u64:: MAX ) ;
98
-
99
- let min_stake = TaoCurrency :: from ( 500_000_000_000 ) ;
100
- // Set the minimum stake
101
- SubtensorModule :: set_stake_threshold ( min_stake. into ( ) ) ;
102
-
103
- // Verify stake is less than minimum
104
- assert ! ( SubtensorModule :: get_total_stake_for_hotkey( & hotkey) < min_stake) ;
105
- let info: DispatchInfo =
106
- DispatchInfoOf :: < <Test as frame_system:: Config >:: RuntimeCall > :: default ( ) ;
107
-
108
- let extension = SubtensorTransactionExtension :: < Test > :: new ( ) ;
109
- // Submit to the signed extension validate function
110
- let result_no_stake = extension. validate (
111
- RawOrigin :: Signed ( who) . into ( ) ,
112
- & call. clone ( ) ,
113
- & info,
114
- 10 ,
115
- ( ) ,
116
- & TxBaseImplication ( ( ) ) ,
117
- TransactionSource :: External ,
118
- ) ;
119
- // Should fail
120
- assert_eq ! (
121
- // Should get an invalid transaction error
122
- result_no_stake. unwrap_err( ) ,
123
- CustomTransactionError :: StakeAmountTooLow . into( )
124
- ) ;
125
-
126
- // Increase the stake to be equal to the minimum
127
- assert_ok ! ( SubtensorModule :: do_add_stake(
128
- RuntimeOrigin :: signed( hotkey) ,
129
- hotkey,
130
- netuid,
131
- min_stake + fee. into( )
132
- ) ) ;
133
-
134
- // Verify stake is equal to minimum
135
- assert_eq ! (
136
- SubtensorModule :: get_total_stake_for_hotkey( & hotkey) ,
137
- min_stake
138
- ) ;
139
-
140
- // Submit to the signed extension validate function
141
- let result_min_stake = extension. validate (
142
- RawOrigin :: Signed ( who) . into ( ) ,
143
- & call. clone ( ) ,
144
- & info,
145
- 10 ,
146
- ( ) ,
147
- & TxBaseImplication ( ( ) ) ,
148
- TransactionSource :: External ,
149
- ) ;
150
- // Now the call should pass
151
- assert_ok ! ( result_min_stake) ;
152
-
153
- // Try with more stake than minimum
154
- assert_ok ! ( SubtensorModule :: do_add_stake(
155
- RuntimeOrigin :: signed( hotkey) ,
156
- hotkey,
157
- netuid,
158
- DefaultMinStake :: <Test >:: get( ) * 10 . into( )
159
- ) ) ;
160
-
161
- // Verify stake is more than minimum
162
- assert ! ( SubtensorModule :: get_total_stake_for_hotkey( & hotkey) > min_stake) ;
163
-
164
- let result_more_stake = extension. validate (
165
- RawOrigin :: Signed ( who) . into ( ) ,
166
- & call. clone ( ) ,
167
- & info,
168
- 10 ,
169
- ( ) ,
170
- & TxBaseImplication ( ( ) ) ,
171
- TransactionSource :: External ,
172
- ) ;
173
- // The call should still pass
174
- assert_ok ! ( result_more_stake) ;
175
- } ) ;
176
- }
177
-
178
65
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::weights::test_commit_weights_dispatch_info_ok --exact --show-output --nocapture
179
66
#[ test]
180
67
fn test_commit_weights_dispatch_info_ok ( ) {
0 commit comments