mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 10:17:57 +00:00
Add force_batch to utility pallet (#11148)
* Add batch_try to utility pallet * lint * rename utility.batch_try -> utility.force_batch * Remove un-needed index field for utility.ItemFailed event * Remove indexes of utility,BatchCompletedWithErrors * Apply suggestions from code review Co-authored-by: Louis Merlin <hello@louismerl.in> Co-authored-by: Louis Merlin <hello@louismerl.in> Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
@@ -606,3 +606,35 @@ fn batch_limit() {
|
||||
assert_noop!(Utility::batch_all(Origin::signed(1), calls), Error::<Test>::TooManyCalls);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn force_batch_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_eq!(Balances::free_balance(1), 10);
|
||||
assert_eq!(Balances::free_balance(2), 10);
|
||||
assert_ok!(Utility::force_batch(
|
||||
Origin::signed(1),
|
||||
vec![
|
||||
call_transfer(2, 5),
|
||||
call_foobar(true, 75, None),
|
||||
call_transfer(2, 10),
|
||||
call_transfer(2, 5),
|
||||
]
|
||||
),);
|
||||
System::assert_last_event(utility::Event::BatchCompletedWithErrors.into());
|
||||
System::assert_has_event(
|
||||
utility::Event::ItemFailed { error: DispatchError::Other("") }.into(),
|
||||
);
|
||||
assert_eq!(Balances::free_balance(1), 0);
|
||||
assert_eq!(Balances::free_balance(2), 20);
|
||||
|
||||
assert_ok!(Utility::force_batch(
|
||||
Origin::signed(2),
|
||||
vec![call_transfer(1, 5), call_transfer(1, 5),]
|
||||
),);
|
||||
System::assert_last_event(utility::Event::BatchCompleted.into());
|
||||
|
||||
assert_ok!(Utility::force_batch(Origin::signed(1), vec![call_transfer(2, 50),]),);
|
||||
System::assert_last_event(utility::Event::BatchCompletedWithErrors.into());
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user