@@ -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,21 +225,47 @@ fn register_token() {
227225}
228226
229227#[ test]
230- fn send_token ( ) {
231- BridgeHubRococo :: fund_accounts ( vec ! [ (
232- BridgeHubRococo :: sovereign_account_id_of ( MultiLocation {
228+ fn send_token_to_penpal ( ) {
229+ let asset_hub_sovereign = BridgeHubRococo :: sovereign_account_id_of (
230+ MultiLocation {
233231 parents : 1 ,
234- interior: X1 ( Parachain ( DEST_PARA_ID ) ) ,
235- } ) ,
232+ interior : X1 ( Parachain ( ASSETHUB_PARA_ID ) ) ,
233+ }
234+ ) ;
235+ BridgeHubRococo :: fund_accounts ( vec ! [ (
236+ asset_hub_sovereign. clone( ) ,
236237 INITIAL_FUND ,
237238 ) ] ) ;
238239
239240 // Fund ethereum sovereign in asset hub
240241 AssetHubRococo :: fund_accounts ( vec ! [
241- ( ASSETHUB_SOVEREIGN . into( ) , INITIAL_FUND ) ,
242242 ( AssetHubRococoReceiver :: get( ) , INITIAL_FUND ) ,
243243 ] ) ;
244244
245+ PenpalA :: fund_accounts ( vec ! [
246+ ( PenpalAReceiver :: get( ) , INITIAL_FUND ) ,
247+ ( PenpalASender :: get( ) , INITIAL_FUND ) ,
248+ ] ) ;
249+
250+ let weth_asset_id: MultiLocation = (
251+ Parent ,
252+ Parent ,
253+ Ethereum { chain_id : 15 } ,
254+ AccountKey20 { network : None , key : WETH }
255+ ) . into ( ) ;
256+
257+ // Create asset on penpal.
258+ PenpalA :: execute_with ( || {
259+ assert_ok ! ( <PenpalA as PenpalAPallet >:: ForeignAssets :: create(
260+ <PenpalA as Chain >:: RuntimeOrigin :: signed( PenpalASender :: get( ) ) ,
261+ weth_asset_id,
262+ asset_hub_sovereign. into( ) ,
263+ 1000 ,
264+ ) ) ;
265+
266+ //assert!(<PenpalA as PenpalAPallet>::Assets::asset_exists(weth_asset_id));
267+ } ) ;
268+
245269 let message_id_: H256 = [ 1 ; 32 ] . into ( ) ;
246270
247271 BridgeHubRococo :: execute_with ( || {
@@ -253,17 +277,17 @@ fn send_token() {
253277 command : Command :: RegisterToken { token : WETH . into ( ) } ,
254278 } ) ;
255279 let ( xcm, _) = EthereumInboundQueue :: do_convert ( message_id_, message) . unwrap ( ) ;
256- let _ = EthereumInboundQueue :: send_xcm ( xcm, DEST_PARA_ID . into ( ) ) . unwrap ( ) ;
280+ let _ = EthereumInboundQueue :: send_xcm ( xcm, ASSETHUB_PARA_ID . into ( ) ) . unwrap ( ) ;
257281 let message = VersionedMessage :: V1 ( MessageV1 {
258282 chain_id : CHAIN_ID ,
259283 command : Command :: SendToken {
260284 token : WETH . into ( ) ,
261- destination : Destination :: AccountId32 { id : AssetHubRococoReceiver :: get ( ) . into ( ) } ,
285+ destination : Destination :: ForeignAccountId32 { para_id : 2000 , id : PenpalAReceiver :: get ( ) . into ( ) } ,
262286 amount : 1_000_000_000 ,
263287 } ,
264288 } ) ;
265289 let ( xcm, _) = EthereumInboundQueue :: do_convert ( message_id_, message) . unwrap ( ) ;
266- let _ = EthereumInboundQueue :: send_xcm ( xcm, DEST_PARA_ID . into ( ) ) . unwrap ( ) ;
290+ let _ = EthereumInboundQueue :: send_xcm ( xcm, ASSETHUB_PARA_ID . into ( ) ) . unwrap ( ) ;
267291
268292 assert_expected_events ! (
269293 BridgeHubRococo ,
@@ -278,6 +302,18 @@ fn send_token() {
278302
279303 assert_expected_events ! (
280304 AssetHubRococo ,
305+ vec![
306+ RuntimeEvent :: ForeignAssets ( pallet_assets:: Event :: Issued { .. } ) => { } ,
307+ RuntimeEvent :: XcmpQueue ( cumulus_pallet_xcmp_queue:: Event :: XcmpMessageSent { .. } ) => { } ,
308+ ]
309+ ) ;
310+ } ) ;
311+
312+ PenpalA :: execute_with ( || {
313+ type RuntimeEvent = <PenpalA as Chain >:: RuntimeEvent ;
314+
315+ assert_expected_events ! (
316+ PenpalA ,
281317 vec![
282318 RuntimeEvent :: ForeignAssets ( pallet_assets:: Event :: Issued { .. } ) => { } ,
283319 ]
@@ -286,18 +322,77 @@ fn send_token() {
286322}
287323
288324#[ test]
289- fn reserve_transfer_token ( ) {
325+ fn send_token ( ) {
290326 BridgeHubRococo :: fund_accounts ( vec ! [ (
291327 BridgeHubRococo :: sovereign_account_id_of( MultiLocation {
292328 parents: 1 ,
293- interior: X1 ( Parachain ( DEST_PARA_ID ) ) ,
329+ interior: X1 ( Parachain ( ASSETHUB_PARA_ID ) ) ,
294330 } ) ,
295331 INITIAL_FUND ,
296332 ) ] ) ;
297333
298334 // Fund ethereum sovereign in asset hub
299335 AssetHubRococo :: fund_accounts ( vec ! [
300- ( ASSETHUB_SOVEREIGN . into( ) , INITIAL_FUND ) ,
336+ ( AssetHubRococoReceiver :: get( ) , INITIAL_FUND ) ,
337+ ] ) ;
338+
339+ let message_id_: H256 = [ 1 ; 32 ] . into ( ) ;
340+
341+ BridgeHubRococo :: execute_with ( || {
342+ type RuntimeEvent = <BridgeHubRococo as Chain >:: RuntimeEvent ;
343+ type EthereumInboundQueue =
344+ <BridgeHubRococo as BridgeHubRococoPallet >:: EthereumInboundQueue ;
345+ let message = VersionedMessage :: V1 ( MessageV1 {
346+ chain_id : CHAIN_ID ,
347+ command : Command :: RegisterToken { token : WETH . into ( ) } ,
348+ } ) ;
349+ let ( xcm, _) = EthereumInboundQueue :: do_convert ( message_id_, message) . unwrap ( ) ;
350+ let _ = EthereumInboundQueue :: send_xcm ( xcm, ASSETHUB_PARA_ID . into ( ) ) . unwrap ( ) ;
351+ let message = VersionedMessage :: V1 ( MessageV1 {
352+ chain_id : CHAIN_ID ,
353+ command : Command :: SendToken {
354+ token : WETH . into ( ) ,
355+ destination : Destination :: AccountId32 { id : AssetHubRococoReceiver :: get ( ) . into ( ) } ,
356+ amount : 1_000_000_000 ,
357+ } ,
358+ } ) ;
359+ let ( xcm, _) = EthereumInboundQueue :: do_convert ( message_id_, message) . unwrap ( ) ;
360+ let _ = EthereumInboundQueue :: send_xcm ( xcm, ASSETHUB_PARA_ID . into ( ) ) . unwrap ( ) ;
361+
362+ assert_expected_events ! (
363+ BridgeHubRococo ,
364+ vec![
365+ RuntimeEvent :: XcmpQueue ( cumulus_pallet_xcmp_queue:: Event :: XcmpMessageSent { .. } ) => { } ,
366+ ]
367+ ) ;
368+ } ) ;
369+
370+ AssetHubRococo :: execute_with ( || {
371+ type RuntimeEvent = <AssetHubRococo as Chain >:: RuntimeEvent ;
372+
373+ assert_expected_events ! (
374+ AssetHubRococo ,
375+ vec![
376+ RuntimeEvent :: ForeignAssets ( pallet_assets:: Event :: Issued { .. } ) => { } ,
377+ ]
378+ ) ;
379+ } ) ;
380+ }
381+
382+ #[ test]
383+ fn reserve_transfer_token ( ) {
384+ let assethub_sovereign = BridgeHubRococo :: sovereign_account_id_of (
385+ MultiLocation {
386+ parents : 1 ,
387+ interior : X1 ( Parachain ( ASSETHUB_PARA_ID ) ) ,
388+ }
389+ ) ;
390+
391+ BridgeHubRococo :: fund_accounts ( vec ! [
392+ ( assethub_sovereign. clone( ) , INITIAL_FUND )
393+ ] ) ;
394+
395+ AssetHubRococo :: fund_accounts ( vec ! [
301396 ( AssetHubRococoReceiver :: get( ) , INITIAL_FUND ) ,
302397 ] ) ;
303398
@@ -313,7 +408,7 @@ fn reserve_transfer_token() {
313408 command : Command :: RegisterToken { token : WETH . into ( ) } ,
314409 } ) ;
315410 let ( xcm, _) = EthereumInboundQueue :: do_convert ( message_id_, message) . unwrap ( ) ;
316- let _ = EthereumInboundQueue :: send_xcm ( xcm, DEST_PARA_ID . into ( ) ) . unwrap ( ) ;
411+ let _ = EthereumInboundQueue :: send_xcm ( xcm, ASSETHUB_PARA_ID . into ( ) ) . unwrap ( ) ;
317412 let message = VersionedMessage :: V1 ( MessageV1 {
318413 chain_id : CHAIN_ID ,
319414 command : Command :: SendToken {
@@ -323,7 +418,7 @@ fn reserve_transfer_token() {
323418 } ,
324419 } ) ;
325420 let ( xcm, _) = EthereumInboundQueue :: do_convert ( message_id_, message) . unwrap ( ) ;
326- let _ = EthereumInboundQueue :: send_xcm ( xcm, DEST_PARA_ID . into ( ) ) . unwrap ( ) ;
421+ let _ = EthereumInboundQueue :: send_xcm ( xcm, ASSETHUB_PARA_ID . into ( ) ) . unwrap ( ) ;
327422
328423 assert_expected_events ! (
329424 BridgeHubRococo ,
@@ -402,7 +497,7 @@ fn reserve_transfer_token() {
402497 . find( |& event| matches!(
403498 event,
404499 RuntimeEvent :: Balances ( pallet_balances:: Event :: Deposit { who, amount } )
405- if * who == ASSETHUB_SOVEREIGN . into ( ) && * amount == 2200000000000
500+ if who == & assethub_sovereign && * amount == 2200000000000
406501 ) )
407502 . is_some( ) ,
408503 "Assethub sovereign takes remote fee."
0 commit comments