@@ -601,28 +601,71 @@ fn from_unversioned_to_v2_storage() {
601
601
// StorageVersion is 0 before migration
602
602
assert_eq ! ( StorageVersion :: get:: <Pallet <para:: Runtime >>( ) , 0 ) ;
603
603
604
- // V2 storage key
605
- let old_key = xcm:: v2:: MultiLocation :: new (
604
+ // V2 storage
605
+ let old_multilocation_0 = xcm:: v2:: MultiLocation :: new (
606
606
0 ,
607
607
xcm:: v2:: Junctions :: X1 ( xcm:: v2:: Junction :: GeneralKey ( vec ! [ 0 ] . try_into ( ) . unwrap ( ) ) ) ,
608
- )
609
- . encode ( ) ;
608
+ ) ;
609
+ let old_multilocation_1 = xcm:: v2:: MultiLocation :: new (
610
+ 1 ,
611
+ xcm:: v2:: Junctions :: X2 (
612
+ xcm:: v2:: Junction :: Parachain ( 2096 ) ,
613
+ xcm:: v2:: Junction :: GeneralKey ( vec ! [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] . try_into ( ) . unwrap ( ) ) ,
614
+ ) ,
615
+ ) ;
616
+ let old_multilocation_2 = xcm:: v2:: MultiLocation :: new (
617
+ 1 ,
618
+ xcm:: v2:: Junctions :: X2 (
619
+ xcm:: v2:: Junction :: Parachain ( 2096 ) ,
620
+ xcm:: v2:: Junction :: GeneralKey ( vec ! [ 1 , 1 ] . try_into ( ) . unwrap ( ) ) ,
621
+ ) ,
622
+ ) ;
610
623
611
- let asset_id: para:: ParaAssetId = 5u32 ;
624
+ let asset_id_0: para:: ParaAssetId = 5u32 ;
625
+ let asset_id_1: para:: ParaAssetId = 6u32 ;
626
+ let asset_id_2: para:: ParaAssetId = 7u32 ;
612
627
613
628
// Store raw xcm::v2 data
614
629
put_storage_value (
615
630
module_prefix,
616
631
storage_prefix,
617
- & Blake2_128Concat :: hash ( & old_key) ,
618
- asset_id,
632
+ & Twox64Concat :: hash ( & old_multilocation_0. encode ( ) ) ,
633
+ asset_id_0,
634
+ ) ;
635
+ put_storage_value (
636
+ module_prefix,
637
+ storage_prefix,
638
+ & Twox64Concat :: hash ( & old_multilocation_1. encode ( ) ) ,
639
+ asset_id_1,
640
+ ) ;
641
+ put_storage_value (
642
+ module_prefix,
643
+ storage_prefix,
644
+ & Twox64Concat :: hash ( & old_multilocation_2. encode ( ) ) ,
645
+ asset_id_2,
619
646
) ;
620
647
621
648
// V3 storage key
622
- let new_key = MultiLocation :: new ( 0 , X1 ( Junction :: from ( BoundedVec :: try_from ( vec ! [ 0 ] ) . unwrap ( ) ) ) ) ;
649
+ let new_multilocation_0 = MultiLocation :: new ( 0 , X1 ( Junction :: from ( BoundedVec :: try_from ( vec ! [ 0 ] ) . unwrap ( ) ) ) ) ;
650
+ let new_multilocation_1 = MultiLocation :: new (
651
+ 1 ,
652
+ X2 (
653
+ Parachain ( 2096 ) ,
654
+ Junction :: from ( BoundedVec :: try_from ( vec ! [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ) . unwrap ( ) ) ,
655
+ ) ,
656
+ ) ;
657
+ let new_multilocation_2 = MultiLocation :: new (
658
+ 1 ,
659
+ X2 (
660
+ Parachain ( 2096 ) ,
661
+ Junction :: from ( BoundedVec :: try_from ( vec ! [ 1 , 1 ] ) . unwrap ( ) ) ,
662
+ ) ,
663
+ ) ;
623
664
624
665
// Assert new StorageKey still does not exist
625
- assert_eq ! ( AssetRegistry :: location_to_asset_id( new_key) , None ) ;
666
+ assert_eq ! ( AssetRegistry :: location_to_asset_id( new_multilocation_0) , None ) ;
667
+ assert_eq ! ( AssetRegistry :: location_to_asset_id( new_multilocation_1) , None ) ;
668
+ assert_eq ! ( AssetRegistry :: location_to_asset_id( new_multilocation_2) , None ) ;
626
669
627
670
// Run StorageKey migration
628
671
crate :: Migration :: < para:: Runtime > :: on_runtime_upgrade ( ) ;
@@ -631,13 +674,36 @@ fn from_unversioned_to_v2_storage() {
631
674
assert_eq ! ( StorageVersion :: get:: <Pallet <para:: Runtime >>( ) , 2 ) ;
632
675
633
676
// Assert the StorageKey exists and has been migrated to xcm::v3
634
- assert_eq ! ( AssetRegistry :: location_to_asset_id( new_key) , Some ( asset_id) ) ;
677
+ assert_eq ! (
678
+ AssetRegistry :: location_to_asset_id( new_multilocation_0) ,
679
+ Some ( asset_id_0)
680
+ ) ;
681
+ assert_eq ! (
682
+ AssetRegistry :: location_to_asset_id( new_multilocation_1) ,
683
+ Some ( asset_id_1)
684
+ ) ;
685
+ assert_eq ! (
686
+ AssetRegistry :: location_to_asset_id( new_multilocation_2) ,
687
+ Some ( asset_id_2)
688
+ ) ;
635
689
636
690
// Assert the old key does not exist anymore
637
691
assert ! ( get_storage_value:: <para:: ParaAssetId >(
638
692
module_prefix,
639
693
storage_prefix,
640
- & Blake2_128Concat :: hash( & old_key) ,
694
+ & Twox64Concat :: hash( & old_multilocation_0. encode( ) ) ,
695
+ )
696
+ . is_none( ) ) ;
697
+ assert ! ( get_storage_value:: <para:: ParaAssetId >(
698
+ module_prefix,
699
+ storage_prefix,
700
+ & Twox64Concat :: hash( & old_multilocation_1. encode( ) ) ,
701
+ )
702
+ . is_none( ) ) ;
703
+ assert ! ( get_storage_value:: <para:: ParaAssetId >(
704
+ module_prefix,
705
+ storage_prefix,
706
+ & Twox64Concat :: hash( & old_multilocation_2. encode( ) ) ,
641
707
)
642
708
. is_none( ) ) ;
643
709
0 commit comments