mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 09:17:58 +00:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user