@@ -25,12 +25,10 @@ use sp_core::H256;
2525
2626const INITIAL_FUND : u128 = 5_000_000_000 * ROCOCO_ED ;
2727const CHAIN_ID : u64 = 15 ;
28- const DEST_PARA_ID : u32 = 1000 ;
28+ const ASSETHUB_PARA_ID : u32 = 1000 ;
2929const TREASURY_ACCOUNT : [ u8 ; 32 ] =
3030 hex ! ( "6d6f646c70792f74727372790000000000000000000000000000000000000000" ) ;
3131const WETH : [ u8 ; 20 ] = hex ! ( "87d1f7fdfEe7f651FaBc8bFCB6E086C278b77A7d" ) ;
32- const ASSETHUB_SOVEREIGN : [ u8 ; 32 ] =
33- hex ! ( "7369626ce8030000000000000000000000000000000000000000000000000000" ) ;
3432const ETHEREUM_DESTINATION_ADDRESS : [ u8 ; 20 ] = hex ! ( "44a57ee2f2FCcb85FDa2B0B18EBD0D8D2333700e" ) ;
3533
3634#[ test]
@@ -188,7 +186,7 @@ fn register_token() {
188186 BridgeHubRococo :: fund_accounts ( vec ! [ (
189187 BridgeHubRococo :: sovereign_account_id_of( MultiLocation {
190188 parents: 1 ,
191- interior: X1 ( Parachain ( DEST_PARA_ID ) ) ,
189+ interior: X1 ( Parachain ( ASSETHUB_PARA_ID ) ) ,
192190 } ) ,
193191 INITIAL_FUND ,
194192 ) ] ) ;
@@ -204,7 +202,7 @@ fn register_token() {
204202 command : Command :: RegisterToken { token : WETH . into ( ) } ,
205203 } ) ;
206204 let ( xcm, _) = EthereumInboundQueue :: do_convert ( message_id_, message) . unwrap ( ) ;
207- let _ = EthereumInboundQueue :: send_xcm ( xcm, DEST_PARA_ID . into ( ) ) . unwrap ( ) ;
205+ let _ = EthereumInboundQueue :: send_xcm ( xcm, ASSETHUB_PARA_ID . into ( ) ) . unwrap ( ) ;
208206
209207 assert_expected_events ! (
210208 BridgeHubRococo ,
@@ -227,18 +225,17 @@ fn register_token() {
227225}
228226
229227#[ test]
230- fn send_token ( ) {
228+ fn send_token_to_penpal ( ) {
231229 BridgeHubRococo :: fund_accounts ( vec ! [ (
232230 BridgeHubRococo :: sovereign_account_id_of( MultiLocation {
233231 parents: 1 ,
234- interior: X1 ( Parachain ( DEST_PARA_ID ) ) ,
232+ interior: X1 ( Parachain ( ASSETHUB_PARA_ID ) ) ,
235233 } ) ,
236234 INITIAL_FUND ,
237235 ) ] ) ;
238236
239237 // Fund ethereum sovereign in asset hub
240238 AssetHubRococo :: fund_accounts ( vec ! [
241- ( ASSETHUB_SOVEREIGN . into( ) , INITIAL_FUND ) ,
242239 ( AssetHubRococoReceiver :: get( ) , INITIAL_FUND ) ,
243240 ] ) ;
244241
@@ -253,7 +250,7 @@ fn send_token() {
253250 command : Command :: RegisterToken { token : WETH . into ( ) } ,
254251 } ) ;
255252 let ( xcm, _) = EthereumInboundQueue :: do_convert ( message_id_, message) . unwrap ( ) ;
256- let _ = EthereumInboundQueue :: send_xcm ( xcm, DEST_PARA_ID . into ( ) ) . unwrap ( ) ;
253+ let _ = EthereumInboundQueue :: send_xcm ( xcm, ASSETHUB_PARA_ID . into ( ) ) . unwrap ( ) ;
257254 let message = VersionedMessage :: V1 ( MessageV1 {
258255 chain_id : CHAIN_ID ,
259256 command : Command :: SendToken {
@@ -263,7 +260,7 @@ fn send_token() {
263260 } ,
264261 } ) ;
265262 let ( xcm, _) = EthereumInboundQueue :: do_convert ( message_id_, message) . unwrap ( ) ;
266- let _ = EthereumInboundQueue :: send_xcm ( xcm, DEST_PARA_ID . into ( ) ) . unwrap ( ) ;
263+ let _ = EthereumInboundQueue :: send_xcm ( xcm, ASSETHUB_PARA_ID . into ( ) ) . unwrap ( ) ;
267264
268265 assert_expected_events ! (
269266 BridgeHubRococo ,
@@ -278,6 +275,18 @@ fn send_token() {
278275
279276 assert_expected_events ! (
280277 AssetHubRococo ,
278+ vec![
279+ RuntimeEvent :: ForeignAssets ( pallet_assets:: Event :: Issued { .. } ) => { } ,
280+ RuntimeEvent :: XcmpQueue ( cumulus_pallet_xcmp_queue:: Event :: XcmpMessageSent { .. } ) => { } ,
281+ ]
282+ ) ;
283+ } ) ;
284+
285+ PenpalARococo :: execute_with ( || {
286+ type RuntimeEvent = <PenpalARococo as Chain >:: RuntimeEvent ;
287+
288+ assert_expected_events ! (
289+ PenpalARococo ,
281290 vec![
282291 RuntimeEvent :: ForeignAssets ( pallet_assets:: Event :: Issued { .. } ) => { } ,
283292 ]
@@ -286,18 +295,77 @@ fn send_token() {
286295}
287296
288297#[ test]
289- fn reserve_transfer_token ( ) {
298+ fn send_token ( ) {
290299 BridgeHubRococo :: fund_accounts ( vec ! [ (
291300 BridgeHubRococo :: sovereign_account_id_of( MultiLocation {
292301 parents: 1 ,
293- interior: X1 ( Parachain ( DEST_PARA_ID ) ) ,
302+ interior: X1 ( Parachain ( ASSETHUB_PARA_ID ) ) ,
294303 } ) ,
295304 INITIAL_FUND ,
296305 ) ] ) ;
297306
298307 // Fund ethereum sovereign in asset hub
299308 AssetHubRococo :: fund_accounts ( vec ! [
300- ( ASSETHUB_SOVEREIGN . into( ) , INITIAL_FUND ) ,
309+ ( AssetHubRococoReceiver :: get( ) , INITIAL_FUND ) ,
310+ ] ) ;
311+
312+ let message_id_: H256 = [ 1 ; 32 ] . into ( ) ;
313+
314+ BridgeHubRococo :: execute_with ( || {
315+ type RuntimeEvent = <BridgeHubRococo as Chain >:: RuntimeEvent ;
316+ type EthereumInboundQueue =
317+ <BridgeHubRococo as BridgeHubRococoPallet >:: EthereumInboundQueue ;
318+ let message = VersionedMessage :: V1 ( MessageV1 {
319+ chain_id : CHAIN_ID ,
320+ command : Command :: RegisterToken { token : WETH . into ( ) } ,
321+ } ) ;
322+ let ( xcm, _) = EthereumInboundQueue :: do_convert ( message_id_, message) . unwrap ( ) ;
323+ let _ = EthereumInboundQueue :: send_xcm ( xcm, ASSETHUB_PARA_ID . into ( ) ) . unwrap ( ) ;
324+ let message = VersionedMessage :: V1 ( MessageV1 {
325+ chain_id : CHAIN_ID ,
326+ command : Command :: SendToken {
327+ token : WETH . into ( ) ,
328+ destination : Destination :: AccountId32 { id : AssetHubRococoReceiver :: get ( ) . into ( ) } ,
329+ amount : 1_000_000_000 ,
330+ } ,
331+ } ) ;
332+ let ( xcm, _) = EthereumInboundQueue :: do_convert ( message_id_, message) . unwrap ( ) ;
333+ let _ = EthereumInboundQueue :: send_xcm ( xcm, ASSETHUB_PARA_ID . into ( ) ) . unwrap ( ) ;
334+
335+ assert_expected_events ! (
336+ BridgeHubRococo ,
337+ vec![
338+ RuntimeEvent :: XcmpQueue ( cumulus_pallet_xcmp_queue:: Event :: XcmpMessageSent { .. } ) => { } ,
339+ ]
340+ ) ;
341+ } ) ;
342+
343+ AssetHubRococo :: execute_with ( || {
344+ type RuntimeEvent = <AssetHubRococo as Chain >:: RuntimeEvent ;
345+
346+ assert_expected_events ! (
347+ AssetHubRococo ,
348+ vec![
349+ RuntimeEvent :: ForeignAssets ( pallet_assets:: Event :: Issued { .. } ) => { } ,
350+ ]
351+ ) ;
352+ } ) ;
353+ }
354+
355+ #[ test]
356+ fn reserve_transfer_token ( ) {
357+ let assethub_sovereign = BridgeHubRococo :: sovereign_account_id_of (
358+ MultiLocation {
359+ parents : 1 ,
360+ interior : X1 ( Parachain ( ASSETHUB_PARA_ID ) ) ,
361+ }
362+ ) ;
363+
364+ BridgeHubRococo :: fund_accounts ( vec ! [
365+ ( assethub_sovereign. clone( ) , INITIAL_FUND )
366+ ] ) ;
367+
368+ AssetHubRococo :: fund_accounts ( vec ! [
301369 ( AssetHubRococoReceiver :: get( ) , INITIAL_FUND ) ,
302370 ] ) ;
303371
@@ -313,7 +381,7 @@ fn reserve_transfer_token() {
313381 command : Command :: RegisterToken { token : WETH . into ( ) } ,
314382 } ) ;
315383 let ( xcm, _) = EthereumInboundQueue :: do_convert ( message_id_, message) . unwrap ( ) ;
316- let _ = EthereumInboundQueue :: send_xcm ( xcm, DEST_PARA_ID . into ( ) ) . unwrap ( ) ;
384+ let _ = EthereumInboundQueue :: send_xcm ( xcm, ASSETHUB_PARA_ID . into ( ) ) . unwrap ( ) ;
317385 let message = VersionedMessage :: V1 ( MessageV1 {
318386 chain_id : CHAIN_ID ,
319387 command : Command :: SendToken {
@@ -323,7 +391,7 @@ fn reserve_transfer_token() {
323391 } ,
324392 } ) ;
325393 let ( xcm, _) = EthereumInboundQueue :: do_convert ( message_id_, message) . unwrap ( ) ;
326- let _ = EthereumInboundQueue :: send_xcm ( xcm, DEST_PARA_ID . into ( ) ) . unwrap ( ) ;
394+ let _ = EthereumInboundQueue :: send_xcm ( xcm, ASSETHUB_PARA_ID . into ( ) ) . unwrap ( ) ;
327395
328396 assert_expected_events ! (
329397 BridgeHubRococo ,
@@ -402,7 +470,7 @@ fn reserve_transfer_token() {
402470 . find( |& event| matches!(
403471 event,
404472 RuntimeEvent :: Balances ( pallet_balances:: Event :: Deposit { who, amount } )
405- if * who == ASSETHUB_SOVEREIGN . into ( ) && * amount == 2200000000000
473+ if who == & assethub_sovereign && * amount == 2200000000000
406474 ) )
407475 . is_some( ) ,
408476 "Assethub sovereign takes remote fee."
0 commit comments