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
Fix tests.
  • Loading branch information
gavofyork committed Aug 22, 2018
commit 71920016a181ab9e1400749e25cf9a4a57d23402
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