Repository: paritytech/substrate
File: frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs (Rust)

Code before:
			assert_ok!(Staking::nominate(RuntimeOrigin::signed(20), vec![11]));
			assert_eq!(Nominators::<Runtime>::get(21).unwrap().targets, vec![11]);

			// validator is slashed. it is removed from the `VoterList` through chilling but in the
			// current era, the validator is still part of the active validator set.
			add_slash(&11);
			assert!(Session::validators().contains(&11));
			assert!(<Runtime as pallet_staking::Config>::VoterList::contains(&11) == false);
			assert_eq!(
				staking_events(),
				[
					Event::Chilled { stash: 11 },
					Event::ForceEra { mode: Forcing::ForceNew },
					Event::SlashReported {
						validator: 11,
						slash_era: 0,
						fraction: Perbill::from_percent(10)
					}
				],
			);

			// after the nominator is slashed and chilled, the nominations remain.
			assert_eq!(Nominators::<Runtime>::get(21).unwrap().targets, vec![11]);

			// validator sets intention to stake again in the same era it was chilled.
			assert_ok!(Staking::validate(RuntimeOrigin::signed(10), ValidatorPrefs::default()));

			// progress era and check that the slashed validator is still part of the validator
			// set.
			assert!(start_next_active_era().is_ok());
			assert_eq!(active_era(), 1);
			assert!(Session::validators().contains(&11));
			assert!(<Runtime as pallet_staking::Config>::VoterList::contains(&11));

			// nominations are still active as before the slash.
			assert_eq!(Nominators::<Runtime>::get(21).unwrap().targets, vec![11]);
		})
}


Review comment (suggestion):
```suggestion
			assert_ok!(Staking::validate(RuntimeOrigin::signed(10), Default::default()));
```

Code after:
			assert!(Session::validators().contains(&81));
			assert!(<Runtime as pallet_staking::Config>::VoterList::contains(&81));

			// nominate validator 81.
			assert_ok!(Staking::nominate(RuntimeOrigin::signed(21), vec![81]));
			assert_eq!(Nominators::<Runtime>::get(21).unwrap().targets, vec![81]);

			// validator is slashed. it is removed from the `VoterList` through chilling but in the
			// current era, the validator is still part of the active validator set.
			add_slash(&81);
			assert!(Session::validators().contains(&81));
			assert!(!<Runtime as pallet_staking::Config>::VoterList::contains(&81));
			assert_eq!(
				staking_events(),
				[
					Event::Chilled { stash: 81 },
					Event::ForceEra { mode: Forcing::ForceNew },
					Event::SlashReported {
						validator: 81,
						slash_era: 0,
						fraction: Perbill::from_percent(10)
					}
				],
			);

			// after the nominator is slashed and chilled, the nominations remain.
			assert_eq!(Nominators::<Runtime>::get(21).unwrap().targets, vec![81]);

			// validator sets intention to stake again in the same era it was chilled.
			assert_ok!(Staking::validate(RuntimeOrigin::signed(81), Default::default()));

			// progress era and check that the slashed validator is still part of the validator
			// set.
			assert!(start_next_active_era().is_ok());
			assert_eq!(active_era(), 1);
			assert!(Session::validators().contains(&81));
			assert!(<Runtime as pallet_staking::Config>::VoterList::contains(&81));

			// nominations are still active as before the slash.
			assert_eq!(Nominators::<Runtime>::get(21).unwrap().targets, vec![81]);
		})
}