@@ -251,11 +251,20 @@ fn test_subtoken_enable_reject_trading_before_enable() {
251251 let hotkey_account_2_id: U256 = U256 :: from ( 3 ) ;
252252 let amount = DefaultMinStake :: < Test > :: get ( ) * 10 ;
253253
254- let limit_price = 1000 ; // not important
254+ let stake_bal = 10_000_000_000 ; // 10 Alpha
255+
256+ let limit_price = 1_000_000_000 ; // not important
255257
256258 add_network_disable_subtoken ( netuid, 10 , 0 ) ;
257259 add_network_disable_subtoken ( netuid2, 10 , 0 ) ;
258260
261+ assert ! ( !SubtokenEnabled :: <Test >:: get( netuid) ) ;
262+ assert ! ( !SubtokenEnabled :: <Test >:: get( netuid2) ) ;
263+
264+ // Set liq high enough to not trigger other errors
265+ SubnetTAO :: < Test > :: set ( netuid, 20_000_000_000 ) ;
266+ SubnetAlphaIn :: < Test > :: set ( netuid, 20_000_000_000 ) ;
267+
259268 // Register so staking *could* work
260269 register_ok_neuron ( netuid, hotkey_account_id, coldkey_account_id, 0 ) ;
261270 register_ok_neuron ( netuid2, hotkey_account_id, coldkey_account_id, 100 ) ;
@@ -264,6 +273,14 @@ fn test_subtoken_enable_reject_trading_before_enable() {
264273
265274 SubtensorModule :: add_balance_to_coldkey_account ( & coldkey_account_id, 10_000 ) ;
266275
276+ // Give some stake
277+ SubtensorModule :: increase_stake_for_hotkey_and_coldkey_on_subnet (
278+ & hotkey_account_id,
279+ & coldkey_account_id,
280+ netuid,
281+ stake_bal,
282+ ) ;
283+
267284 // all trading extrinsic should be rejected.
268285 assert_noop ! (
269286 SubtensorModule :: add_stake(
@@ -287,20 +304,40 @@ fn test_subtoken_enable_reject_trading_before_enable() {
287304 Error :: <Test >:: SubtokenDisabled
288305 ) ;
289306
290- assert_noop ! (
307+ // For unstake_all and unstake_all_alpha, the result is Ok, but the
308+ // operation is not performed.
309+ assert_ok ! (
291310 SubtensorModule :: unstake_all(
292311 RuntimeOrigin :: signed( coldkey_account_id) ,
293312 hotkey_account_id
294313 ) ,
295- Error :: <Test >:: SubtokenDisabled
314+ ( )
315+ ) ;
316+ // Check that the stake is still the same
317+ assert_eq ! (
318+ SubtensorModule :: get_stake_for_hotkey_and_coldkey_on_subnet(
319+ & hotkey_account_id,
320+ & coldkey_account_id,
321+ netuid
322+ ) ,
323+ stake_bal
296324 ) ;
297325
298- assert_noop ! (
326+ assert_ok ! (
299327 SubtensorModule :: unstake_all_alpha(
300328 RuntimeOrigin :: signed( coldkey_account_id) ,
301329 hotkey_account_id
302330 ) ,
303- Error :: <Test >:: SubtokenDisabled
331+ ( )
332+ ) ;
333+ // Check that the stake is still the same
334+ assert_eq ! (
335+ SubtensorModule :: get_stake_for_hotkey_and_coldkey_on_subnet(
336+ & hotkey_account_id,
337+ & coldkey_account_id,
338+ netuid
339+ ) ,
340+ stake_bal
304341 ) ;
305342
306343 assert_noop ! (
0 commit comments