Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
0aab5c65
Commit
0aab5c65
authored
5 years ago
by
Kian Paimani
Committed by
Bastian Köcher
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Few extra tests for phragmen (#4451)
parent
216f77d9
Branches
gh-readonly-queue/master/pr-7177-f5673cf260ba08fbc04667b1fcd0e635d87e6451
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/primitives/phragmen/src/tests.rs
+51
-0
51 additions, 0 deletions
substrate/primitives/phragmen/src/tests.rs
with
51 additions
and
0 deletions
substrate/primitives/phragmen/src/tests.rs
+
51
−
0
View file @
0aab5c65
...
...
@@ -354,3 +354,54 @@ fn phragmen_linear_equalize() {
run_and_compare
(
candidates
,
voters
,
stake_of
,
2
,
2
);
}
#[test]
fn
elect_has_no_entry_barrier
()
{
let
candidates
=
vec!
[
10
,
20
,
30
];
let
voters
=
vec!
[
(
1
,
vec!
[
10
]),
(
2
,
vec!
[
20
]),
];
let
stake_of
=
create_stake_of
(
&
[
(
1
,
10
),
(
2
,
10
),
]);
let
PhragmenResult
{
winners
,
assignments
:
_
}
=
elect
::
<
_
,
_
,
_
,
TestCurrencyToVote
>
(
3
,
3
,
candidates
,
voters
,
stake_of
,
)
.unwrap
();
// 30 is elected with stake 0. The caller is responsible for stripping this.
assert_eq_uvec!
(
winners
,
vec!
[
(
10
,
10
),
(
20
,
10
),
(
30
,
0
),
]);
}
#[test]
fn
minimum_to_elect_is_respected
()
{
let
candidates
=
vec!
[
10
,
20
,
30
];
let
voters
=
vec!
[
(
1
,
vec!
[
10
]),
(
2
,
vec!
[
20
]),
];
let
stake_of
=
create_stake_of
(
&
[
(
1
,
10
),
(
2
,
10
),
]);
let
maybe_result
=
elect
::
<
_
,
_
,
_
,
TestCurrencyToVote
>
(
10
,
10
,
candidates
,
voters
,
stake_of
,
);
assert!
(
maybe_result
.is_none
());
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment