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
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
Some minors
  • Loading branch information
kianenigma committed Nov 16, 2020
commit 530268ec870fdb2c1c22eea1fb5f0279835df10f
14 changes: 7 additions & 7 deletions frame/elections/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ parameter_types! {
}

frame_support::parameter_types_thread_local! {
static VoterBond: u64 = 0;
static VotingBond: u64 = 0;
static VotingFee: u64 = 0;
static PresentSlashPerVoter: u64 = 0;
static DecayRatio: u32 = 0;
Expand Down Expand Up @@ -122,7 +122,7 @@ impl elections::Trait for Test {
type LoserCandidate = ();
type ChangeMembers = TestChangeMembers;
type CandidacyBond = CandidacyBond;
type VotingBond = VoterBond;
type VotingBond = VotingBond;
type VotingFee = VotingFee;
type MinimumVotingLock = MinimumVotingLock;
type PresentSlashPerVoter = PresentSlashPerVoter;
Expand Down Expand Up @@ -154,7 +154,7 @@ pub struct ExtBuilder {
decay_ratio: u32,
desired_seats: u32,
voting_fee: u64,
voter_bond: u64,
voting_bond: u64,
bad_presentation_punishment: u64,
}

Expand All @@ -165,7 +165,7 @@ impl Default for ExtBuilder {
decay_ratio: 24,
desired_seats: 2,
voting_fee: 0,
voter_bond: 0,
voting_bond: 0,
bad_presentation_punishment: 1,
}
}
Expand All @@ -188,16 +188,16 @@ impl ExtBuilder {
self.bad_presentation_punishment = fee;
self
}
pub fn voter_bond(mut self, fee: u64) -> Self {
self.voter_bond = fee;
pub fn voting_bond(mut self, fee: u64) -> Self {
self.voting_bond = fee;
self
}
pub fn desired_seats(mut self, seats: u32) -> Self {
self.desired_seats = seats;
self
}
pub fn build(self) -> sp_io::TestExternalities {
VOTER_BOND.with(|v| *v.borrow_mut() = self.voter_bond);
VOTING_BOND.with(|v| *v.borrow_mut() = self.voting_bond);
VOTING_FEE.with(|v| *v.borrow_mut() = self.voting_fee);
PRESENT_SLASH_PER_VOTER.with(|v| *v.borrow_mut() = self.bad_presentation_punishment);
DECAY_RATIO.with(|v| *v.borrow_mut() = self.decay_ratio);
Expand Down
12 changes: 6 additions & 6 deletions frame/elections/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ fn voting_initial_set_approvals_ignores_voter_index() {
}
#[test]
fn voting_bad_approval_index_slashes_voters_and_bond_reduces_stake() {
ExtBuilder::default().voting_fee(5).voter_bond(2).build().execute_with(|| {
ExtBuilder::default().voting_fee(5).voting_bond(2).build().execute_with(|| {
assert_ok!(Elections::submit_candidacy(Origin::signed(2), 0));

(1..=63).for_each(|i| vote(i, 0));
Expand Down Expand Up @@ -365,7 +365,7 @@ fn voting_cannot_lock_less_than_limit() {

#[test]
fn voting_locking_more_than_total_balance_is_moot() {
ExtBuilder::default().voter_bond(2).build().execute_with(|| {
ExtBuilder::default().voting_bond(2).build().execute_with(|| {
assert_ok!(Elections::submit_candidacy(Origin::signed(2), 0));

assert_eq!(balances(&3), (30, 0));
Expand All @@ -381,7 +381,7 @@ fn voting_locking_more_than_total_balance_is_moot() {

#[test]
fn voting_locking_stake_and_reserving_bond_works() {
ExtBuilder::default().voter_bond(2).build().execute_with(|| {
ExtBuilder::default().voting_bond(2).build().execute_with(|| {
assert_ok!(Elections::submit_candidacy(Origin::signed(5), 0));

assert_eq!(balances(&2), (20, 0));
Expand Down Expand Up @@ -558,7 +558,7 @@ fn retracting_inactive_voter_should_work() {

#[test]
fn retracting_inactive_voter_with_other_candidates_in_slots_should_work() {
ExtBuilder::default().voter_bond(2).build().execute_with(|| {
ExtBuilder::default().voting_bond(2).build().execute_with(|| {
System::set_block_number(4);
assert_ok!(Elections::submit_candidacy(Origin::signed(2), 0));
assert_ok!(Elections::set_approvals(Origin::signed(2), vec![true], 0, 0, 20));
Expand Down Expand Up @@ -1107,7 +1107,7 @@ fn election_present_when_presenter_is_poor_should_not_work() {
let test_present = |p| {
ExtBuilder::default()
.voting_fee(5)
.voter_bond(2)
.voting_bond(2)
.bad_presentation_punishment(p)
.build()
.execute_with(|| {
Expand Down Expand Up @@ -1507,7 +1507,7 @@ fn pot_winning_resets_accumulated_pot() {
#[test]
fn pot_resubmitting_approvals_stores_pot() {
ExtBuilder::default()
.voter_bond(0)
.voting_bond(0)
.voting_fee(0)
.balance_factor(10)
.build()
Expand Down