AstarNetwork/Astar

[XCM] Improve XCM precompile tests

Dinonard opened this issue · 0 comments

Description

With the introduction of remote_transact we need to ensure the message being sent has the correct format. The send extrinsic will prepend XCM with DescendOrigin instruction in case it’s not coming from sovereign account. We rely on it in the precompiles and should somehow ensure it doesn’t accidentally get removed.

An approach that can be used:

thread_local! {
	pub static SENT_XCM: RefCell<Vec<(MultiLocation, Xcm<()>)>> = RefCell::new(Vec::new());
}

/// Sender that never returns error, always sends
pub struct TestSendXcm;
impl SendXcm for TestSendXcm {
	fn send_xcm(dest: impl Into<MultiLocation>, msg: Xcm<()>) -> SendResult {
		SENT_XCM.with(|q| q.borrow_mut().push((dest.into(), msg)));
		Ok(())
	}
}