Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
gavofyork committed Aug 22, 2018
1 parent b85cb38 commit 7192001
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
2 changes: 1 addition & 1 deletion substrate/runtime/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub fn new_test_ext(ext_deposit: u64, session_length: u64, sessions_per_era: u64
} else {
vec![(10, balance_factor), (20, balance_factor)]
},
intentions: vec![],
intentions: vec![10, 20],
validator_count: 2,
minimum_validator_count: 0,
bonding_duration: 3,
Expand Down
17 changes: 2 additions & 15 deletions substrate/runtime/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ fn note_missed_proposal_force_unstake_session_change_should_work() {
with_externalities(&mut new_test_ext(0, 3, 3, 0, true, 10), || {
Staking::set_free_balance(&10, 70);
Staking::set_free_balance(&20, 70);
assert_ok!(Staking::stake(&10));
assert_ok!(Staking::stake(&20));
assert_ok!(Staking::stake(&1));

assert_eq!(Staking::slash_count(&10), 0);
Expand All @@ -123,8 +121,6 @@ fn note_missed_proposal_auto_unstake_session_change_should_work() {
with_externalities(&mut new_test_ext(0, 3, 3, 0, true, 10), || {
Staking::set_free_balance(&10, 7000);
Staking::set_free_balance(&20, 7000);
assert_ok!(Staking::stake(&10));
assert_ok!(Staking::stake(&20));
assert_ok!(Staking::register_slash_preference(&10, 0, SlashPreference { unstake_threshold: 1 }));

assert_eq!(Staking::intentions(), vec![10, 20]);
Expand Down Expand Up @@ -205,25 +201,20 @@ fn slashing_should_work() {
assert_eq!(Staking::voting_balance(&10), 1);

System::set_block_number(3);
Timestamp::set_timestamp(15); // on time.
Session::check_rotate_session();
assert_eq!(Staking::current_era(), 0);
assert_eq!(Session::current_index(), 1);
assert_eq!(Staking::voting_balance(&10), 11);

System::set_block_number(6);
Timestamp::set_timestamp(30); // on time.
Session::check_rotate_session();
assert_eq!(Staking::current_era(), 0);
assert_eq!(Session::current_index(), 2);
assert_eq!(Staking::voting_balance(&10), 21);

System::set_block_number(7);
::system::ExtrinsicIndex::<Test>::put(1);
Session::note_offline(&0, vec![0]).unwrap(); // val 10 reported bad.
Session::check_rotate_session();
assert_eq!(Staking::current_era(), 1);
assert_eq!(Session::current_index(), 3);
assert_ok!(Staking::note_missed_proposal(&Default::default(), vec![0, 1]));
assert_eq!(Staking::voting_balance(&10), 1);
});
}
Expand Down Expand Up @@ -444,11 +435,7 @@ fn nominating_slashes_should_work() {

System::set_block_number(5);
::system::ExtrinsicIndex::<Test>::put(1);
Session::note_offline(&0, vec![0, 1]).unwrap(); // both get reported offline.
assert_eq!(Session::blocks_remaining(), 1);
Session::check_rotate_session();

assert_eq!(Staking::current_era(), 2);
assert_ok!(Staking::note_missed_proposal(&Default::default(), vec![0, 1]));
assert_eq!(Staking::voting_balance(&1), 0);
assert_eq!(Staking::voting_balance(&2), 20);
assert_eq!(Staking::voting_balance(&3), 10);
Expand Down

0 comments on commit 7192001

Please sign in to comment.