mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 11:38:01 +00:00
Use GrandpaJustification instead of Vec<u8> in Pallet API (#847)
* Stop passing raw encoded justifications to pallet API By having the API accept a struct-ified justification we are able to better utilize the justifications fields for weight calculations. * Update relayer code to use decoded justifications * Add justification to `expect()` statement * Fix some imports * Make justification wrapper contain decoded justification * Rename some fields * Get rid of warnings * Appease Clippy * Only decode justification once at init time * Remove unnecessary method * Remove justification wrapper This became kinda unnecessary since we could implement the FinalityProof trait on GrandpaJustification directly.
This commit is contained in:
committed by
Bastian Köcher
parent
904b9f4da5
commit
67cdca8aa4
@@ -18,7 +18,6 @@
|
||||
|
||||
use bp_header_chain::justification::{verify_justification, Error};
|
||||
use bp_test_utils::*;
|
||||
use codec::Encode;
|
||||
|
||||
type TestHeader = sp_runtime::testing::Header;
|
||||
|
||||
@@ -38,7 +37,7 @@ fn valid_justification_accepted() {
|
||||
header_id::<TestHeader>(1),
|
||||
TEST_GRANDPA_SET_ID,
|
||||
&voter_set(),
|
||||
&make_justification_for_header::<TestHeader>(params).encode()
|
||||
&make_justification_for_header::<TestHeader>(params)
|
||||
),
|
||||
Ok(()),
|
||||
);
|
||||
@@ -60,7 +59,7 @@ fn valid_justification_accepted_with_single_fork() {
|
||||
header_id::<TestHeader>(1),
|
||||
TEST_GRANDPA_SET_ID,
|
||||
&voter_set(),
|
||||
&make_justification_for_header::<TestHeader>(params).encode()
|
||||
&make_justification_for_header::<TestHeader>(params)
|
||||
),
|
||||
Ok(()),
|
||||
);
|
||||
@@ -94,20 +93,12 @@ fn valid_justification_accepted_with_arbitrary_number_of_authorities() {
|
||||
header_id::<TestHeader>(1),
|
||||
TEST_GRANDPA_SET_ID,
|
||||
&voter_set,
|
||||
&make_justification_for_header::<TestHeader>(params).encode()
|
||||
&make_justification_for_header::<TestHeader>(params)
|
||||
),
|
||||
Ok(()),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn justification_with_invalid_encoding_rejected() {
|
||||
assert_eq!(
|
||||
verify_justification::<TestHeader>(header_id::<TestHeader>(1), TEST_GRANDPA_SET_ID, &voter_set(), &[],),
|
||||
Err(Error::JustificationDecode),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn justification_with_invalid_target_rejected() {
|
||||
assert_eq!(
|
||||
@@ -115,7 +106,7 @@ fn justification_with_invalid_target_rejected() {
|
||||
header_id::<TestHeader>(2),
|
||||
TEST_GRANDPA_SET_ID,
|
||||
&voter_set(),
|
||||
&make_default_justification::<TestHeader>(&test_header(1)).encode(),
|
||||
&make_default_justification::<TestHeader>(&test_header(1)),
|
||||
),
|
||||
Err(Error::InvalidJustificationTarget),
|
||||
);
|
||||
@@ -131,7 +122,7 @@ fn justification_with_invalid_commit_rejected() {
|
||||
header_id::<TestHeader>(1),
|
||||
TEST_GRANDPA_SET_ID,
|
||||
&voter_set(),
|
||||
&justification.encode(),
|
||||
&justification,
|
||||
),
|
||||
Err(Error::InvalidJustificationCommit),
|
||||
);
|
||||
@@ -147,7 +138,7 @@ fn justification_with_invalid_authority_signature_rejected() {
|
||||
header_id::<TestHeader>(1),
|
||||
TEST_GRANDPA_SET_ID,
|
||||
&voter_set(),
|
||||
&justification.encode(),
|
||||
&justification,
|
||||
),
|
||||
Err(Error::InvalidAuthoritySignature),
|
||||
);
|
||||
@@ -163,7 +154,7 @@ fn justification_with_invalid_precommit_ancestry() {
|
||||
header_id::<TestHeader>(1),
|
||||
TEST_GRANDPA_SET_ID,
|
||||
&voter_set(),
|
||||
&justification.encode(),
|
||||
&justification,
|
||||
),
|
||||
Err(Error::InvalidPrecommitAncestries),
|
||||
);
|
||||
@@ -186,7 +177,7 @@ fn justification_is_invalid_if_we_dont_meet_threshold() {
|
||||
header_id::<TestHeader>(1),
|
||||
TEST_GRANDPA_SET_ID,
|
||||
&voter_set(),
|
||||
&make_justification_for_header::<TestHeader>(params).encode()
|
||||
&make_justification_for_header::<TestHeader>(params)
|
||||
),
|
||||
Err(Error::InvalidJustificationCommit),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user