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 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cb10d13
EPM and staking pallets: Adds new crate for integration tests
gpestana Dec 14, 2022
3ec1541
Adds ExtBuilder and helpers with initial conditions assertions
gpestana Dec 16, 2022
b818b29
removes account helpers; adds staking, session, etc genesis
gpestana Jan 1, 2023
624c728
Adds kusama incident test case
gpestana Jan 2, 2023
73197ae
Prepare for slashing test
gpestana Jan 5, 2023
762b0c0
Adds solution submission
gpestana Jan 6, 2023
869b677
slash_through_offending_threshold
gpestana Jan 6, 2023
eeb0438
Renames e2e integration tests dir and crate
gpestana Jan 8, 2023
888fa74
consistently slash 10% of validator set
gpestana Jan 9, 2023
8e73538
finishes continous_slashes_below_offending_threshold test
gpestana Jan 9, 2023
632e209
Update frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs
gpestana Mar 13, 2023
ffc9aae
Update frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs
gpestana Mar 13, 2023
81b2275
Update frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs
gpestana Mar 13, 2023
b3c6e98
Update frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs
gpestana Mar 15, 2023
a1dcd6c
Update frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs
gpestana Mar 15, 2023
79d8d4b
Update frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs
gpestana Mar 15, 2023
ac52c0b
mock fixes
gpestana Mar 15, 2023
40ac80f
Additional checks to delayed solution eras and mock fixes
gpestana Mar 15, 2023
f1de0a9
nits and addresses review comments; splits ext_builder into one per p…
gpestana Mar 15, 2023
84dfba6
helper to set balances ext builder
gpestana Mar 15, 2023
3597015
Merge branch 'master' into gpestana/9057-EPM-integration-tests
gpestana Mar 15, 2023
9829cc1
bring up mock.rs to master
gpestana Mar 15, 2023
3eb15b6
integration test fixes and additions
gpestana Mar 16, 2023
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
Prev Previous commit
Next Next commit
nits and addresses review comments; splits ext_builder into one per p…
…allet
  • Loading branch information
gpestana committed Mar 15, 2023
commit f1de0a937aaa996accbc0b87d1072dba06b70d6d
67 changes: 33 additions & 34 deletions frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn log_current_time() {

#[test]
fn setup_works() {
ExtBuilder::default().initialize_first_session(true).build_and_execute(|| {
ExtBuilder::default().build_and_execute(|| {
assert_eq!(active_era(), 0);

assert!(start_next_active_era().is_ok());
Expand Down Expand Up @@ -81,7 +81,7 @@ fn setup_works() {
/// solution is added to the queue, EPM phase transitions to `Phase::Off` and the election flow
/// restarts.
fn enters_emergency_phase_after_forcing_before_elect() {
ExtBuilder::default().initialize_first_session(true).build_and_execute(|| {
ExtBuilder::default().build_and_execute(|| {
log!(
trace,
"current validators (staking): {:?}",
Expand Down Expand Up @@ -149,37 +149,36 @@ fn enters_emergency_phase_after_forcing_before_elect() {
/// the subsequent elections do not meet the minimum election untrusted score, the election will
/// fail and enter in emenergency mode.
fn continous_slashes_below_offending_threshold() {
ExtBuilder::default()
.initialize_first_session(true)
.validator_count(10)
.build_and_execute(|| {
assert_eq!(Session::validators().len(), 10);
let mut active_validator_set = Session::validators();

// set a minimum election score.
assert!(set_minimum_election_score(500, 1000, 500).is_ok());

// slash 10% of the active validators and progress era until the minimum trusted score
// is reached.
while active_validator_set.len() > 0 {
let slashed = slash_percentage(Perbill::from_percent(10));
assert_eq!(slashed.len(), 1);

// break loop when era does not progress; EPM is in emergency phase as election
// failed due to election minimum score.
if start_next_active_era().is_err() {
assert!(ElectionProviderMultiPhase::current_phase().is_emergency());
break
}

active_validator_set = Session::validators();

log!(
trace,
"slashed 10% of active validators ({:?}). After slash: {:?}",
slashed,
active_validator_set
);
let staking_builder = StakingExtBuilder::default().validator_count(10);

ExtBuilder::default().staking(staking_builder).build_and_execute(|| {
assert_eq!(Session::validators().len(), 10);
let mut active_validator_set = Session::validators();

// set a minimum election score.
assert!(set_minimum_election_score(500, 1000, 500).is_ok());

// slash 10% of the active validators and progress era until the minimum trusted score
// is reached.
while active_validator_set.len() > 0 {
let slashed = slash_percentage(Perbill::from_percent(10));
assert_eq!(slashed.len(), 1);

// break loop when era does not progress; EPM is in emergency phase as election
// failed due to election minimum score.
if start_next_active_era().is_err() {
assert!(ElectionProviderMultiPhase::current_phase().is_emergency());
break
}
});

active_validator_set = Session::validators();

log!(
trace,
"slashed 10% of active validators ({:?}). After slash: {:?}",
slashed,
active_validator_set
);
}
});
}
Loading