mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 06:57:58 +00:00
Offences report system rework (#13425)
* Experiments with common equivocation trait * Improved equivocation trait * Fix grandpa equivocation implementation * Remove some cruft * Remove some more cruft * More generic naming * Simplification of offences manipilation * More refactory * Some prograss with the encapsulation of offence report system * Finally unit type works as a universal null report system * Align substrate node code * Further simplification * Fix test utils * Remove not required associated type * Fix benches * Rollback to prev field name * Box big params * Fix typo * Remove new tag computation * Remove default implementations * Better docs * Return 'Result' instead of bool * Change offence report system return types * Some renaming and documentation * Improve documentation * More abstract offence report system * Rename 'consume_evidence' to 'process_evidence' * Further docs refinements * Doc for dummy offence report * Fix rustdoc * Fix after master merge * Apply code review suggestions * Improve docs
This commit is contained in:
@@ -160,20 +160,18 @@ fn doesnt_deposit_event_for_dups() {
|
||||
|
||||
#[test]
|
||||
fn reports_if_an_offence_is_dup() {
|
||||
type TestOffence = Offence<u64>;
|
||||
|
||||
new_test_ext().execute_with(|| {
|
||||
let time_slot = 42;
|
||||
assert_eq!(offence_reports(KIND, time_slot), vec![]);
|
||||
|
||||
let offence =
|
||||
|time_slot, offenders| TestOffence { validator_set_count: 5, time_slot, offenders };
|
||||
|time_slot, offenders| Offence { validator_set_count: 5, time_slot, offenders };
|
||||
|
||||
let mut test_offence = offence(time_slot, vec![0]);
|
||||
|
||||
// the report for authority 0 at time slot 42 should not be a known
|
||||
// offence
|
||||
assert!(!<Offences as ReportOffence<_, _, TestOffence>>::is_known_offence(
|
||||
assert!(!<Offences as ReportOffence<_, _, Offence>>::is_known_offence(
|
||||
&test_offence.offenders,
|
||||
&test_offence.time_slot
|
||||
));
|
||||
@@ -182,7 +180,7 @@ fn reports_if_an_offence_is_dup() {
|
||||
Offences::report_offence(vec![], test_offence.clone()).unwrap();
|
||||
|
||||
// the same report should be a known offence now
|
||||
assert!(<Offences as ReportOffence<_, _, TestOffence>>::is_known_offence(
|
||||
assert!(<Offences as ReportOffence<_, _, Offence>>::is_known_offence(
|
||||
&test_offence.offenders,
|
||||
&test_offence.time_slot
|
||||
));
|
||||
@@ -197,7 +195,7 @@ fn reports_if_an_offence_is_dup() {
|
||||
test_offence.offenders.push(1);
|
||||
|
||||
// it should not be a known offence anymore
|
||||
assert!(!<Offences as ReportOffence<_, _, TestOffence>>::is_known_offence(
|
||||
assert!(!<Offences as ReportOffence<_, _, Offence>>::is_known_offence(
|
||||
&test_offence.offenders,
|
||||
&test_offence.time_slot
|
||||
));
|
||||
@@ -208,7 +206,7 @@ fn reports_if_an_offence_is_dup() {
|
||||
// creating a new offence for the same authorities on the next slot
|
||||
// should be considered a new offence and thefore not known
|
||||
let test_offence_next_slot = offence(time_slot + 1, vec![0, 1]);
|
||||
assert!(!<Offences as ReportOffence<_, _, TestOffence>>::is_known_offence(
|
||||
assert!(!<Offences as ReportOffence<_, _, Offence>>::is_known_offence(
|
||||
&test_offence_next_slot.offenders,
|
||||
&test_offence_next_slot.time_slot
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user