mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 05:51:02 +00:00
Prevent events from being emitted during genesis construction (#5463)
* Don't populate runtime events in genesis * typo * Change to block zero * Fix vesting tests * Update frame/system/src/lib.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update frame/system/src/lib.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Add test * Fix test * Fix contract tests * Fix phragmen tests * Fix Generic Assets Tests * Fix offences tests * Fix im-online * fix recovery * Fix utility tests * Shorter * Use ext Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -1040,7 +1040,7 @@ mod tests {
|
||||
VOTING_BOND.with(|v| *v.borrow_mut() = self.voter_bond);
|
||||
TERM_DURATION.with(|v| *v.borrow_mut() = self.term_duration);
|
||||
DESIRED_RUNNERS_UP.with(|v| *v.borrow_mut() = self.desired_runners_up);
|
||||
GenesisConfig {
|
||||
let mut ext: sp_io::TestExternalities = GenesisConfig {
|
||||
pallet_balances: Some(pallet_balances::GenesisConfig::<Test>{
|
||||
balances: vec![
|
||||
(1, 10 * self.balance_factor),
|
||||
@@ -1051,7 +1051,9 @@ mod tests {
|
||||
(6, 60 * self.balance_factor)
|
||||
],
|
||||
}),
|
||||
}.build_storage().unwrap().into()
|
||||
}.build_storage().unwrap().into();
|
||||
ext.execute_with(|| System::set_block_number(1));
|
||||
ext
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1072,7 +1074,6 @@ mod tests {
|
||||
#[test]
|
||||
fn params_should_work() {
|
||||
ExtBuilder::default().build().execute_with(|| {
|
||||
System::set_block_number(1);
|
||||
assert_eq!(Elections::desired_members(), 2);
|
||||
assert_eq!(Elections::term_duration(), 5);
|
||||
assert_eq!(Elections::election_rounds(), 0);
|
||||
@@ -1096,7 +1097,6 @@ mod tests {
|
||||
.build()
|
||||
.execute_with(||
|
||||
{
|
||||
System::set_block_number(1);
|
||||
assert_eq!(Elections::term_duration(), 0);
|
||||
assert_eq!(Elections::desired_members(), 2);
|
||||
assert_eq!(Elections::election_rounds(), 0);
|
||||
@@ -1537,10 +1537,9 @@ mod tests {
|
||||
assert_eq!(balances(&5), (45, 5));
|
||||
|
||||
assert_ok!(Elections::report_defunct_voter(Origin::signed(5), 3));
|
||||
assert_eq!(
|
||||
System::events()[7].event,
|
||||
Event::elections(RawEvent::VoterReported(3, 5, true))
|
||||
);
|
||||
assert!(System::events().iter().any(|event| {
|
||||
event.event == Event::elections(RawEvent::VoterReported(3, 5, true))
|
||||
}));
|
||||
|
||||
assert_eq!(balances(&3), (28, 0));
|
||||
assert_eq!(balances(&5), (47, 5));
|
||||
@@ -1566,10 +1565,9 @@ mod tests {
|
||||
assert_eq!(balances(&5), (45, 5));
|
||||
|
||||
assert_ok!(Elections::report_defunct_voter(Origin::signed(5), 4));
|
||||
assert_eq!(
|
||||
System::events()[7].event,
|
||||
Event::elections(RawEvent::VoterReported(4, 5, false))
|
||||
);
|
||||
assert!(System::events().iter().any(|event| {
|
||||
event.event == Event::elections(RawEvent::VoterReported(4, 5, false))
|
||||
}));
|
||||
|
||||
assert_eq!(balances(&4), (35, 5));
|
||||
assert_eq!(balances(&5), (45, 3));
|
||||
@@ -1977,10 +1975,9 @@ mod tests {
|
||||
// 5 is an outgoing loser. will also get slashed.
|
||||
assert_eq!(balances(&5), (45, 2));
|
||||
|
||||
assert_eq!(
|
||||
System::events()[6].event,
|
||||
Event::elections(RawEvent::NewTerm(vec![(4, 40), (5, 50)])),
|
||||
);
|
||||
assert!(System::events().iter().any(|event| {
|
||||
event.event == Event::elections(RawEvent::NewTerm(vec![(4, 40), (5, 50)]))
|
||||
}));
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user