@@ -2969,71 +2969,6 @@ fn test_migrate_remove_unknown_neuron_axon_cert_prom() {
29692969}
29702970
29712971#[ test]
2972- fn test_migrate_reset_coldkey_for_root_claim ( ) {
2973- new_test_ext ( 1 ) . execute_with ( || {
2974- const MIGRATION_NAME : & [ u8 ] = b"migrate_reset_coldkey_for_root_claim" ;
2975-
2976- // Step 1: Set up initial state - put a value in AlphaMapLastKey
2977- let test_key: Option < Vec < u8 > > = Some ( vec ! [ 1 , 2 , 3 , 4 , 5 ] ) ;
2978- AlphaMapLastKey :: < Test > :: put ( test_key. clone ( ) ) ;
2979-
2980- // Verify the value was set
2981- assert_eq ! (
2982- AlphaMapLastKey :: <Test >:: get( ) ,
2983- test_key,
2984- "AlphaMapLastKey should have the test value."
2985- ) ;
2986-
2987- // Step 2: Verify migration hasn't run yet
2988- assert ! (
2989- !HasMigrationRun :: <Test >:: get( MIGRATION_NAME . to_vec( ) ) ,
2990- "Migration should not have run yet."
2991- ) ;
2992-
2993- // Step 3: Run the migration
2994- let weight = crate :: migrations:: migrate_reset_coldkey_for_root_claim:: migrate_reset_coldkey_for_root_claim :: < Test > ( ) ;
2995-
2996- // Step 4: Verify AlphaMapLastKey was killed (reset to default None)
2997- assert_eq ! (
2998- AlphaMapLastKey :: <Test >:: get( ) ,
2999- None ,
3000- "AlphaMapLastKey should be reset to None after migration."
3001- ) ;
3002-
3003- // Step 5: Verify migration is marked as completed
3004- assert ! (
3005- HasMigrationRun :: <Test >:: get( MIGRATION_NAME . to_vec( ) ) ,
3006- "Migration should be marked as run."
3007- ) ;
3008-
3009- // Step 6: Verify weight is non-zero
3010- assert ! (
3011- !weight. is_zero( ) ,
3012- "Migration weight should be non-zero."
3013- ) ;
3014-
3015- // Step 7: Run migration again - should be idempotent
3016- // Set the value again to verify migration doesn't run twice
3017- let test_key_2: Option < Vec < u8 > > = Some ( vec ! [ 6 , 7 , 8 , 9 , 10 ] ) ;
3018- AlphaMapLastKey :: < Test > :: put ( test_key_2. clone ( ) ) ;
3019-
3020- let weight_second_run = crate :: migrations:: migrate_reset_coldkey_for_root_claim:: migrate_reset_coldkey_for_root_claim :: < Test > ( ) ;
3021-
3022- // Value should NOT be reset since migration already ran
3023- assert_eq ! (
3024- AlphaMapLastKey :: <Test >:: get( ) ,
3025- test_key_2,
3026- "AlphaMapLastKey should not be changed on second migration run."
3027- ) ;
3028-
3029- // Second run should only have read weight (checking if migration ran)
3030- assert_eq ! (
3031- weight_second_run,
3032- <Test as frame_system:: Config >:: DbWeight :: get( ) . reads( 1 ) ,
3033- "Second migration run should only have read weight."
3034- ) ;
3035- } ) ;
3036- }
30372972fn test_migrate_coldkey_swap_scheduled_to_announcements ( ) {
30382973 new_test_ext ( 1000 ) . execute_with ( || {
30392974 const MIGRATION_NAME : & [ u8 ] = b"migrate_coldkey_swap_scheduled_to_announcements" ;
@@ -3104,3 +3039,70 @@ fn test_migrate_coldkey_swap_scheduled_to_announcements() {
31043039 ) ;
31053040 } ) ;
31063041}
3042+
3043+ #[ test]
3044+ fn test_migrate_reset_coldkey_for_root_claim ( ) {
3045+ new_test_ext ( 1 ) . execute_with ( || {
3046+ const MIGRATION_NAME : & [ u8 ] = b"migrate_reset_coldkey_for_root_claim" ;
3047+
3048+ // Step 1: Set up initial state - put a value in AlphaMapLastKey
3049+ let test_key: Option < Vec < u8 > > = Some ( vec ! [ 1 , 2 , 3 , 4 , 5 ] ) ;
3050+ AlphaMapLastKey :: < Test > :: put ( test_key. clone ( ) ) ;
3051+
3052+ // Verify the value was set
3053+ assert_eq ! (
3054+ AlphaMapLastKey :: <Test >:: get( ) ,
3055+ test_key,
3056+ "AlphaMapLastKey should have the test value."
3057+ ) ;
3058+
3059+ // Step 2: Verify migration hasn't run yet
3060+ assert ! (
3061+ !HasMigrationRun :: <Test >:: get( MIGRATION_NAME . to_vec( ) ) ,
3062+ "Migration should not have run yet."
3063+ ) ;
3064+
3065+ // Step 3: Run the migration
3066+ let weight = crate :: migrations:: migrate_reset_coldkey_for_root_claim:: migrate_reset_coldkey_for_root_claim :: < Test > ( ) ;
3067+
3068+ // Step 4: Verify AlphaMapLastKey was killed (reset to default None)
3069+ assert_eq ! (
3070+ AlphaMapLastKey :: <Test >:: get( ) ,
3071+ None ,
3072+ "AlphaMapLastKey should be reset to None after migration."
3073+ ) ;
3074+
3075+ // Step 5: Verify migration is marked as completed
3076+ assert ! (
3077+ HasMigrationRun :: <Test >:: get( MIGRATION_NAME . to_vec( ) ) ,
3078+ "Migration should be marked as run."
3079+ ) ;
3080+
3081+ // Step 6: Verify weight is non-zero
3082+ assert ! (
3083+ !weight. is_zero( ) ,
3084+ "Migration weight should be non-zero."
3085+ ) ;
3086+
3087+ // Step 7: Run migration again - should be idempotent
3088+ // Set the value again to verify migration doesn't run twice
3089+ let test_key_2: Option < Vec < u8 > > = Some ( vec ! [ 6 , 7 , 8 , 9 , 10 ] ) ;
3090+ AlphaMapLastKey :: < Test > :: put ( test_key_2. clone ( ) ) ;
3091+
3092+ let weight_second_run = crate :: migrations:: migrate_reset_coldkey_for_root_claim:: migrate_reset_coldkey_for_root_claim :: < Test > ( ) ;
3093+
3094+ // Value should NOT be reset since migration already ran
3095+ assert_eq ! (
3096+ AlphaMapLastKey :: <Test >:: get( ) ,
3097+ test_key_2,
3098+ "AlphaMapLastKey should not be changed on second migration run."
3099+ ) ;
3100+
3101+ // Second run should only have read weight (checking if migration ran)
3102+ assert_eq ! (
3103+ weight_second_run,
3104+ <Test as frame_system:: Config >:: DbWeight :: get( ) . reads( 1 ) ,
3105+ "Second migration run should only have read weight."
3106+ ) ;
3107+ } ) ;
3108+ }
0 commit comments