@@ -43,6 +43,7 @@ use frame_support::{
4343 fungibles:: {
4444 Create , Inspect as FungiblesInspect , InspectEnumerable , Mutate as FungiblesMutate ,
4545 } ,
46+ ContainsPair ,
4647 } ,
4748 weights:: { Weight , WeightToFee as WeightToFeeT } ,
4849} ;
@@ -133,6 +134,7 @@ fn setup_pool_for_paying_fees_with_foreign_assets(
133134#[ test]
134135fn test_buy_and_refund_weight_in_native ( ) {
135136 ExtBuilder :: < Runtime > :: default ( )
137+ . with_tracing ( )
136138 . with_collators ( vec ! [ AccountId :: from( ALICE ) ] )
137139 . with_session_keys ( vec ! [ (
138140 AccountId :: from( ALICE ) ,
@@ -191,6 +193,7 @@ fn test_buy_and_refund_weight_in_native() {
191193#[ test]
192194fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader ( ) {
193195 ExtBuilder :: < Runtime > :: default ( )
196+ . with_tracing ( )
194197 . with_collators ( vec ! [ AccountId :: from( ALICE ) ] )
195198 . with_session_keys ( vec ! [ (
196199 AccountId :: from( ALICE ) ,
@@ -300,6 +303,7 @@ fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() {
300303#[ test]
301304fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader ( ) {
302305 ExtBuilder :: < Runtime > :: default ( )
306+ . with_tracing ( )
303307 . with_collators ( vec ! [ AccountId :: from( ALICE ) ] )
304308 . with_session_keys ( vec ! [ (
305309 AccountId :: from( ALICE ) ,
@@ -410,6 +414,7 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
410414#[ test]
411415fn test_asset_xcm_take_first_trader ( ) {
412416 ExtBuilder :: < Runtime > :: default ( )
417+ . with_tracing ( )
413418 . with_collators ( vec ! [ AccountId :: from( ALICE ) ] )
414419 . with_session_keys ( vec ! [ (
415420 AccountId :: from( ALICE ) ,
@@ -488,6 +493,7 @@ fn test_asset_xcm_take_first_trader() {
488493#[ test]
489494fn test_foreign_asset_xcm_take_first_trader ( ) {
490495 ExtBuilder :: < Runtime > :: default ( )
496+ . with_tracing ( )
491497 . with_collators ( vec ! [ AccountId :: from( ALICE ) ] )
492498 . with_session_keys ( vec ! [ (
493499 AccountId :: from( ALICE ) ,
@@ -569,6 +575,7 @@ fn test_foreign_asset_xcm_take_first_trader() {
569575#[ test]
570576fn test_asset_xcm_take_first_trader_with_refund ( ) {
571577 ExtBuilder :: < Runtime > :: default ( )
578+ . with_tracing ( )
572579 . with_collators ( vec ! [ AccountId :: from( ALICE ) ] )
573580 . with_session_keys ( vec ! [ (
574581 AccountId :: from( ALICE ) ,
@@ -648,6 +655,7 @@ fn test_asset_xcm_take_first_trader_with_refund() {
648655#[ test]
649656fn test_asset_xcm_take_first_trader_refund_not_possible_since_amount_less_than_ed ( ) {
650657 ExtBuilder :: < Runtime > :: default ( )
658+ . with_tracing ( )
651659 . with_collators ( vec ! [ AccountId :: from( ALICE ) ] )
652660 . with_session_keys ( vec ! [ (
653661 AccountId :: from( ALICE ) ,
@@ -700,6 +708,7 @@ fn test_asset_xcm_take_first_trader_refund_not_possible_since_amount_less_than_e
700708#[ test]
701709fn test_that_buying_ed_refund_does_not_refund_for_take_first_trader ( ) {
702710 ExtBuilder :: < Runtime > :: default ( )
711+ . with_tracing ( )
703712 . with_collators ( vec ! [ AccountId :: from( ALICE ) ] )
704713 . with_session_keys ( vec ! [ (
705714 AccountId :: from( ALICE ) ,
@@ -764,6 +773,7 @@ fn test_that_buying_ed_refund_does_not_refund_for_take_first_trader() {
764773#[ test]
765774fn test_asset_xcm_take_first_trader_not_possible_for_non_sufficient_assets ( ) {
766775 ExtBuilder :: < Runtime > :: default ( )
776+ . with_tracing ( )
767777 . with_collators ( vec ! [ AccountId :: from( ALICE ) ] )
768778 . with_session_keys ( vec ! [ (
769779 AccountId :: from( ALICE ) ,
@@ -825,6 +835,7 @@ fn test_assets_balances_api_works() {
825835 use assets_common:: runtime_api:: runtime_decl_for_fungibles_api:: FungiblesApi ;
826836
827837 ExtBuilder :: < Runtime > :: default ( )
838+ . with_tracing ( )
828839 . with_collators ( vec ! [ AccountId :: from( ALICE ) ] )
829840 . with_session_keys ( vec ! [ (
830841 AccountId :: from( ALICE ) ,
@@ -939,6 +950,87 @@ fn test_assets_balances_api_works() {
939950 } ) ;
940951}
941952
953+ #[ test]
954+ fn authorized_aliases_work ( ) {
955+ ExtBuilder :: < Runtime > :: default ( )
956+ . with_tracing ( )
957+ . with_collators ( vec ! [ AccountId :: from( ALICE ) ] )
958+ . with_session_keys ( vec ! [ (
959+ AccountId :: from( ALICE ) ,
960+ AccountId :: from( ALICE ) ,
961+ SessionKeys { aura: AuraId :: from( sp_core:: sr25519:: Public :: from_raw( ALICE ) ) } ,
962+ ) ] )
963+ . build ( )
964+ . execute_with ( || {
965+ let alice: AccountId = ALICE . into ( ) ;
966+ let local_alice = Location :: new ( 0 , AccountId32 { network : Some ( Westend ) , id : ALICE } ) ;
967+ let alice_on_sibling_para =
968+ Location :: new ( 1 , [ Parachain ( 42 ) , AccountId32 { network : None , id : ALICE } ] ) ;
969+ let alice_on_relay = Location :: new ( 1 , AccountId32 { network : None , id : ALICE } ) ;
970+ let bob_on_relay = Location :: new ( 1 , AccountId32 { network : None , id : [ 42_u8 ; 32 ] } ) ;
971+
972+ // neither `alice_on_sibling_para`, `alice_on_relay`, `bob_on_relay` are allowed to
973+ // alias into `local_alice`
974+ for aliaser in [ & alice_on_sibling_para, & alice_on_relay, & bob_on_relay] {
975+ assert ! ( !<XcmConfig as xcm_executor:: Config >:: Aliasers :: contains(
976+ aliaser,
977+ & local_alice
978+ ) ) ;
979+ }
980+
981+ // Alice explicitly authorizes `alice_on_sibling_para` to alias her local account
982+ assert_ok ! ( PolkadotXcm :: add_authorized_alias(
983+ RuntimeHelper :: origin_of( alice. clone( ) ) ,
984+ Box :: new( alice_on_sibling_para. clone( ) . into( ) )
985+ ) ) ;
986+
987+ // `alice_on_sibling_para` now explicitly allowed to alias into `local_alice`
988+ assert ! ( <XcmConfig as xcm_executor:: Config >:: Aliasers :: contains(
989+ & alice_on_sibling_para,
990+ & local_alice
991+ ) ) ;
992+ // as expected, `alice_on_relay` and `bob_on_relay` still can't alias into `local_alice`
993+ for aliaser in [ & alice_on_relay, & bob_on_relay] {
994+ assert ! ( !<XcmConfig as xcm_executor:: Config >:: Aliasers :: contains(
995+ aliaser,
996+ & local_alice
997+ ) ) ;
998+ }
999+
1000+ // Alice explicitly authorizes `alice_on_relay` to alias her local account
1001+ assert_ok ! ( PolkadotXcm :: add_authorized_alias(
1002+ RuntimeHelper :: origin_of( alice. clone( ) ) ,
1003+ Box :: new( alice_on_relay. clone( ) . into( ) )
1004+ ) ) ;
1005+ // Now both `alice_on_relay` and `alice_on_sibling_para` can alias into her local
1006+ // account
1007+ for aliaser in [ & alice_on_relay, & alice_on_sibling_para] {
1008+ assert ! ( <XcmConfig as xcm_executor:: Config >:: Aliasers :: contains(
1009+ aliaser,
1010+ & local_alice
1011+ ) ) ;
1012+ }
1013+
1014+ // Alice removes authorization for `alice_on_relay` to alias her local account
1015+ assert_ok ! ( PolkadotXcm :: remove_authorized_alias(
1016+ RuntimeHelper :: origin_of( alice. clone( ) ) ,
1017+ Box :: new( alice_on_relay. clone( ) . into( ) )
1018+ ) ) ;
1019+
1020+ // `alice_on_relay` no longer allowed to alias into `local_alice`
1021+ assert ! ( !<XcmConfig as xcm_executor:: Config >:: Aliasers :: contains(
1022+ & alice_on_relay,
1023+ & local_alice
1024+ ) ) ;
1025+
1026+ // `alice_on_sibling_para` still allowed to alias into `local_alice`
1027+ assert ! ( <XcmConfig as xcm_executor:: Config >:: Aliasers :: contains(
1028+ & alice_on_sibling_para,
1029+ & local_alice
1030+ ) ) ;
1031+ } )
1032+ }
1033+
9421034asset_test_utils:: include_teleports_for_native_asset_works!(
9431035 Runtime ,
9441036 AllPalletsWithoutSystem ,
0 commit comments