pallet-sudo: Accept Root origin as valid sudo (#2783)

This changes `pallet-sudo` to also accept `Root` origin for
`ensure_sudo`. This can be useful for parachains who allow the relay
chain to have superuser rights to setup the sudo pallet for example.
This commit is contained in:
Bastian Köcher
2023-12-22 09:58:32 +01:00
committed by GitHub
parent 46dd4b8f53
commit 96bec7a7ab
3 changed files with 32 additions and 4 deletions
+12
View File
@@ -169,6 +169,18 @@ fn remove_key_works() {
});
}
#[test]
fn using_root_origin_works() {
new_test_ext(1).execute_with(|| {
assert_ok!(Sudo::remove_key(RuntimeOrigin::root()));
assert!(Sudo::key().is_none());
System::assert_has_event(TestEvent::Sudo(Event::KeyRemoved {}));
assert_ok!(Sudo::set_key(RuntimeOrigin::root(), 1));
assert_eq!(Some(1), Sudo::key());
});
}
#[test]
fn sudo_as_basics() {
new_test_ext(1).execute_with(|| {