@@ -1816,104 +1816,102 @@ fn test_migrate_network_lock_reduction_interval_and_decay() {
18161816}
18171817
18181818#[ test]
1819- fn test_migrate_restore_subnet_locked_feb1_2025 ( ) {
1820- use sp_runtime:: traits:: SaturatedConversion ; // only for NetUid -> u16 when reading back
1821- use std:: collections:: BTreeMap ;
1822-
1823- use crate :: { HasMigrationRun , SubnetLocked , TaoCurrency } ;
1824-
1825- // NOTE: Ensure the migration uses `TaoCurrency::from(rao_u64)` and a `&[(u16, u64)]` snapshot.
1819+ fn test_migrate_restore_subnet_locked_65_128 ( ) {
1820+ use sp_runtime:: traits:: SaturatedConversion ;
18261821 new_test_ext ( 0 ) . execute_with ( || {
1827- // ── pre ──────────────────────────────────────────────────────────────
18281822 let name = b"migrate_restore_subnet_locked" . to_vec ( ) ;
18291823 assert ! (
18301824 !HasMigrationRun :: <Test >:: get( name. clone( ) ) ,
18311825 "HasMigrationRun should be false before migration"
18321826 ) ;
18331827
1834- // Snapshot at block #4_828_623 (2025-02-01 00:00:00Z), RAO as u64 .
1828+ // Expected snapshot for netuids 65..128 .
18351829 const EXPECTED : & [ ( u16 , u64 ) ] = & [
1836- ( 2 , 976_893_069_056 ) ,
1837- ( 3 , 2_569_362_397_490 ) ,
1838- ( 4 , 1_928_551_593_932 ) ,
1839- ( 5 , 1_712_540_082_588 ) ,
1840- ( 6 , 1_495_929_556_770 ) ,
1841- ( 7 , 1_011_702_451_936 ) ,
1842- ( 8 , 337_484_391_024 ) ,
1843- ( 9 , 381_240_180_320 ) ,
1844- ( 10 , 1_253_515_128_353 ) ,
1845- ( 11 , 1_453_924_672_132 ) ,
1846- ( 12 , 100_000_000_000 ) ,
1847- ( 13 , 100_000_000_000 ) ,
1848- ( 14 , 1_489_714_521_808 ) ,
1849- ( 15 , 1_784_089_225_496 ) ,
1850- ( 16 , 889_176_219_484 ) ,
1851- ( 17 , 1_266_310_122_772 ) ,
1852- ( 18 , 222_355_058_433 ) ,
1853- ( 19 , 100_000_000_000 ) ,
1854- ( 20 , 100_000_000_000 ) ,
1855- ( 21 , 885_096_322_978 ) ,
1856- ( 22 , 100_000_000_000 ) ,
1857- ( 23 , 100_000_000_000 ) ,
1858- ( 24 , 5_146_073_854_481 ) ,
1859- ( 25 , 1_782_920_948_214 ) ,
1860- ( 26 , 153_583_865_248 ) ,
1861- ( 27 , 201_344_183_084 ) ,
1862- ( 28 , 901_455_879_445 ) ,
1863- ( 29 , 175_000_001_600 ) ,
1864- ( 30 , 1_419_730_660_074 ) ,
1865- ( 31 , 319_410_100_502 ) ,
1866- ( 32 , 2_016_397_028_246 ) ,
1867- ( 33 , 1_626_477_274_174 ) ,
1868- ( 34 , 1_455_297_496_345 ) ,
1869- ( 35 , 1_191_275_979_639 ) ,
1870- ( 36 , 1_097_008_574_216 ) ,
1871- ( 37 , 864_664_455_362 ) ,
1872- ( 38 , 1_001_936_494_076 ) ,
1873- ( 39 , 1_366_096_404_884 ) ,
1874- ( 40 , 100_000_000_000 ) ,
1875- ( 41 , 535_937_523_200 ) ,
1876- ( 42 , 1_215_698_423_344 ) ,
1877- ( 43 , 1_641_308_676_800 ) ,
1878- ( 44 , 1_514_636_189_434 ) ,
1879- ( 45 , 1_605_608_381_438 ) ,
1880- ( 46 , 1_095_943_027_350 ) ,
1881- ( 47 , 1_499_235_469_986 ) ,
1882- ( 48 , 1_308_073_720_362 ) ,
1883- ( 49 , 1_222_672_092_068 ) ,
1884- ( 50 , 2_628_355_421_561 ) ,
1885- ( 51 , 1_520_860_720_561 ) ,
1886- ( 52 , 1_794_457_248_725 ) ,
1887- ( 53 , 1_721_472_811_492 ) ,
1888- ( 54 , 2_048_900_691_868 ) ,
1889- ( 55 , 1_278_597_446_119 ) ,
1890- ( 56 , 2_016_045_544_480 ) ,
1891- ( 57 , 1_920_563_399_676 ) ,
1892- ( 58 , 2_246_525_691_504 ) ,
1893- ( 59 , 1_776_159_384_888 ) ,
1894- ( 60 , 2_173_138_865_414 ) ,
1895- ( 61 , 1_435_634_867_728 ) ,
1896- ( 62 , 2_061_282_563_888 ) ,
1897- ( 63 , 3_008_967_320_998 ) ,
1898- ( 64 , 2_099_236_359_026 ) ,
1830+ ( 65 , 37_274_536_408 ) ,
1831+ ( 66 , 65_230_444_016 ) ,
1832+ ( 67 , 114_153_284_032 ) ,
1833+ ( 68 , 199_768_252_064 ) ,
1834+ ( 69 , 349_594_445_728 ) ,
1835+ ( 70 , 349_412_366_216 ) ,
1836+ ( 71 , 213_408_488_702 ) ,
1837+ ( 72 , 191_341_473_067 ) ,
1838+ ( 73 , 246_711_333_592 ) ,
1839+ ( 74 , 291_874_466_228 ) ,
1840+ ( 75 , 247_485_227_056 ) ,
1841+ ( 76 , 291_241_991_316 ) ,
1842+ ( 77 , 303_154_601_714 ) ,
1843+ ( 78 , 287_407_417_932 ) ,
1844+ ( 79 , 254_935_051_664 ) ,
1845+ ( 80 , 255_413_055_349 ) ,
1846+ ( 81 , 249_790_431_509 ) ,
1847+ ( 82 , 261_343_249_180 ) ,
1848+ ( 83 , 261_361_408_796 ) ,
1849+ ( 84 , 201_938_003_214 ) ,
1850+ ( 85 , 264_805_234_604 ) ,
1851+ ( 86 , 223_171_973_880 ) ,
1852+ ( 87 , 180_397_358_280 ) ,
1853+ ( 88 , 270_596_039_760 ) ,
1854+ ( 89 , 286_399_608_951 ) ,
1855+ ( 90 , 267_684_201_301 ) ,
1856+ ( 91 , 284_637_542_762 ) ,
1857+ ( 92 , 288_373_410_868 ) ,
1858+ ( 93 , 290_836_604_849 ) ,
1859+ ( 94 , 270_861_792_144 ) ,
1860+ ( 95 , 210_595_055_304 ) ,
1861+ ( 96 , 315_263_727_200 ) ,
1862+ ( 97 , 158_244_884_792 ) ,
1863+ ( 98 , 168_102_223_900 ) ,
1864+ ( 99 , 252_153_339_800 ) ,
1865+ ( 100 , 378_230_014_000 ) ,
1866+ ( 101 , 205_977_765_866 ) ,
1867+ ( 102 , 149_434_017_849 ) ,
1868+ ( 103 , 135_476_471_008 ) ,
1869+ ( 104 , 147_970_415_680 ) ,
1870+ ( 105 , 122_003_668_139 ) ,
1871+ ( 106 , 133_585_556_570 ) ,
1872+ ( 107 , 200_137_144_216 ) ,
1873+ ( 108 , 106_767_623_816 ) ,
1874+ ( 109 , 124_280_483_748 ) ,
1875+ ( 110 , 186_420_726_696 ) ,
1876+ ( 111 , 249_855_564_892 ) ,
1877+ ( 112 , 196_761_272_984 ) ,
1878+ ( 113 , 147_120_048_727 ) ,
1879+ ( 114 , 84_021_895_534 ) ,
1880+ ( 115 , 98_002_215_656 ) ,
1881+ ( 116 , 89_944_262_256 ) ,
1882+ ( 117 , 107_183_582_952 ) ,
1883+ ( 118 , 110_644_724_664 ) ,
1884+ ( 119 , 99_380_483_902 ) ,
1885+ ( 120 , 138_829_019_156 ) ,
1886+ ( 121 , 111_988_743_976 ) ,
1887+ ( 122 , 130_264_686_152 ) ,
1888+ ( 123 , 118_034_291_488 ) ,
1889+ ( 124 , 79_312_501_676 ) ,
1890+ ( 125 , 43_214_310_704 ) ,
1891+ ( 126 , 64_755_449_962 ) ,
1892+ ( 127 , 97_101_698_382 ) ,
1893+ ( 128 , 145_645_807_991 ) ,
18991894 ] ;
19001895
1901- // ── run migration ────────────────────────────────────────────────────
1896+ // Run migration
19021897 let weight =
19031898 crate :: migrations:: migrate_subnet_locked:: migrate_restore_subnet_locked :: < Test > ( ) ;
19041899 assert ! ( !weight. is_zero( ) , "migration weight should be > 0" ) ;
19051900
1906- // ── validate: build a (u16 -> u64) map directly from storage iterator ─
1901+ // Read back storage as (u16 -> u64)
19071902 let actual: BTreeMap < u16 , u64 > = SubnetLocked :: < Test > :: iter ( )
19081903 . map ( |( k, v) | ( k. saturated_into :: < u16 > ( ) , u64:: from ( v) ) )
19091904 . collect ( ) ;
19101905
19111906 let expected: BTreeMap < u16 , u64 > = EXPECTED . iter ( ) . copied ( ) . collect ( ) ;
19121907
1913- // 1) exact content match (keys and values)
1914- assert_eq ! ( actual, expected, "SubnetLocked map mismatch with snapshot" ) ;
1908+ // 1) exact content
1909+ assert_eq ! (
1910+ actual, expected,
1911+ "SubnetLocked map mismatch for 65..128 snapshot"
1912+ ) ;
19151913
1916- // 2) count and total sum match expectations
1914+ // 2) count and total
19171915 let expected_len = expected. len ( ) ;
19181916 let expected_sum: u128 = expected. values ( ) . map ( |v| * v as u128 ) . sum ( ) ;
19191917
@@ -1923,22 +1921,19 @@ fn test_migrate_restore_subnet_locked_feb1_2025() {
19231921 assert_eq ! ( count_after, expected_len, "entry count mismatch" ) ;
19241922 assert_eq ! ( sum_after, expected_sum, "total RAO sum mismatch" ) ;
19251923
1926- // ── migration flag ───────────────────────────────────────────────────
1924+ // 3) migration flag set
19271925 assert ! (
19281926 HasMigrationRun :: <Test >:: get( name. clone( ) ) ,
19291927 "HasMigrationRun should be true after migration"
19301928 ) ;
19311929
1932- // ── idempotence: re-running does not change storage ─────────────────
1933- let before = actual;
1934-
1930+ // 4) idempotence
1931+ let before = actual. clone ( ) ;
19351932 let _again =
19361933 crate :: migrations:: migrate_subnet_locked:: migrate_restore_subnet_locked :: < Test > ( ) ;
1937-
19381934 let after: BTreeMap < u16 , u64 > = SubnetLocked :: < Test > :: iter ( )
19391935 . map ( |( k, v) | ( k. saturated_into :: < u16 > ( ) , u64:: from ( v) ) )
19401936 . collect ( ) ;
1941-
19421937 assert_eq ! (
19431938 before, after,
19441939 "re-running the migration should not change storage"
0 commit comments