17
17
18
18
use crate :: imports:: * ;
19
19
20
- use assets_common:: runtime_api:: runtime_decl_for_fungibles_api:: FungiblesApiV2 ;
21
20
use emulated_integration_tests_common:: test_chain_can_claim_assets;
22
- use frame_support:: traits:: fungible:: Mutate ;
23
21
use xcm_executor:: traits:: DropAssets ;
24
22
25
23
#[ test]
@@ -35,83 +33,3 @@ fn assets_can_be_claimed() {
35
33
amount
36
34
) ;
37
35
}
38
-
39
- #[ test]
40
- fn chain_can_claim_assets_for_its_users ( ) {
41
- // Many Penpal users have assets trapped in AssetHubWestend.
42
- let beneficiaries: Vec < ( Location , Assets ) > = vec ! [
43
- // Some WND.
44
- (
45
- Location :: new( 1 , [ Parachain ( 2000 ) , AccountId32 { id: [ 0u8 ; 32 ] , network: None } ] ) ,
46
- ( Parent , 10_000_000_000_000u128 ) . into( ) ,
47
- ) ,
48
- // Some USDT.
49
- (
50
- Location :: new( 1 , [ Parachain ( 2000 ) , AccountId32 { id: [ 1u8 ; 32 ] , network: None } ] ) ,
51
- ( [ PalletInstance ( ASSETS_PALLET_ID ) , GeneralIndex ( USDT_ID . into( ) ) ] , 100_000_000u128 )
52
- . into( ) ,
53
- ) ,
54
- ] ;
55
-
56
- // Start with those assets trapped.
57
- AssetHubWestend :: execute_with ( || {
58
- for ( location, assets) in & beneficiaries {
59
- <AssetHubWestend as AssetHubWestendPallet >:: PolkadotXcm :: drop_assets (
60
- location,
61
- assets. clone ( ) . into ( ) ,
62
- & XcmContext { origin : None , message_id : [ 0u8 ; 32 ] , topic : None } ,
63
- ) ;
64
- }
65
- } ) ;
66
-
67
- let penpal_to_asset_hub = PenpalA :: sibling_location_of ( AssetHubWestend :: para_id ( ) ) ;
68
- let mut builder = Xcm :: < ( ) > :: builder ( )
69
- . withdraw_asset ( ( Parent , 1_000_000_000_000u128 ) )
70
- . pay_fees ( ( Parent , 100_000_000_000u128 ) ) ;
71
-
72
- // Loop through all beneficiaries.
73
- for ( location, assets) in & beneficiaries {
74
- builder = builder. execute_with_origin (
75
- // We take only the last part, the `AccountId32` junction.
76
- Some ( ( * location. interior ( ) . last ( ) . unwrap ( ) ) . into ( ) ) ,
77
- Xcm :: < ( ) > :: builder_unsafe ( )
78
- . claim_asset ( assets. clone ( ) , Location :: new ( 0 , [ GeneralIndex ( 5 ) ] ) ) // Means lost assets were version 5.
79
- . deposit_asset ( assets. clone ( ) , location. clone ( ) )
80
- . build ( ) ,
81
- )
82
- }
83
-
84
- // Finish assembling the message.
85
- let message = builder. build ( ) ;
86
-
87
- // Fund PenpalA's sovereign account on AssetHubWestend so it can pay for fees.
88
- AssetHubWestend :: execute_with ( || {
89
- let penpal_as_seen_by_asset_hub = AssetHubWestend :: sibling_location_of ( PenpalA :: para_id ( ) ) ;
90
- let penpal_sov_account_on_asset_hub =
91
- AssetHubWestend :: sovereign_account_id_of ( penpal_as_seen_by_asset_hub) ;
92
- type Balances = <AssetHubWestend as AssetHubWestendPallet >:: Balances ;
93
- assert_ok ! ( <Balances as Mutate <_>>:: mint_into(
94
- & penpal_sov_account_on_asset_hub,
95
- 2_000_000_000_000u128 ,
96
- ) ) ;
97
- } ) ;
98
-
99
- // We can send a message from Penpal root that claims all those assets for each beneficiary.
100
- PenpalA :: execute_with ( || {
101
- assert_ok ! ( <PenpalA as PenpalAPallet >:: PolkadotXcm :: send(
102
- <PenpalA as Chain >:: RuntimeOrigin :: root( ) ,
103
- bx!( penpal_to_asset_hub. into( ) ) ,
104
- bx!( VersionedXcm :: from( message) ) ,
105
- ) ) ;
106
- } ) ;
107
-
108
- // We assert beneficiaries have received their funds.
109
- AssetHubWestend :: execute_with ( || {
110
- for ( location, expected_assets) in & beneficiaries {
111
- let sov_account = AssetHubWestend :: sovereign_account_id_of ( location. clone ( ) ) ;
112
- let actual_assets =
113
- <AssetHubWestend as Chain >:: Runtime :: query_account_balances ( sov_account) . unwrap ( ) ;
114
- assert_eq ! ( VersionedAssets :: from( expected_assets. clone( ) ) , actual_assets) ;
115
- }
116
- } ) ;
117
- }
0 commit comments