1
1
#![ allow( unused, clippy:: indexing_slicing, clippy:: panic, clippy:: unwrap_used) ]
2
2
3
+ use super :: mock:: * ;
4
+ use crate :: * ;
3
5
use codec:: { Decode , Encode } ;
4
6
use frame_support:: {
5
7
assert_ok,
@@ -9,8 +11,6 @@ use frame_support::{
9
11
StorageHasher , Twox64Concat ,
10
12
} ;
11
13
use frame_system:: Config ;
12
- use super :: mock:: * ;
13
- use crate :: * ;
14
14
use sp_core:: { crypto:: Ss58Codec , H256 , U256 } ;
15
15
use sp_io:: hashing:: twox_128;
16
16
use sp_runtime:: traits:: Zero ;
@@ -99,7 +99,8 @@ fn test_migration_fix_total_stake_maps() {
99
99
assert_ne ! ( SubtensorModule :: get_total_stake( ) , total_stake_amount) ;
100
100
101
101
// Run the migration to fix the total stake maps
102
- crate :: migrations:: migrate_to_v2_fixed_total_stake:: migrate_to_v2_fixed_total_stake :: < Test > ( ) ;
102
+ crate :: migrations:: migrate_to_v2_fixed_total_stake:: migrate_to_v2_fixed_total_stake :: < Test > (
103
+ ) ;
103
104
104
105
// Verify that the total stake is now correct
105
106
assert_eq ! ( SubtensorModule :: get_total_stake( ) , total_stake_amount) ;
@@ -126,14 +127,8 @@ fn test_migration_fix_total_stake_maps() {
126
127
127
128
// Verify that the Stake map has no extra entries
128
129
assert_eq ! ( crate :: Stake :: <Test >:: iter( ) . count( ) , 4 ) ; // 4 entries total
129
- assert_eq ! (
130
- crate :: Stake :: <Test >:: iter_key_prefix( hk1) . count( ) ,
131
- 2
132
- ) ; // 2 stake entries for hk1
133
- assert_eq ! (
134
- crate :: Stake :: <Test >:: iter_key_prefix( hk2) . count( ) ,
135
- 2
136
- ) ; // 2 stake entries for hk2
130
+ assert_eq ! ( crate :: Stake :: <Test >:: iter_key_prefix( hk1) . count( ) , 2 ) ; // 2 stake entries for hk1
131
+ assert_eq ! ( crate :: Stake :: <Test >:: iter_key_prefix( hk2) . count( ) , 2 ) ; // 2 stake entries for hk2
137
132
} )
138
133
}
139
134
@@ -322,7 +317,9 @@ fn test_migrate_fix_total_coldkey_stake() {
322
317
Stake :: < Test > :: insert ( U256 :: from ( 1 ) , U256 :: from ( 0 ) , 10000 ) ;
323
318
Stake :: < Test > :: insert ( U256 :: from ( 2 ) , U256 :: from ( 0 ) , 10000 ) ;
324
319
Stake :: < Test > :: insert ( U256 :: from ( 3 ) , U256 :: from ( 0 ) , 10000 ) ;
325
- crate :: migrations:: migrate_fix_total_coldkey_stake:: do_migrate_fix_total_coldkey_stake :: < Test > ( ) ;
320
+ crate :: migrations:: migrate_fix_total_coldkey_stake:: do_migrate_fix_total_coldkey_stake :: <
321
+ Test ,
322
+ > ( ) ;
326
323
assert_eq ! ( TotalColdkeyStake :: <Test >:: get( coldkey) , 30000 ) ;
327
324
} )
328
325
}
@@ -338,7 +335,9 @@ fn test_migrate_fix_total_coldkey_stake_value_already_in_total() {
338
335
Stake :: < Test > :: insert ( U256 :: from ( 1 ) , U256 :: from ( 0 ) , 10000 ) ;
339
336
Stake :: < Test > :: insert ( U256 :: from ( 2 ) , U256 :: from ( 0 ) , 10000 ) ;
340
337
Stake :: < Test > :: insert ( U256 :: from ( 3 ) , U256 :: from ( 0 ) , 10000 ) ;
341
- crate :: migrations:: migrate_fix_total_coldkey_stake:: do_migrate_fix_total_coldkey_stake :: < Test > ( ) ;
338
+ crate :: migrations:: migrate_fix_total_coldkey_stake:: do_migrate_fix_total_coldkey_stake :: <
339
+ Test ,
340
+ > ( ) ;
342
341
assert_eq ! ( TotalColdkeyStake :: <Test >:: get( coldkey) , 30000 ) ;
343
342
} )
344
343
}
@@ -353,7 +352,9 @@ fn test_migrate_fix_total_coldkey_stake_no_entry() {
353
352
Stake :: < Test > :: insert ( U256 :: from ( 1 ) , U256 :: from ( 0 ) , 10000 ) ;
354
353
Stake :: < Test > :: insert ( U256 :: from ( 2 ) , U256 :: from ( 0 ) , 10000 ) ;
355
354
Stake :: < Test > :: insert ( U256 :: from ( 3 ) , U256 :: from ( 0 ) , 10000 ) ;
356
- crate :: migrations:: migrate_fix_total_coldkey_stake:: do_migrate_fix_total_coldkey_stake :: < Test > ( ) ;
355
+ crate :: migrations:: migrate_fix_total_coldkey_stake:: do_migrate_fix_total_coldkey_stake :: <
356
+ Test ,
357
+ > ( ) ;
357
358
assert_eq ! ( TotalColdkeyStake :: <Test >:: get( coldkey) , 30000 ) ;
358
359
} )
359
360
}
@@ -366,7 +367,9 @@ fn test_migrate_fix_total_coldkey_stake_no_entry_in_hotkeys() {
366
367
let coldkey = U256 :: from ( 0 ) ;
367
368
TotalColdkeyStake :: < Test > :: insert ( coldkey, 100000000 ) ;
368
369
StakingHotkeys :: < Test > :: insert ( coldkey, vec ! [ U256 :: from( 1 ) , U256 :: from( 2 ) , U256 :: from( 3 ) ] ) ;
369
- crate :: migrations:: migrate_fix_total_coldkey_stake:: do_migrate_fix_total_coldkey_stake :: < Test > ( ) ;
370
+ crate :: migrations:: migrate_fix_total_coldkey_stake:: do_migrate_fix_total_coldkey_stake :: <
371
+ Test ,
372
+ > ( ) ;
370
373
assert_eq ! ( TotalColdkeyStake :: <Test >:: get( coldkey) , 0 ) ;
371
374
} )
372
375
}
@@ -381,7 +384,9 @@ fn test_migrate_fix_total_coldkey_stake_one_hotkey_stake_missing() {
381
384
StakingHotkeys :: < Test > :: insert ( coldkey, vec ! [ U256 :: from( 1 ) , U256 :: from( 2 ) , U256 :: from( 3 ) ] ) ;
382
385
Stake :: < Test > :: insert ( U256 :: from ( 1 ) , U256 :: from ( 0 ) , 10000 ) ;
383
386
Stake :: < Test > :: insert ( U256 :: from ( 2 ) , U256 :: from ( 0 ) , 10000 ) ;
384
- crate :: migrations:: migrate_fix_total_coldkey_stake:: do_migrate_fix_total_coldkey_stake :: < Test > ( ) ;
387
+ crate :: migrations:: migrate_fix_total_coldkey_stake:: do_migrate_fix_total_coldkey_stake :: <
388
+ Test ,
389
+ > ( ) ;
385
390
assert_eq ! ( TotalColdkeyStake :: <Test >:: get( coldkey) , 20000 ) ;
386
391
} )
387
392
}
@@ -430,7 +435,9 @@ fn test_migrate_fix_total_coldkey_stake_starts_with_value_no_stake_map_entries()
430
435
431
436
fn run_migration_and_check ( migration_name : & ' static str ) -> frame_support:: weights:: Weight {
432
437
// Execute the migration and store its weight
433
- let weight: frame_support:: weights:: Weight = crate :: migrations:: migrate_fix_total_coldkey_stake:: migrate_fix_total_coldkey_stake :: < Test > ( ) ;
438
+ let weight: frame_support:: weights:: Weight =
439
+ crate :: migrations:: migrate_fix_total_coldkey_stake:: migrate_fix_total_coldkey_stake :: < Test > (
440
+ ) ;
434
441
435
442
// Check if the migration has been marked as completed
436
443
assert ! ( HasMigrationRun :: <Test >:: get(
@@ -502,9 +509,7 @@ fn test_migrate_commit_reveal_2() {
502
509
// ------------------------------
503
510
// Step 2: Run the Migration
504
511
// ------------------------------
505
- let weight =
506
- crate :: migrations:: migrate_commit_reveal_v2:: migrate_commit_reveal_2 :: < Test > (
507
- ) ;
512
+ let weight = crate :: migrations:: migrate_commit_reveal_v2:: migrate_commit_reveal_2 :: < Test > ( ) ;
508
513
509
514
assert ! (
510
515
HasMigrationRun :: <Test >:: get( MIGRATION_NAME . as_bytes( ) . to_vec( ) ) ,
0 commit comments