Offence reporting returns a result (#5082)

* Offence reporting returns a result

* Bump spec_version

* Use unwrap instead of assertions

* Fix more review grumbles
This commit is contained in:
Fedor Sakharov
2020-03-02 13:00:38 +03:00
committed by GitHub
parent d7e4aa41b9
commit 8539b85c99
7 changed files with 51 additions and 22 deletions
+10 -10
View File
@@ -40,7 +40,7 @@ fn should_report_an_authority_and_trigger_on_offence() {
};
// when
Offences::report_offence(vec![], offence);
Offences::report_offence(vec![], offence).unwrap();
// then
with_on_offence_fractions(|f| {
@@ -61,7 +61,7 @@ fn should_not_report_the_same_authority_twice_in_the_same_slot() {
time_slot,
offenders: vec![5],
};
Offences::report_offence(vec![], offence.clone());
Offences::report_offence(vec![], offence.clone()).unwrap();
with_on_offence_fractions(|f| {
assert_eq!(f.clone(), vec![Perbill::from_percent(25)]);
f.clear();
@@ -69,7 +69,7 @@ fn should_not_report_the_same_authority_twice_in_the_same_slot() {
// when
// report for the second time
Offences::report_offence(vec![], offence);
assert_eq!(Offences::report_offence(vec![], offence), Err(OffenceError::DuplicateReport));
// then
with_on_offence_fractions(|f| {
@@ -91,7 +91,7 @@ fn should_report_in_different_time_slot() {
time_slot,
offenders: vec![5],
};
Offences::report_offence(vec![], offence.clone());
Offences::report_offence(vec![], offence.clone()).unwrap();
with_on_offence_fractions(|f| {
assert_eq!(f.clone(), vec![Perbill::from_percent(25)]);
f.clear();
@@ -100,7 +100,7 @@ fn should_report_in_different_time_slot() {
// when
// report for the second time
offence.time_slot += 1;
Offences::report_offence(vec![], offence);
Offences::report_offence(vec![], offence).unwrap();
// then
with_on_offence_fractions(|f| {
@@ -123,7 +123,7 @@ fn should_deposit_event() {
};
// when
Offences::report_offence(vec![], offence);
Offences::report_offence(vec![], offence).unwrap();
// then
assert_eq!(
@@ -149,7 +149,7 @@ fn doesnt_deposit_event_for_dups() {
time_slot,
offenders: vec![5],
};
Offences::report_offence(vec![], offence.clone());
Offences::report_offence(vec![], offence.clone()).unwrap();
with_on_offence_fractions(|f| {
assert_eq!(f.clone(), vec![Perbill::from_percent(25)]);
f.clear();
@@ -157,7 +157,7 @@ fn doesnt_deposit_event_for_dups() {
// when
// report for the second time
Offences::report_offence(vec![], offence);
assert_eq!(Offences::report_offence(vec![], offence), Err(OffenceError::DuplicateReport));
// then
// there is only one event.
@@ -191,7 +191,7 @@ fn should_properly_count_offences() {
time_slot,
offenders: vec![4],
};
Offences::report_offence(vec![], offence1);
Offences::report_offence(vec![], offence1).unwrap();
with_on_offence_fractions(|f| {
assert_eq!(f.clone(), vec![Perbill::from_percent(25)]);
f.clear();
@@ -199,7 +199,7 @@ fn should_properly_count_offences() {
// when
// report for the second time
Offences::report_offence(vec![], offence2);
Offences::report_offence(vec![], offence2).unwrap();
// then
// the 1st authority should have count 2 and the 2nd one should be reported only once.