Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion frame/staking/src/pallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ pub mod pallet {
Chilled(T::AccountId),
/// The stakers' rewards are getting paid. \[era_index, validator_stash\]
PayoutStarted(EraIndex, T::AccountId),
/// A validator has set their preferences.
ValidatorPrefsSet(T::AccountId, ValidatorPrefs),
}

#[pallet::error]
Expand Down Expand Up @@ -1016,7 +1018,9 @@ pub mod pallet {
}

Self::do_remove_nominator(stash);
Self::do_add_validator(stash, prefs);
Self::do_add_validator(stash, prefs.clone());
Self::deposit_event(Event::<T>::ValidatorPrefsSet(ledger.stash, prefs));

Ok(())
}

Expand Down
10 changes: 10 additions & 0 deletions frame/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4598,11 +4598,21 @@ fn capped_stakers_works() {
#[test]
fn min_commission_works() {
ExtBuilder::default().build_and_execute(|| {
// account 10 controls the stash from account 11
assert_ok!(Staking::validate(
Origin::signed(10),
ValidatorPrefs { commission: Perbill::from_percent(5), blocked: false }
));

// event emitted should be correct
assert_eq!(
*staking_events().last().unwrap(),
Event::ValidatorPrefsSet(
11,
ValidatorPrefs { commission: Perbill::from_percent(5), blocked: false }
)
);

assert_ok!(Staking::set_staking_configs(
Origin::root(),
ConfigOp::Remove,
Expand Down