@@ -1460,3 +1460,71 @@ fn inbound_xcm_buffer_is_clean_between_messages() {
14601460 ) ;
14611461 } ) ;
14621462}
1463+
1464+ #[ test]
1465+ fn inbound_xcm_incomplete_message_still_accounts_egress ( ) {
1466+ TestNet :: reset ( ) ;
1467+
1468+ let sovereign = parachain_reserve_account ( ) ;
1469+
1470+ Hydra :: execute_with ( || {
1471+ init_global_withdraw_limit_params ( ) ;
1472+
1473+ assert_ok ! ( CircuitBreaker :: set_asset_category(
1474+ hydradx_runtime:: RuntimeOrigin :: root( ) ,
1475+ HDX ,
1476+ Some ( GlobalAssetCategory :: Local )
1477+ ) ) ;
1478+
1479+ assert_ok ! ( hydradx_runtime:: Balances :: transfer_allow_death(
1480+ hydradx_runtime:: RuntimeOrigin :: signed( ALICE . into( ) ) ,
1481+ sovereign. clone( ) ,
1482+ 500 * UNITS ,
1483+ ) ) ;
1484+
1485+ assert_eq ! ( CircuitBreaker :: withdraw_limit_accumulator( ) . 0 , 0 ) ;
1486+ assert_eq ! ( Currencies :: free_balance( HDX , & sovereign) , 500 * UNITS ) ;
1487+ } ) ;
1488+
1489+ Acala :: execute_with ( || {
1490+ let hdx_loc = Location :: new (
1491+ 1 ,
1492+ [
1493+ cumulus_primitives_core:: Junction :: Parachain ( HYDRA_PARA_ID ) ,
1494+ cumulus_primitives_core:: Junction :: GeneralIndex ( 0 ) ,
1495+ ] ,
1496+ ) ;
1497+ let amount = 100 * UNITS ;
1498+ let asset: Asset = Asset {
1499+ id : cumulus_primitives_core:: AssetId ( hdx_loc) ,
1500+ fun : Fungible ( amount) ,
1501+ } ;
1502+
1503+ let message = Xcm ( vec ! [
1504+ WithdrawAsset ( asset. clone( ) . into( ) ) ,
1505+ BuyExecution {
1506+ fees: asset,
1507+ weight_limit: Unlimited ,
1508+ } ,
1509+ Trap ( 1 ) ,
1510+ ] ) ;
1511+
1512+ assert_ok ! ( hydradx_runtime:: PolkadotXcm :: send_xcm(
1513+ Here ,
1514+ Location :: new( 1 , [ cumulus_primitives_core:: Junction :: Parachain ( HYDRA_PARA_ID ) ] ) ,
1515+ message
1516+ ) ) ;
1517+ } ) ;
1518+
1519+ Hydra :: execute_with ( || {
1520+ assert_xcm_message_processing_failed ( ) ;
1521+ assert ! (
1522+ Currencies :: free_balance( HDX , & sovereign) < 500 * UNITS ,
1523+ "Incomplete inbound XCM must have withdrawn funds from the sovereign account"
1524+ ) ;
1525+ assert ! (
1526+ CircuitBreaker :: withdraw_limit_accumulator( ) . 0 > 0 ,
1527+ "Incomplete inbound XCM with real egress must still increment the accumulator"
1528+ ) ;
1529+ } ) ;
1530+ }
0 commit comments