@@ -239,7 +239,9 @@ fn test_subtoken_enable() {
239239 } ) ;
240240}
241241
242- // cargo test --package pallet-subtensor --lib -- tests::subnet::test_subtoken_enable_reject_trading_before_enable --exact --show-output
242+ // cargo test --package pallet-subtensor --lib --
243+ // tests::subnet::test_subtoken_enable_reject_trading_before_enable --exact --show-output
244+ #[ allow( clippy:: unwrap_used) ]
243245#[ test]
244246fn test_subtoken_enable_reject_trading_before_enable ( ) {
245247 // ensure_subtoken_enabled
@@ -251,9 +253,20 @@ fn test_subtoken_enable_reject_trading_before_enable() {
251253 let hotkey_account_2_id: U256 = U256 :: from ( 3 ) ;
252254 let amount = DefaultMinStake :: < Test > :: get ( ) * 10 ;
253255
256+ let stake_bal = 10_000_000_000 ; // 10 Alpha
257+
258+ let limit_price = 1_000_000_000 ; // not important
259+
254260 add_network_disable_subtoken ( netuid, 10 , 0 ) ;
255261 add_network_disable_subtoken ( netuid2, 10 , 0 ) ;
256262
263+ assert ! ( !SubtokenEnabled :: <Test >:: get( netuid) ) ;
264+ assert ! ( !SubtokenEnabled :: <Test >:: get( netuid2) ) ;
265+
266+ // Set liq high enough to not trigger other errors
267+ SubnetTAO :: < Test > :: set ( netuid, 20_000_000_000 ) ;
268+ SubnetAlphaIn :: < Test > :: set ( netuid, 20_000_000_000 ) ;
269+
257270 // Register so staking *could* work
258271 register_ok_neuron ( netuid, hotkey_account_id, coldkey_account_id, 0 ) ;
259272 register_ok_neuron ( netuid2, hotkey_account_id, coldkey_account_id, 100 ) ;
@@ -262,6 +275,14 @@ fn test_subtoken_enable_reject_trading_before_enable() {
262275
263276 SubtensorModule :: add_balance_to_coldkey_account ( & coldkey_account_id, 10_000 ) ;
264277
278+ // Give some stake
279+ SubtensorModule :: increase_stake_for_hotkey_and_coldkey_on_subnet (
280+ & hotkey_account_id,
281+ & coldkey_account_id,
282+ netuid,
283+ stake_bal,
284+ ) ;
285+
265286 // all trading extrinsic should be rejected.
266287 assert_noop ! (
267288 SubtensorModule :: add_stake(
@@ -273,6 +294,64 @@ fn test_subtoken_enable_reject_trading_before_enable() {
273294 Error :: <Test >:: SubtokenDisabled
274295 ) ;
275296
297+ assert_noop ! (
298+ SubtensorModule :: add_stake_limit(
299+ RuntimeOrigin :: signed( coldkey_account_id) ,
300+ hotkey_account_id,
301+ netuid,
302+ amount,
303+ limit_price,
304+ false
305+ ) ,
306+ Error :: <Test >:: SubtokenDisabled
307+ ) ;
308+
309+ // For unstake_all and unstake_all_alpha, the result is Ok, but the
310+ // operation is not performed.
311+ assert_ok ! (
312+ SubtensorModule :: unstake_all(
313+ RuntimeOrigin :: signed( coldkey_account_id) ,
314+ hotkey_account_id
315+ ) ,
316+ ( )
317+ ) ;
318+ // Check that the stake is still the same
319+ assert_eq ! (
320+ SubtensorModule :: get_stake_for_hotkey_and_coldkey_on_subnet(
321+ & hotkey_account_id,
322+ & coldkey_account_id,
323+ netuid
324+ ) ,
325+ stake_bal
326+ ) ;
327+
328+ assert_ok ! (
329+ SubtensorModule :: unstake_all_alpha(
330+ RuntimeOrigin :: signed( coldkey_account_id) ,
331+ hotkey_account_id
332+ ) ,
333+ ( )
334+ ) ;
335+ // Check that the stake is still the same
336+ assert_eq ! (
337+ SubtensorModule :: get_stake_for_hotkey_and_coldkey_on_subnet(
338+ & hotkey_account_id,
339+ & coldkey_account_id,
340+ netuid
341+ ) ,
342+ stake_bal
343+ ) ;
344+
345+ SubtensorModule :: remove_stake_limit (
346+ RuntimeOrigin :: signed ( coldkey_account_id) ,
347+ hotkey_account_id,
348+ netuid,
349+ amount,
350+ limit_price,
351+ false ,
352+ )
353+ . unwrap ( ) ;
354+
276355 assert_noop ! (
277356 SubtensorModule :: remove_stake(
278357 RuntimeOrigin :: signed( coldkey_account_id) ,
0 commit comments