Skip to content
Snippets Groups Projects
Unverified Commit ad373259 authored by Branislav Kontur's avatar Branislav Kontur
Browse files

Align error codes with other pallets

parent a699970c
Branches
No related merge requests found
Pipeline #516311 waiting for manual action with stages
in 1 hour, 27 minutes, and 4 seconds
......@@ -720,8 +720,10 @@ pub mod pallet {
CannotUpgradeCode,
/// Invalid validation code size.
InvalidCode,
/// The given code is not authorized.
NotAuthorizedCode,
/// No upgrade authorized.
NothingAuthorized,
/// The submitted code is not authorized.
Unauthorized,
}
/// All currently active PVF pre-checking votes.
......@@ -1214,13 +1216,9 @@ pub mod pallet {
// no need to ensure, anybody can do this
// Ensure `new_code` is authorized
if let Some(authorized_code_hash) = AuthorizedCodeHash::<T>::take(&para) {
if new_code.hash() != authorized_code_hash {
return Err(Error::<T>::NotAuthorizedCode.into());
}
} else {
return Err(Error::<T>::NotAuthorizedCode.into());
}
let authorized_code_hash =
AuthorizedCodeHash::<T>::take(&para).ok_or(Error::<T>::NothingAuthorized)?;
ensure!(authorized_code_hash == new_code.hash(), Error::<T>::Unauthorized);
// TODO: FAIL-CI - more validations?
......
......@@ -2041,7 +2041,7 @@ fn authorize_and_apply_set_current_code_works() {
para_a,
code_1.clone()
),
Error::<Test>::NotAuthorizedCode,
Error::<Test>::NothingAuthorized,
);
// non-root user cannot authorize
......@@ -2066,7 +2066,7 @@ fn authorize_and_apply_set_current_code_works() {
para_a,
code_2.clone()
),
Error::<Test>::NotAuthorizedCode,
Error::<Test>::Unauthorized,
);
assert_eq!(AuthorizedCodeHash::<Test>::get(para_a), Some(code_1_hash));
assert!(CurrentCodeHash::<Test>::get(para_a).is_none());
......@@ -2111,7 +2111,7 @@ fn authorize_and_apply_set_current_code_works() {
para_a,
code_1.clone()
),
Error::<Test>::NotAuthorizedCode,
Error::<Test>::Unauthorized,
);
assert_err!(
Paras::apply_authorized_force_set_current_code(
......@@ -2119,7 +2119,7 @@ fn authorize_and_apply_set_current_code_works() {
para_a,
code_2.clone()
),
Error::<Test>::NotAuthorizedCode,
Error::<Test>::Unauthorized,
);
// apply just authorized
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment