mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
Migrate pallet-babe to pallet attribute macro. (#8310)
* Migrate pallet-babe to pallet attribute macro. * Remove unnecessary bound in pallet storage. Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
|
||||
use super::{Call, *};
|
||||
use frame_support::{
|
||||
assert_err, assert_ok,
|
||||
assert_err, assert_ok, assert_noop,
|
||||
traits::{Currency, EstimateNextSessionRotation, OnFinalize},
|
||||
weights::{GetDispatchInfo, Pays},
|
||||
};
|
||||
@@ -92,11 +92,11 @@ fn first_block_epoch_zero_start() {
|
||||
Babe::on_finalize(1);
|
||||
let header = System::finalize();
|
||||
|
||||
assert_eq!(SegmentIndex::get(), 0);
|
||||
assert_eq!(UnderConstruction::get(0), vec![vrf_randomness]);
|
||||
assert_eq!(SegmentIndex::<Test>::get(), 0);
|
||||
assert_eq!(UnderConstruction::<Test>::get(0), vec![vrf_randomness]);
|
||||
assert_eq!(Babe::randomness(), [0; 32]);
|
||||
assert_eq!(Babe::author_vrf_randomness(), None);
|
||||
assert_eq!(NextRandomness::get(), [0; 32]);
|
||||
assert_eq!(NextRandomness::<Test>::get(), [0; 32]);
|
||||
|
||||
assert_eq!(header.digest.logs.len(), 2);
|
||||
assert_eq!(pre_digest.logs.len(), 1);
|
||||
@@ -278,10 +278,10 @@ fn can_enact_next_config() {
|
||||
allowed_slots: sp_consensus_babe::AllowedSlots::PrimarySlots,
|
||||
};
|
||||
|
||||
EpochConfig::put(current_config);
|
||||
NextEpochConfig::put(next_config.clone());
|
||||
EpochConfig::<Test>::put(current_config);
|
||||
NextEpochConfig::<Test>::put(next_config.clone());
|
||||
|
||||
assert_eq!(NextEpochConfig::get(), Some(next_config.clone()));
|
||||
assert_eq!(NextEpochConfig::<Test>::get(), Some(next_config.clone()));
|
||||
|
||||
Babe::plan_config_change(
|
||||
Origin::root(),
|
||||
@@ -295,8 +295,8 @@ fn can_enact_next_config() {
|
||||
Babe::on_finalize(9);
|
||||
let header = System::finalize();
|
||||
|
||||
assert_eq!(EpochConfig::get(), Some(next_config));
|
||||
assert_eq!(NextEpochConfig::get(), Some(next_next_config.clone()));
|
||||
assert_eq!(EpochConfig::<Test>::get(), Some(next_config));
|
||||
assert_eq!(NextEpochConfig::<Test>::get(), Some(next_next_config.clone()));
|
||||
|
||||
let consensus_log = sp_consensus_babe::ConsensusLog::NextConfigData(
|
||||
NextConfigDescriptor::V1 {
|
||||
@@ -325,14 +325,14 @@ fn only_root_can_enact_config_change() {
|
||||
next_config.clone(),
|
||||
);
|
||||
|
||||
assert_eq!(res, Err(DispatchError::BadOrigin));
|
||||
assert_noop!(res, DispatchError::BadOrigin);
|
||||
|
||||
let res = Babe::plan_config_change(
|
||||
Origin::signed(1),
|
||||
next_config.clone(),
|
||||
);
|
||||
|
||||
assert_eq!(res, Err(DispatchError::BadOrigin));
|
||||
assert_noop!(res, DispatchError::BadOrigin);
|
||||
|
||||
let res = Babe::plan_config_change(
|
||||
Origin::root(),
|
||||
@@ -346,7 +346,7 @@ fn only_root_can_enact_config_change() {
|
||||
#[test]
|
||||
fn can_fetch_current_and_next_epoch_data() {
|
||||
new_test_ext(5).execute_with(|| {
|
||||
EpochConfig::put(BabeEpochConfiguration {
|
||||
EpochConfig::<Test>::put(BabeEpochConfiguration {
|
||||
c: (1, 4),
|
||||
allowed_slots: sp_consensus_babe::AllowedSlots::PrimarySlots,
|
||||
});
|
||||
@@ -444,7 +444,7 @@ fn report_equivocation_current_session_works() {
|
||||
let equivocation_proof = generate_equivocation_proof(
|
||||
offending_validator_index as u32,
|
||||
&offending_authority_pair,
|
||||
CurrentSlot::get(),
|
||||
CurrentSlot::<Test>::get(),
|
||||
);
|
||||
|
||||
// create the key ownership proof
|
||||
@@ -518,7 +518,7 @@ fn report_equivocation_old_session_works() {
|
||||
let equivocation_proof = generate_equivocation_proof(
|
||||
offending_validator_index as u32,
|
||||
&offending_authority_pair,
|
||||
CurrentSlot::get(),
|
||||
CurrentSlot::<Test>::get(),
|
||||
);
|
||||
|
||||
// create the key ownership proof
|
||||
@@ -584,7 +584,7 @@ fn report_equivocation_invalid_key_owner_proof() {
|
||||
let equivocation_proof = generate_equivocation_proof(
|
||||
offending_validator_index as u32,
|
||||
&offending_authority_pair,
|
||||
CurrentSlot::get(),
|
||||
CurrentSlot::<Test>::get(),
|
||||
);
|
||||
|
||||
// create the key ownership proof
|
||||
@@ -664,7 +664,7 @@ fn report_equivocation_invalid_equivocation_proof() {
|
||||
let mut equivocation_proof = generate_equivocation_proof(
|
||||
offending_validator_index as u32,
|
||||
&offending_authority_pair,
|
||||
CurrentSlot::get(),
|
||||
CurrentSlot::<Test>::get(),
|
||||
);
|
||||
equivocation_proof.second_header = equivocation_proof.first_header.clone();
|
||||
assert_invalid_equivocation(equivocation_proof);
|
||||
@@ -673,7 +673,7 @@ fn report_equivocation_invalid_equivocation_proof() {
|
||||
let mut equivocation_proof = generate_equivocation_proof(
|
||||
offending_validator_index as u32,
|
||||
&offending_authority_pair,
|
||||
CurrentSlot::get(),
|
||||
CurrentSlot::<Test>::get(),
|
||||
);
|
||||
equivocation_proof.first_header.digest_mut().logs.remove(0);
|
||||
assert_invalid_equivocation(equivocation_proof);
|
||||
@@ -682,7 +682,7 @@ fn report_equivocation_invalid_equivocation_proof() {
|
||||
let mut equivocation_proof = generate_equivocation_proof(
|
||||
offending_validator_index as u32,
|
||||
&offending_authority_pair,
|
||||
CurrentSlot::get(),
|
||||
CurrentSlot::<Test>::get(),
|
||||
);
|
||||
equivocation_proof.first_header.digest_mut().logs.remove(1);
|
||||
assert_invalid_equivocation(equivocation_proof);
|
||||
@@ -691,7 +691,7 @@ fn report_equivocation_invalid_equivocation_proof() {
|
||||
let mut equivocation_proof = generate_equivocation_proof(
|
||||
offending_validator_index as u32,
|
||||
&offending_authority_pair,
|
||||
CurrentSlot::get(),
|
||||
CurrentSlot::<Test>::get(),
|
||||
);
|
||||
equivocation_proof.slot = Slot::from(0);
|
||||
assert_invalid_equivocation(equivocation_proof.clone());
|
||||
@@ -701,7 +701,7 @@ fn report_equivocation_invalid_equivocation_proof() {
|
||||
let mut equivocation_proof = generate_equivocation_proof(
|
||||
offending_validator_index as u32,
|
||||
&offending_authority_pair,
|
||||
CurrentSlot::get() + 1,
|
||||
CurrentSlot::<Test>::get() + 1,
|
||||
);
|
||||
|
||||
// use the header from the previous equivocation generated
|
||||
@@ -714,7 +714,7 @@ fn report_equivocation_invalid_equivocation_proof() {
|
||||
let mut equivocation_proof = generate_equivocation_proof(
|
||||
offending_validator_index as u32,
|
||||
&offending_authority_pair,
|
||||
CurrentSlot::get() + 1,
|
||||
CurrentSlot::<Test>::get() + 1,
|
||||
);
|
||||
|
||||
// replace the seal digest with the digest from the
|
||||
@@ -753,7 +753,7 @@ fn report_equivocation_validate_unsigned_prevents_duplicates() {
|
||||
let equivocation_proof = generate_equivocation_proof(
|
||||
offending_validator_index as u32,
|
||||
&offending_authority_pair,
|
||||
CurrentSlot::get(),
|
||||
CurrentSlot::<Test>::get(),
|
||||
);
|
||||
|
||||
let key = (
|
||||
@@ -775,7 +775,7 @@ fn report_equivocation_validate_unsigned_prevents_duplicates() {
|
||||
);
|
||||
|
||||
// the transaction is valid when passed as local
|
||||
let tx_tag = (offending_authority_pair.public(), CurrentSlot::get());
|
||||
let tx_tag = (offending_authority_pair.public(), CurrentSlot::<Test>::get());
|
||||
assert_eq!(
|
||||
<Babe as sp_runtime::traits::ValidateUnsigned>::validate_unsigned(
|
||||
TransactionSource::Local,
|
||||
@@ -848,7 +848,7 @@ fn valid_equivocation_reports_dont_pay_fees() {
|
||||
|
||||
// generate an equivocation proof.
|
||||
let equivocation_proof =
|
||||
generate_equivocation_proof(0, &offending_authority_pair, CurrentSlot::get());
|
||||
generate_equivocation_proof(0, &offending_authority_pair, CurrentSlot::<Test>::get());
|
||||
|
||||
// create the key ownership proof.
|
||||
let key_owner_proof = Historical::prove((
|
||||
@@ -941,7 +941,7 @@ fn add_epoch_configurations_migration_works() {
|
||||
&[],
|
||||
).is_none());
|
||||
|
||||
assert_eq!(EpochConfig::get(), Some(current_epoch));
|
||||
assert_eq!(PendingEpochConfigChange::get(), Some(next_config_descriptor));
|
||||
assert_eq!(EpochConfig::<Test>::get(), Some(current_epoch));
|
||||
assert_eq!(PendingEpochConfigChange::<Test>::get(), Some(next_config_descriptor));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user