Rb staking pallet validator commission change event (#10827)

* commission-changed-event-and-deposit

* deposit_event fix

* commission_changed_event_works

* fmt

* CommissionChanged -> ValidatorPrefsUpdated

* event ValidatorPrefs

* updated commet

* fmt

* Update frame/staking/src/pallet/mod.rs

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Update frame/staking/src/pallet/mod.rs

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Update frame/staking/src/tests.rs

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
This commit is contained in:
Ross Bulat
2022-04-14 17:25:54 +01:00
committed by GitHub
parent e5c33d8aa4
commit c56e8f684f
2 changed files with 15 additions and 1 deletions
+5 -1
View File
@@ -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]
@@ -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(())
}
+10
View File
@@ -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,