mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 15:41:02 +00:00
XCM: ExpectTransactStatus instruction (#6578)
* Introduce ExpectTransactStatus instruction * Remove other changes * Implement * Implement rest * Benchmark * Update xcm/src/v3/mod.rs Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * Update xcm/src/v3/mod.rs Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
This commit is contained in:
@@ -156,6 +156,68 @@ fn report_failed_transact_status_should_work() {
|
||||
assert_eq!(sent_xcm(), vec![(Parent.into(), expected_msg, expected_hash)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn expect_successful_transact_status_should_work() {
|
||||
AllowUnpaidFrom::set(vec![Parent.into()]);
|
||||
|
||||
let message = Xcm::<TestCall>(vec![
|
||||
Transact {
|
||||
origin_kind: OriginKind::Native,
|
||||
require_weight_at_most: Weight::from_parts(50, 50),
|
||||
call: TestCall::Any(Weight::from_parts(50, 50), None).encode().into(),
|
||||
},
|
||||
ExpectTransactStatus(MaybeErrorCode::Success),
|
||||
]);
|
||||
let hash = fake_message_hash(&message);
|
||||
let weight_limit = Weight::from_parts(70, 70);
|
||||
let r = XcmExecutor::<TestConfig>::execute_xcm(Parent, message, hash, weight_limit);
|
||||
assert_eq!(r, Outcome::Complete(Weight::from_parts(70, 70)));
|
||||
|
||||
let message = Xcm::<TestCall>(vec![
|
||||
Transact {
|
||||
origin_kind: OriginKind::Native,
|
||||
require_weight_at_most: Weight::from_parts(50, 50),
|
||||
call: TestCall::OnlyRoot(Weight::from_parts(50, 50), None).encode().into(),
|
||||
},
|
||||
ExpectTransactStatus(MaybeErrorCode::Success),
|
||||
]);
|
||||
let hash = fake_message_hash(&message);
|
||||
let weight_limit = Weight::from_parts(70, 70);
|
||||
let r = XcmExecutor::<TestConfig>::execute_xcm(Parent, message, hash, weight_limit);
|
||||
assert_eq!(r, Outcome::Incomplete(Weight::from_parts(70, 70), XcmError::ExpectationFalse));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn expect_failed_transact_status_should_work() {
|
||||
AllowUnpaidFrom::set(vec![Parent.into()]);
|
||||
|
||||
let message = Xcm::<TestCall>(vec![
|
||||
Transact {
|
||||
origin_kind: OriginKind::Native,
|
||||
require_weight_at_most: Weight::from_parts(50, 50),
|
||||
call: TestCall::OnlyRoot(Weight::from_parts(50, 50), None).encode().into(),
|
||||
},
|
||||
ExpectTransactStatus(MaybeErrorCode::Error(vec![2])),
|
||||
]);
|
||||
let hash = fake_message_hash(&message);
|
||||
let weight_limit = Weight::from_parts(70, 70);
|
||||
let r = XcmExecutor::<TestConfig>::execute_xcm(Parent, message, hash, weight_limit);
|
||||
assert_eq!(r, Outcome::Complete(Weight::from_parts(70, 70)));
|
||||
|
||||
let message = Xcm::<TestCall>(vec![
|
||||
Transact {
|
||||
origin_kind: OriginKind::Native,
|
||||
require_weight_at_most: Weight::from_parts(50, 50),
|
||||
call: TestCall::Any(Weight::from_parts(50, 50), None).encode().into(),
|
||||
},
|
||||
ExpectTransactStatus(MaybeErrorCode::Error(vec![2])),
|
||||
]);
|
||||
let hash = fake_message_hash(&message);
|
||||
let weight_limit = Weight::from_parts(70, 70);
|
||||
let r = XcmExecutor::<TestConfig>::execute_xcm(Parent, message, hash, weight_limit);
|
||||
assert_eq!(r, Outcome::Incomplete(Weight::from_parts(70, 70), XcmError::ExpectationFalse));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clear_transact_status_should_work() {
|
||||
AllowUnpaidFrom::set(vec![Parent.into()]);
|
||||
|
||||
Reference in New Issue
Block a user