mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 04:41:03 +00:00
Remove grandpa StoredPendingChange shim (#8788)
* Remove grandpa StoredPendingChange shim * Unused import
This commit is contained in:
@@ -107,21 +107,8 @@ pub trait WeightInfo {
|
||||
fn note_stalled() -> Weight;
|
||||
}
|
||||
|
||||
/// A stored pending change, old format.
|
||||
// TODO: remove shim
|
||||
// https://github.com/paritytech/substrate/issues/1614
|
||||
#[derive(Encode, Decode)]
|
||||
pub struct OldStoredPendingChange<N> {
|
||||
/// The block number this was scheduled at.
|
||||
pub scheduled_at: N,
|
||||
/// The delay in blocks until it will be applied.
|
||||
pub delay: N,
|
||||
/// The next authority set.
|
||||
pub next_authorities: AuthorityList,
|
||||
}
|
||||
|
||||
/// A stored pending change.
|
||||
#[derive(Encode)]
|
||||
#[derive(Encode, Decode)]
|
||||
pub struct StoredPendingChange<N> {
|
||||
/// The block number this was scheduled at.
|
||||
pub scheduled_at: N,
|
||||
@@ -134,20 +121,6 @@ pub struct StoredPendingChange<N> {
|
||||
pub forced: Option<N>,
|
||||
}
|
||||
|
||||
impl<N: Decode> Decode for StoredPendingChange<N> {
|
||||
fn decode<I: codec::Input>(value: &mut I) -> core::result::Result<Self, codec::Error> {
|
||||
let old = OldStoredPendingChange::decode(value)?;
|
||||
let forced = <Option<N>>::decode(value).unwrap_or(None);
|
||||
|
||||
Ok(StoredPendingChange {
|
||||
scheduled_at: old.scheduled_at,
|
||||
delay: old.delay,
|
||||
next_authorities: old.next_authorities,
|
||||
forced,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Current state of the GRANDPA authority set. State transitions must happen in
|
||||
/// the same order of states defined below, e.g. `Paused` implies a prior
|
||||
/// `PendingPause`.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
use super::{Call, Event, *};
|
||||
use crate::mock::*;
|
||||
use codec::{Decode, Encode};
|
||||
use codec::Encode;
|
||||
use fg_primitives::ScheduledChange;
|
||||
use frame_support::{
|
||||
assert_err, assert_ok, assert_noop,
|
||||
@@ -127,22 +127,6 @@ fn cannot_schedule_change_when_one_pending() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_decodes_from_old() {
|
||||
let old = OldStoredPendingChange {
|
||||
scheduled_at: 5u32,
|
||||
delay: 100u32,
|
||||
next_authorities: to_authorities(vec![(1, 5), (2, 10), (3, 2)]),
|
||||
};
|
||||
|
||||
let encoded = old.encode();
|
||||
let new = StoredPendingChange::<u32>::decode(&mut &encoded[..]).unwrap();
|
||||
assert!(new.forced.is_none());
|
||||
assert_eq!(new.scheduled_at, old.scheduled_at);
|
||||
assert_eq!(new.delay, old.delay);
|
||||
assert_eq!(new.next_authorities, old.next_authorities);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dispatch_forced_change() {
|
||||
new_test_ext(vec![(1, 1), (2, 1), (3, 1)]).execute_with(|| {
|
||||
|
||||
Reference in New Issue
Block a user