pallet-utility: Disallow none origin (#12321)

Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
Bastian Köcher
2022-09-22 09:41:16 +02:00
committed by GitHub
parent 857c3bf37b
commit 8a43b42ab1
2 changed files with 15 additions and 5 deletions
+12 -2
View File
@@ -25,6 +25,7 @@ use crate as utility;
use frame_support::{
assert_err_ignore_postinfo, assert_noop, assert_ok,
dispatch::{DispatchError, DispatchErrorWithPostInfo, Dispatchable, Pays},
error::BadOrigin,
parameter_types, storage,
traits::{ConstU32, ConstU64, Contains},
weights::Weight,
@@ -651,7 +652,7 @@ fn force_batch_works() {
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(),
@@ -662,10 +663,19 @@ fn force_batch_works() {
assert_ok!(Utility::force_batch(
RuntimeOrigin::signed(2),
vec![call_transfer(1, 5), call_transfer(1, 5),]
),);
));
System::assert_last_event(utility::Event::BatchCompleted.into());
assert_ok!(Utility::force_batch(RuntimeOrigin::signed(1), vec![call_transfer(2, 50),]),);
System::assert_last_event(utility::Event::BatchCompletedWithErrors.into());
});
}
#[test]
fn none_origin_does_not_work() {
new_test_ext().execute_with(|| {
assert_noop!(Utility::force_batch(RuntimeOrigin::none(), vec![]), BadOrigin);
assert_noop!(Utility::batch(RuntimeOrigin::none(), vec![]), BadOrigin);
assert_noop!(Utility::batch_all(RuntimeOrigin::none(), vec![]), BadOrigin);
})
}