Rename all the election operations (#6245)

* Rename and move sp-phragmen

* More renames for equalise

* Update main module doc

* Fix line width

* Line width
This commit is contained in:
Kian Paimani
2020-06-05 17:33:13 +02:00
committed by GitHub
parent d63b8e0da0
commit 8a8b4f99c3
35 changed files with 296 additions and 322 deletions
+4 -39
View File
@@ -406,41 +406,6 @@ fn no_candidate_emergency_condition() {
#[test]
fn nominating_and_rewards_should_work() {
// PHRAGMEN OUTPUT: running this test with the reference impl gives:
//
// Sequential Phragmén gives
// 10 is elected with stake 2200.0 and score 0.0003333333333333333
// 20 is elected with stake 1800.0 and score 0.0005555555555555556
// 10 has load 0.0003333333333333333 and supported
// 10 with stake 1000.0
// 20 has load 0.0005555555555555556 and supported
// 20 with stake 1000.0
// 30 has load 0 and supported
// 30 with stake 0
// 40 has load 0 and supported
// 40 with stake 0
// 2 has load 0.0005555555555555556 and supported
// 10 with stake 600.0 20 with stake 400.0 30 with stake 0.0
// 4 has load 0.0005555555555555556 and supported
// 10 with stake 600.0 20 with stake 400.0 40 with stake 0.0
// Sequential Phragmén with post processing gives
// 10 is elected with stake 2000.0 and score 0.0003333333333333333
// 20 is elected with stake 2000.0 and score 0.0005555555555555556
// 10 has load 0.0003333333333333333 and supported
// 10 with stake 1000.0
// 20 has load 0.0005555555555555556 and supported
// 20 with stake 1000.0
// 30 has load 0 and supported
// 30 with stake 0
// 40 has load 0 and supported
// 40 with stake 0
// 2 has load 0.0005555555555555556 and supported
// 10 with stake 400.0 20 with stake 600.0 30 with stake 0
// 4 has load 0.0005555555555555556 and supported
// 10 with stake 600.0 20 with stake 400.0 40 with stake 0.0
ExtBuilder::default()
.nominate(false)
.validator_pool(true)
@@ -477,7 +442,7 @@ fn nominating_and_rewards_should_work() {
mock::start_era(1);
// 10 and 20 have more votes, they will be chosen by phragmen.
// 10 and 20 have more votes, they will be chosen.
assert_eq_uvec!(validator_controllers(), vec![20, 10]);
// OLD validators must have already received some rewards.
@@ -2765,7 +2730,7 @@ mod offchain_phragmen {
OffchainExt, TransactionPoolExt,
};
use sp_io::TestExternalities;
use sp_phragmen::StakedAssignment;
use sp_npos_elections::StakedAssignment;
use frame_support::traits::OffchainWorker;
use std::sync::Arc;
use substrate_test_utils::assert_eq_uvec;
@@ -2822,7 +2787,7 @@ mod offchain_phragmen {
origin: Origin,
winners: Vec<ValidatorIndex>,
compact: CompactAssignments,
score: PhragmenScore,
score: ElectionScore,
) -> DispatchResultWithPostInfo {
Staking::submit_election_solution(
origin,
@@ -3355,7 +3320,7 @@ mod offchain_phragmen {
&inner,
),
TransactionValidity::Ok(ValidTransaction {
// the proposed slot stake, with equalize.
// the proposed slot stake, with balance_solution.
priority: UnsignedPriority::get() + 1250,
requires: vec![],
provides: vec![("StakingOffchain", active_era()).encode()],