From 5870827873079050883ab7e0b1724e91b50e6712 Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 10 Sep 2024 23:08:59 +0800 Subject: [PATCH] Remove tests unused --- .../src/tests/snowbridge.rs | 343 ------------------ 1 file changed, 343 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge.rs index 389b3ec33427..9841e9c51d15 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge.rs @@ -600,346 +600,3 @@ fn transfer_ah_token() { ); }); } - -#[test] -fn transfer_penpal_native_token() { - let assethub_location = BridgeHubWestend::sibling_location_of(AssetHubWestend::para_id()); - let assethub_sovereign = BridgeHubWestend::sovereign_account_id_of(assethub_location); - BridgeHubWestend::fund_accounts(vec![(assethub_sovereign.clone(), INITIAL_FUND)]); - - let ethereum_destination = Location::new(2, [GlobalConsensus(Ethereum { chain_id: CHAIN_ID })]); - let ethereum_sovereign: AccountId = - GlobalConsensusEthereumConvertsFor::<[u8; 32]>::convert_location(ðereum_destination) - .unwrap() - .into(); - AssetHubWestend::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]); - - let penpal_asset_location = Location::new(1, [Parachain(PenpalB::para_id().into())]); - - let penpal_asset_location_after_reanchored = - Location::new(1, [GlobalConsensus(Westend), Parachain(PenpalB::para_id().into())]); - - let token_id = TokenIdOf::convert_location(&penpal_asset_location_after_reanchored).unwrap(); - - // Register token on AH - AssetHubWestend::force_create_foreign_asset( - penpal_asset_location.clone().try_into().unwrap(), - PenpalBSiblingSovereignAccount::get().clone(), - false, - ASSET_MIN_BALANCE, - vec![], - ); - - // Fund sender on AH - AssetHubWestend::mint_foreign_asset( - ::RuntimeOrigin::signed(PenpalBSiblingSovereignAccount::get()), - penpal_asset_location.clone().try_into().unwrap(), - AssetHubWestendSender::get(), - TOKEN_AMOUNT, - ); - - // Fund sov of AH on penpal - let ah_sovereign = - PenpalB::sovereign_account_id_of(PenpalB::sibling_location_of(AssetHubWestend::para_id())); - PenpalB::fund_accounts(vec![(ah_sovereign.clone(), INITIAL_FUND)]); - PenpalB::mint_foreign_asset( - ::RuntimeOrigin::signed(PenpalAssetOwner::get()), - RelayLocation::get(), - ah_sovereign.clone(), - INITIAL_FUND, - ); - - // Create token - BridgeHubWestend::execute_with(|| { - type RuntimeOrigin = ::RuntimeOrigin; - - assert_ok!(::EthereumSystem::register_token( - RuntimeOrigin::root(), - Box::new(VersionedLocation::V4(penpal_asset_location.clone())), - AssetMetadata { - name: "penpal_asset".as_bytes().to_vec().try_into().unwrap(), - symbol: "penpal_asset".as_bytes().to_vec().try_into().unwrap(), - decimals: 12, - }, - )); - }); - - // Send token to Ethereum - AssetHubWestend::execute_with(|| { - type RuntimeOrigin = ::RuntimeOrigin; - type RuntimeEvent = ::RuntimeEvent; - - let assets = vec![Asset { - id: penpal_asset_location.clone().into(), - fun: Fungible(TOKEN_AMOUNT / 10), - }]; - - let beneficiary = VersionedLocation::V4(Location::new( - 0, - [AccountKey20 { network: None, key: ETHEREUM_DESTINATION_ADDRESS.into() }], - )); - - assert_ok!(::PolkadotXcm::limited_reserve_transfer_assets( - RuntimeOrigin::signed(AssetHubWestendSender::get()), - Box::new(VersionedLocation::from(ethereum_destination)), - Box::new(beneficiary), - Box::new(VersionedAssets::from(Assets::from(assets))), - 0, - Unlimited, - )); - - assert_expected_events!( - AssetHubWestend, - vec![RuntimeEvent::ForeignAssets(pallet_assets::Event::Transferred{..}) => {},] - ); - - let events = AssetHubWestend::events(); - // Check that the native asset transferred to some reserved account(sovereign of Ethereum) - assert!( - events.iter().any(|event| matches!( - event, - RuntimeEvent::ForeignAssets(pallet_assets::Event::Transferred { amount, to, ..}) - if *amount == TOKEN_AMOUNT/10 && *to == ethereum_sovereign - )), - "native token reserved to Ethereum sovereign account." - ); - }); - - // Send token back from Ethereum - BridgeHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - // Check that the transfer token back to Ethereum message was queue in the Ethereum - // Outbound Queue - assert_expected_events!( - BridgeHubWestend, - vec![RuntimeEvent::EthereumOutboundQueue(snowbridge_pallet_outbound_queue::Event::MessageQueued{..}) => {},] - ); - - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::SendNativeToken { - token_id, - destination: Destination::ForeignAccountId32 { - para_id: PenpalB::para_id().into(), - id: PenpalBReceiver::get().into(), - fee: XCM_FEE, - }, - amount: TOKEN_AMOUNT / 10, - fee: XCM_FEE, - }, - }); - - // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert([0; 32].into(), message).unwrap(); - // Send the XCM - let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubWestend::para_id().into()).unwrap(); - - assert_expected_events!( - BridgeHubWestend, - vec![RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {},] - ); - }); - - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - // Check that token burnt from some reserved account - assert_expected_events!( - AssetHubWestend, - vec![RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { .. }) => {},] - ); - }); - - PenpalB::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - // Check that token issued to beneficial - assert_expected_events!( - PenpalB, - vec![RuntimeEvent::Balances(pallet_balances::Event::Minted { .. }) => {},] - ); - - let events = PenpalB::events(); - - // Check that token issued to destination account - assert!( - events.iter().any(|event| matches!( - event, - RuntimeEvent::Balances(pallet_balances::Event::Minted { amount, who, ..}) - if *amount == TOKEN_AMOUNT/10 && *who == PenpalBReceiver::get() - )), - "Token minted to beneficiary." - ); - }) -} - -#[test] -fn transfer_penpal_asset() { - let assethub_location = BridgeHubWestend::sibling_location_of(AssetHubWestend::para_id()); - let assethub_sovereign = BridgeHubWestend::sovereign_account_id_of(assethub_location); - BridgeHubWestend::fund_accounts(vec![(assethub_sovereign.clone(), INITIAL_FUND)]); - - let ethereum_destination = Location::new(2, [GlobalConsensus(Ethereum { chain_id: CHAIN_ID })]); - let ethereum_sovereign: AccountId = - GlobalConsensusEthereumConvertsFor::<[u8; 32]>::convert_location(ðereum_destination) - .unwrap() - .into(); - - AssetHubWestend::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]); - - let penpal_asset_location = Location::new(1, [Parachain(PenpalB::para_id().into())]) - .appended_with(PenpalLocalTeleportableToAssetHub::get()) - .unwrap(); - - let penpal_asset_location_after_reanchored = - Location::new(1, [GlobalConsensus(Westend), Parachain(PenpalB::para_id().into())]) - .appended_with(PenpalLocalTeleportableToAssetHub::get()) - .unwrap(); - - let token_id = TokenIdOf::convert_location(&penpal_asset_location_after_reanchored).unwrap(); - - // Fund sender on AH - AssetHubWestend::mint_foreign_asset( - ::RuntimeOrigin::signed(PenpalBSiblingSovereignAccount::get()), - penpal_asset_location.clone().try_into().unwrap(), - AssetHubWestendSender::get(), - TOKEN_AMOUNT, - ); - - // Fund sov of AH on penpal - let ah_sovereign = - PenpalB::sovereign_account_id_of(PenpalB::sibling_location_of(AssetHubWestend::para_id())); - PenpalB::fund_accounts(vec![(ah_sovereign.clone(), INITIAL_FUND)]); - PenpalB::mint_foreign_asset( - ::RuntimeOrigin::signed(PenpalAssetOwner::get()), - RelayLocation::get(), - ah_sovereign.clone(), - INITIAL_FUND, - ); - PenpalB::mint_asset( - ::RuntimeOrigin::signed(PenpalAssetOwner::get()), - TELEPORTABLE_ASSET_ID, - ah_sovereign.clone(), - TOKEN_AMOUNT, - ); - - // create token - BridgeHubWestend::execute_with(|| { - type Runtime = ::Runtime; - - snowbridge_pallet_system::ForeignToNativeId::::insert( - token_id, - penpal_asset_location_after_reanchored.clone(), - ); - }); - - // Send token to Ethereum - AssetHubWestend::execute_with(|| { - type RuntimeOrigin = ::RuntimeOrigin; - type RuntimeEvent = ::RuntimeEvent; - - let assets = vec![Asset { - id: penpal_asset_location.clone().into(), - fun: Fungible(TOKEN_AMOUNT / 10), - }]; - - let beneficiary = VersionedLocation::V4(Location::new( - 0, - [AccountKey20 { network: None, key: ETHEREUM_DESTINATION_ADDRESS.into() }], - )); - - assert_ok!(::PolkadotXcm::limited_reserve_transfer_assets( - RuntimeOrigin::signed(AssetHubWestendSender::get()), - Box::new(VersionedLocation::from(ethereum_destination)), - Box::new(beneficiary), - Box::new(VersionedAssets::from(Assets::from(assets))), - 0, - Unlimited, - )); - - assert_expected_events!( - AssetHubWestend, - vec![RuntimeEvent::ForeignAssets(pallet_assets::Event::Transferred{..}) => {},] - ); - - let events = AssetHubWestend::events(); - // Check that the native asset transferred to some reserved account(sovereign of Ethereum) - assert!( - events.iter().any(|event| matches!( - event, - RuntimeEvent::ForeignAssets(pallet_assets::Event::Transferred { amount, to, ..}) - if *amount == TOKEN_AMOUNT/10 && *to == ethereum_sovereign - )), - "native token reserved to Ethereum sovereign account." - ); - }); - - // Send token back from Ethereum - BridgeHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - // Check that the transfer token back to Ethereum message was queue in the Ethereum - // Outbound Queue - assert_expected_events!( - BridgeHubWestend, - vec![RuntimeEvent::EthereumOutboundQueue(snowbridge_pallet_outbound_queue::Event::MessageQueued{..}) => {},] - ); - - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::SendNativeToken { - token_id, - destination: Destination::ForeignAccountId32 { - para_id: PenpalB::para_id().into(), - id: PenpalBReceiver::get().into(), - fee: XCM_FEE, - }, - amount: TOKEN_AMOUNT / 10, - fee: XCM_FEE, - }, - }); - - // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert([0; 32].into(), message).unwrap(); - // Send the XCM - let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubWestend::para_id().into()).unwrap(); - - assert_expected_events!( - BridgeHubWestend, - vec![RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {},] - ); - }); - - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - // Check that token burnt from some reserved account - assert_expected_events!( - AssetHubWestend, - vec![RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { .. }) => {},] - ); - }); - - PenpalB::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - // Check that token issued to beneficial - assert_expected_events!( - PenpalB, - vec![RuntimeEvent::Assets(pallet_assets::Event::Issued { .. }) => {},] - ); - - let events = PenpalB::events(); - - // Check that token issued to destination account - assert!( - events.iter().any(|event| matches!( - event, - RuntimeEvent::Assets(pallet_assets::Event::Issued { amount, owner, ..}) - if *amount == TOKEN_AMOUNT/10 && *owner == PenpalBReceiver::get() - )), - "Token minted to beneficiary." - ); - }) -}