mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 14:31:02 +00:00
Tunable Justification Generator (#835)
* Add way to create tunable GRANDPA justifications * Use new function in tests * Allow multiple authorities on a single fork * Only store pre-commit targets instead of full ancestry chains * Rename precommit_header to be more generic * Push new digest item instead of overriding entire digest * Ensure that we generate chains with non-zero length * Extract justification creation parameters into struct * Appease Clippy
This commit is contained in:
committed by
Bastian Köcher
parent
4105575794
commit
1c7b5d1b30
@@ -522,7 +522,7 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::mock::{run_test, test_header, Origin, TestHash, TestHeader, TestNumber, TestRuntime};
|
||||
use bp_test_utils::{
|
||||
authority_list, keyring, make_justification_for_header,
|
||||
authority_list, make_default_justification, make_justification_for_header, JustificationGeneratorParams,
|
||||
Keyring::{Alice, Bob},
|
||||
};
|
||||
use codec::Encode;
|
||||
@@ -551,10 +551,7 @@ mod tests {
|
||||
|
||||
fn submit_finality_proof(header: u8) -> frame_support::dispatch::DispatchResultWithPostInfo {
|
||||
let header = test_header(header.into());
|
||||
|
||||
let set_id = 1;
|
||||
let grandpa_round = 1;
|
||||
let justification = make_justification_for_header(&header, grandpa_round, set_id, &keyring()).encode();
|
||||
let justification = make_default_justification(&header).encode();
|
||||
|
||||
Module::<TestRuntime>::submit_finality_proof(Origin::signed(1), header, justification)
|
||||
}
|
||||
@@ -726,9 +723,11 @@ mod tests {
|
||||
|
||||
let header = test_header(1);
|
||||
|
||||
let set_id = 2;
|
||||
let grandpa_round = 1;
|
||||
let justification = make_justification_for_header(&header, grandpa_round, set_id, &keyring()).encode();
|
||||
let params = JustificationGeneratorParams::<TestHeader> {
|
||||
set_id: 2,
|
||||
..Default::default()
|
||||
};
|
||||
let justification = make_justification_for_header(params).encode();
|
||||
|
||||
assert_err!(
|
||||
Module::<TestRuntime>::submit_finality_proof(Origin::signed(1), header, justification,),
|
||||
@@ -802,9 +801,7 @@ mod tests {
|
||||
header.digest = change_log(0);
|
||||
|
||||
// Create a valid justification for the header
|
||||
let set_id = 1;
|
||||
let grandpa_round = 1;
|
||||
let justification = make_justification_for_header(&header, grandpa_round, set_id, &keyring()).encode();
|
||||
let justification = make_default_justification(&header).encode();
|
||||
|
||||
// Let's import our test header
|
||||
assert_ok!(Module::<TestRuntime>::submit_finality_proof(
|
||||
@@ -836,9 +833,7 @@ mod tests {
|
||||
header.digest = change_log(1);
|
||||
|
||||
// Create a valid justification for the header
|
||||
let set_id = 1;
|
||||
let grandpa_round = 1;
|
||||
let justification = make_justification_for_header(&header, grandpa_round, set_id, &keyring()).encode();
|
||||
let justification = make_default_justification(&header).encode();
|
||||
|
||||
// Should not be allowed to import this header
|
||||
assert_err!(
|
||||
@@ -859,9 +854,7 @@ mod tests {
|
||||
header.digest = forced_change_log(0);
|
||||
|
||||
// Create a valid justification for the header
|
||||
let set_id = 1;
|
||||
let grandpa_round = 1;
|
||||
let justification = make_justification_for_header(&header, grandpa_round, set_id, &keyring()).encode();
|
||||
let justification = make_default_justification(&header).encode();
|
||||
|
||||
// Should not be allowed to import this header
|
||||
assert_err!(
|
||||
|
||||
Reference in New Issue
Block a user