mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 21:37:56 +00:00
Improve call, and usage in pallet utility (#9418)
* WIP * WIP * WIP * add some tests and limit * remove wip test * fmt * Update bin/node/runtime/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * fmt * use primitives allocation limit Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
27d4177f93
commit
38db14089b
@@ -440,8 +440,12 @@ fn report_equivocation_current_session_works() {
|
||||
let key_owner_proof = Historical::prove(key).unwrap();
|
||||
|
||||
// report the equivocation
|
||||
Babe::report_equivocation_unsigned(Origin::none(), equivocation_proof, key_owner_proof)
|
||||
.unwrap();
|
||||
Babe::report_equivocation_unsigned(
|
||||
Origin::none(),
|
||||
Box::new(equivocation_proof),
|
||||
key_owner_proof,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// start a new era so that the results of the offence report
|
||||
// are applied at era end
|
||||
@@ -508,8 +512,12 @@ fn report_equivocation_old_session_works() {
|
||||
assert_eq!(Staking::slashable_balance_of(&offending_validator_id), 10_000);
|
||||
|
||||
// report the equivocation
|
||||
Babe::report_equivocation_unsigned(Origin::none(), equivocation_proof, key_owner_proof)
|
||||
.unwrap();
|
||||
Babe::report_equivocation_unsigned(
|
||||
Origin::none(),
|
||||
Box::new(equivocation_proof),
|
||||
key_owner_proof,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// start a new era so that the results of the offence report
|
||||
// are applied at era end
|
||||
@@ -558,7 +566,7 @@ fn report_equivocation_invalid_key_owner_proof() {
|
||||
assert_err!(
|
||||
Babe::report_equivocation_unsigned(
|
||||
Origin::none(),
|
||||
equivocation_proof.clone(),
|
||||
Box::new(equivocation_proof.clone()),
|
||||
key_owner_proof
|
||||
),
|
||||
Error::<Test>::InvalidKeyOwnershipProof,
|
||||
@@ -576,7 +584,11 @@ fn report_equivocation_invalid_key_owner_proof() {
|
||||
start_era(2);
|
||||
|
||||
assert_err!(
|
||||
Babe::report_equivocation_unsigned(Origin::none(), equivocation_proof, key_owner_proof),
|
||||
Babe::report_equivocation_unsigned(
|
||||
Origin::none(),
|
||||
Box::new(equivocation_proof),
|
||||
key_owner_proof,
|
||||
),
|
||||
Error::<Test>::InvalidKeyOwnershipProof,
|
||||
);
|
||||
})
|
||||
@@ -608,7 +620,7 @@ fn report_equivocation_invalid_equivocation_proof() {
|
||||
assert_err!(
|
||||
Babe::report_equivocation_unsigned(
|
||||
Origin::none(),
|
||||
equivocation_proof,
|
||||
Box::new(equivocation_proof),
|
||||
key_owner_proof.clone(),
|
||||
),
|
||||
Error::<Test>::InvalidEquivocationProof,
|
||||
@@ -714,8 +726,10 @@ fn report_equivocation_validate_unsigned_prevents_duplicates() {
|
||||
let key = (sp_consensus_babe::KEY_TYPE, &offending_authority_pair.public());
|
||||
let key_owner_proof = Historical::prove(key).unwrap();
|
||||
|
||||
let inner =
|
||||
Call::report_equivocation_unsigned(equivocation_proof.clone(), key_owner_proof.clone());
|
||||
let inner = Call::report_equivocation_unsigned(
|
||||
Box::new(equivocation_proof.clone()),
|
||||
key_owner_proof.clone(),
|
||||
);
|
||||
|
||||
// only local/inblock reports are allowed
|
||||
assert_eq!(
|
||||
@@ -746,8 +760,12 @@ fn report_equivocation_validate_unsigned_prevents_duplicates() {
|
||||
assert_ok!(<Babe as sp_runtime::traits::ValidateUnsigned>::pre_dispatch(&inner));
|
||||
|
||||
// we submit the report
|
||||
Babe::report_equivocation_unsigned(Origin::none(), equivocation_proof, key_owner_proof)
|
||||
.unwrap();
|
||||
Babe::report_equivocation_unsigned(
|
||||
Origin::none(),
|
||||
Box::new(equivocation_proof),
|
||||
key_owner_proof,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// the report should now be considered stale and the transaction is invalid.
|
||||
// the check for staleness should be done on both `validate_unsigned` and on `pre_dispatch`
|
||||
@@ -805,7 +823,7 @@ fn valid_equivocation_reports_dont_pay_fees() {
|
||||
|
||||
// check the dispatch info for the call.
|
||||
let info = Call::<Test>::report_equivocation_unsigned(
|
||||
equivocation_proof.clone(),
|
||||
Box::new(equivocation_proof.clone()),
|
||||
key_owner_proof.clone(),
|
||||
)
|
||||
.get_dispatch_info();
|
||||
@@ -817,7 +835,7 @@ fn valid_equivocation_reports_dont_pay_fees() {
|
||||
// report the equivocation.
|
||||
let post_info = Babe::report_equivocation_unsigned(
|
||||
Origin::none(),
|
||||
equivocation_proof.clone(),
|
||||
Box::new(equivocation_proof.clone()),
|
||||
key_owner_proof.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -829,11 +847,14 @@ fn valid_equivocation_reports_dont_pay_fees() {
|
||||
|
||||
// report the equivocation again which is invalid now since it is
|
||||
// duplicate.
|
||||
let post_info =
|
||||
Babe::report_equivocation_unsigned(Origin::none(), equivocation_proof, key_owner_proof)
|
||||
.err()
|
||||
.unwrap()
|
||||
.post_info;
|
||||
let post_info = Babe::report_equivocation_unsigned(
|
||||
Origin::none(),
|
||||
Box::new(equivocation_proof),
|
||||
key_owner_proof,
|
||||
)
|
||||
.err()
|
||||
.unwrap()
|
||||
.post_info;
|
||||
|
||||
// the fee is not waived and the original weight is kept.
|
||||
assert!(post_info.actual_weight.is_none());
|
||||
|
||||
Reference in New Issue
Block a user