diff --git a/bridges/modules/xcm-bridge/src/lib.rs b/bridges/modules/xcm-bridge/src/lib.rs index c5a22557364dd..cd6190f9b71ac 100644 --- a/bridges/modules/xcm-bridge/src/lib.rs +++ b/bridges/modules/xcm-bridge/src/lib.rs @@ -761,15 +761,17 @@ pub mod pallet { // check that `locations` are convertible to the `latest` XCM. let bridge_origin_relative_location_as_latest: &Location = - bridge.bridge_origin_relative_location.try_as().map_err(|_| { + &(*bridge.bridge_origin_relative_location).try_into().map_err(|_| { "`bridge.bridge_origin_relative_location` cannot be converted to the `latest` XCM, needs migration!" })?; - let bridge_origin_universal_location_as_latest: &InteriorLocation = bridge.bridge_origin_universal_location - .try_as() - .map_err(|_| "`bridge.bridge_origin_universal_location` cannot be converted to the `latest` XCM, needs migration!")?; - let bridge_destination_universal_location_as_latest: &InteriorLocation = bridge.bridge_destination_universal_location - .try_as() - .map_err(|_| "`bridge.bridge_destination_universal_location` cannot be converted to the `latest` XCM, needs migration!")?; + let bridge_origin_universal_location_as_latest: &InteriorLocation = + &(*bridge.bridge_origin_universal_location).try_into().map_err(|_| { + "`bridge.bridge_origin_universal_location` cannot be converted to the `latest` XCM, needs migration!" + })?; + let bridge_destination_universal_location_as_latest: &InteriorLocation = + &(*bridge.bridge_destination_universal_location).try_into().map_err(|_| { + "`bridge.bridge_destination_universal_location` cannot be converted to the `latest` XCM, needs migration!" + })?; // check `BridgeId` does not change ensure!( diff --git a/bridges/modules/xcm-bridge/src/tests.rs b/bridges/modules/xcm-bridge/src/tests.rs index 223abb904728c..6db9fec32b71f 100644 --- a/bridges/modules/xcm-bridge/src/tests.rs +++ b/bridges/modules/xcm-bridge/src/tests.rs @@ -860,7 +860,7 @@ fn do_try_state_works() { bridge_destination_universal_location.clone(), )), state: BridgeState::Opened, - deposit: Some(Deposit::new(bridge_owner_account, Zero::zero())), + deposit: Some(Deposit::new(bridge_owner_account.clone(), Zero::zero())), lane_id, maybe_notify: None, }, @@ -870,6 +870,36 @@ fn do_try_state_works() { ); cleanup(bridge_id, vec![lane_id, lane_id_mismatch]); + // ok state with old XCM version + test_bridge_state( + bridge_id, + Bridge { + bridge_origin_relative_location: Box::new( + VersionedLocation::from(bridge_origin_relative_location.clone()) + .into_version(XCM_VERSION - 1) + .unwrap(), + ), + bridge_origin_universal_location: Box::new( + VersionedInteriorLocation::from(bridge_origin_universal_location.clone()) + .into_version(XCM_VERSION - 1) + .unwrap(), + ), + bridge_destination_universal_location: Box::new( + VersionedInteriorLocation::from(bridge_destination_universal_location.clone()) + .into_version(XCM_VERSION - 1) + .unwrap(), + ), + state: BridgeState::Opened, + deposit: Some(Deposit::new(bridge_owner_account, Zero::zero())), + lane_id, + maybe_notify: None, + }, + (lane_id, bridge_id), + (lane_id, lane_id), + None, + ); + cleanup(bridge_id, vec![lane_id]); + // missing bridge for inbound lane let lanes_manager = LanesManagerOf::::new(); assert!(lanes_manager.create_inbound_lane(lane_id).is_ok());