Skip to content

Commit

Permalink
sudo_as should return a result (paritytech#7620)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawntabrizi authored and darkfriend77 committed Jan 11, 2021
1 parent 97aa0c7 commit d348970
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions frame/sudo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,9 @@ decl_module! {

let who = T::Lookup::lookup(who)?;

let res = match call.dispatch_bypass_filter(frame_system::RawOrigin::Signed(who).into()) {
Ok(_) => true,
Err(e) => {
sp_runtime::print(e);
false
}
};
let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Signed(who).into());

Self::deposit_event(RawEvent::SudoAsDone(res));
Self::deposit_event(RawEvent::SudoAsDone(res.map(|_| ()).map_err(|e| e.error)));
// Sudo user does not pay a fee.
Ok(Pays::No.into())
}
Expand All @@ -236,7 +230,7 @@ decl_event!(
/// The \[sudoer\] just switched identity; the old key is supplied.
KeyChanged(AccountId),
/// A sudo just took place. \[result\]
SudoAsDone(bool),
SudoAsDone(DispatchResult),
}
);

Expand Down
2 changes: 1 addition & 1 deletion frame/sudo/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fn sudo_as_emits_events_correctly() {
// A non-privileged function will work when passed to `sudo_as` with the root `key`.
let call = Box::new(Call::Logger(LoggerCall::non_privileged_log(42, 1)));
assert_ok!(Sudo::sudo_as(Origin::signed(1), 2, call));
let expected_event = TestEvent::sudo(RawEvent::SudoAsDone(true));
let expected_event = TestEvent::sudo(RawEvent::SudoAsDone(Ok(())));
assert!(System::events().iter().any(|a| a.event == expected_event));
});
}

0 comments on commit d348970

Please sign in to comment.