Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions bridges/modules/xcm-bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
32 changes: 31 additions & 1 deletion bridges/modules/xcm-bridge/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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::<TestRuntime, ()>::new();
assert!(lanes_manager.create_inbound_lane(lane_id).is_ok());
Expand Down
Loading