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
Additional checks to delayed solution eras and mock fixes
  • Loading branch information
gpestana committed Mar 15, 2023
commit 40ac80f5d510a8633733f58c99e1b9867e07862b
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#![cfg(test)]
mod mock;

pub(crate) const LOG_TARGET: &str = "tests::epm";
pub(crate) const LOG_TARGET: &str = "tests::e2e-epm";

use mock::*;
use sp_npos_elections::{to_supports, StakedAssignment};
Expand Down Expand Up @@ -70,7 +70,7 @@ fn setup_works() {
/// Replicates the Kusama incident of 8th Dec 2022 and its resolution through the governance
/// fallback.
///
/// After enough slashes to exceed the `Staking::OffendingValidatorsThreshold`, the staking pallet
/// After enough slashes exceeded the `Staking::OffendingValidatorsThreshold`, the staking pallet
/// set `Forcing::ForceNew`. When a new session starts, staking will start to force a new era and
/// calls <EPM as election_provider>::elect(). If at this point EPM and the staking miners did not
/// have enough time to queue a new solution (snapshot + solution submission), the election request
Expand Down Expand Up @@ -103,9 +103,12 @@ fn enters_emergency_phase_after_forcing_before_elect() {
assert!(ElectionProviderMultiPhase::current_phase().is_emergency());
log_current_time();

let era_before_delayed_next = Staking::current_era();
// try to advance 2 eras with a delayed solution.
assert!(start_next_active_era_delayed_solution().is_ok());
assert_eq!(Staking::current_era(), era_before_delayed_next);
assert!(start_next_active_era_delayed_solution().is_ok());
assert_eq!(Staking::current_era(), era_before_delayed_next);

// EPM is still in emergency phase.
assert!(ElectionProviderMultiPhase::current_phase().is_emergency());
Expand All @@ -131,6 +134,7 @@ fn enters_emergency_phase_after_forcing_before_elect() {
log_current_time();
assert!(ElectionProviderMultiPhase::current_phase().is_signed());
assert_eq!(Session::validators(), vec![21, 31, 41]);
assert_eq!(Staking::current_era(), era_before_delayed_next.map(|e| e + 1));
});
}

Expand Down
31 changes: 13 additions & 18 deletions frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type MaxElectableTargets = MaxElectableTargets;
type MaxElectingVoters = MaxElectingVoters;
type MaxWinners = MaxWinners;
type BenchmarkingConfig = ElectionProviderBenchmarkConfig;
type BenchmarkingConfig = NoopElectionProviderBenchmarkConfig;
type WeightInfo = ();
}

Expand Down Expand Up @@ -278,7 +278,7 @@ impl pallet_staking::Config for Runtime {
type HistoryDepth = HistoryDepth;
type OnStakerSlash = ();
type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>;
type BenchmarkingConfig = StakingBenchmarkingConfig;
type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig;
}

impl<LocalCall> frame_system::offchain::SendTransactionTypes<LocalCall> for Runtime
Expand Down Expand Up @@ -309,22 +309,18 @@ impl onchain::Config for OnChainSeqPhragmen {
type TargetsBound = TargetsBound;
}

pub struct StakingBenchmarkingConfig;
impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig {
type MaxNominators = traits::ConstU32<1000>;
type MaxValidators = traits::ConstU32<1000>;
}

pub struct ElectionProviderBenchmarkConfig;
pub struct NoopElectionProviderBenchmarkConfig;

impl pallet_election_provider_multi_phase::BenchmarkingConfig for ElectionProviderBenchmarkConfig {
const VOTERS: [u32; 2] = [1000, 2000];
const TARGETS: [u32; 2] = [500, 1000];
const ACTIVE_VOTERS: [u32; 2] = [500, 800];
const DESIRED_TARGETS: [u32; 2] = [200, 400];
const SNAPSHOT_MAXIMUM_VOTERS: u32 = 1000;
const MINER_MAXIMUM_VOTERS: u32 = 1000;
const MAXIMUM_TARGETS: u32 = 300;
impl pallet_election_provider_multi_phase::BenchmarkingConfig
for NoopElectionProviderBenchmarkConfig
{
const VOTERS: [u32; 2] = [0, 0];
const TARGETS: [u32; 2] = [0, 0];
const ACTIVE_VOTERS: [u32; 2] = [0, 0];
const DESIRED_TARGETS: [u32; 2] = [0, 0];
const SNAPSHOT_MAXIMUM_VOTERS: u32 = 0;
const MINER_MAXIMUM_VOTERS: u32 = 0;
const MAXIMUM_TARGETS: u32 = 0;
}

pub struct OtherSessionHandler;
Expand Down Expand Up @@ -384,7 +380,6 @@ impl Default for ExtBuilder {
}
}


impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
sp_tracing::try_init_simple();
Expand Down