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
+3 -2
View File
@@ -22,7 +22,7 @@ use std::cell::RefCell;
use crate::{Module, Trait};
use sp_runtime::Perbill;
use sp_staking::{SessionIndex, offence::ReportOffence};
use sp_staking::{SessionIndex, offence::{ReportOffence, OffenceError}};
use sp_runtime::testing::{Header, UintAuthorityId, TestXt};
use sp_runtime::traits::{IdentityLookup, BlakeTwo256, ConvertInto};
use sp_core::H256;
@@ -77,8 +77,9 @@ thread_local! {
/// A mock offence report handler.
pub struct OffenceHandler;
impl ReportOffence<u64, IdentificationTuple, Offence> for OffenceHandler {
fn report_offence(reporters: Vec<u64>, offence: Offence) {
fn report_offence(reporters: Vec<u64>, offence: Offence) -> Result<(), OffenceError> {
OFFENCES.with(|l| l.borrow_mut().push((reporters, offence)));
Ok(())
}
}