diff --git a/pallets/session-validator-management/src/lib.rs b/pallets/session-validator-management/src/lib.rs index ba135c12e..ab1e050d9 100644 --- a/pallets/session-validator-management/src/lib.rs +++ b/pallets/session-validator-management/src/lib.rs @@ -97,7 +97,6 @@ pub mod pallet { } #[pallet::storage] - #[pallet::getter(fn current_committee_storage)] pub type CurrentCommittee = StorageValue< _, CommitteeInfo, @@ -105,7 +104,6 @@ pub mod pallet { >; #[pallet::storage] - #[pallet::getter(fn next_committee_storage)] pub type NextCommittee = StorageValue< _, CommitteeInfo, @@ -280,6 +278,17 @@ pub mod pallet { .clone() } + pub fn current_committee_storage( + ) -> CommitteeInfo { + CurrentCommittee::::get() + } + + pub fn next_committee_storage() -> Option< + CommitteeInfo, + > { + NextCommittee::::get() + } + /// This function's result should be always defined after inherent call of 1st block of each epoch pub fn next_committee() -> Option> { Some(BoundedVec::truncate_from( diff --git a/pallets/session-validator-management/src/mock.rs b/pallets/session-validator-management/src/mock.rs index 8216a0814..5746fd329 100644 --- a/pallets/session-validator-management/src/mock.rs +++ b/pallets/session-validator-management/src/mock.rs @@ -31,7 +31,6 @@ pub mod mock_pallet { pub trait Config: frame_system::Config {} #[pallet::storage] - #[pallet::getter(fn current_epoch)] pub type CurrentEpoch = StorageValue<_, u64, ValueQuery>; } @@ -202,5 +201,5 @@ pub fn create_inherent_set_validators_call( } pub(crate) fn current_epoch_number() -> u64 { - Mock::current_epoch() + mock_pallet::CurrentEpoch::::get() } diff --git a/pallets/sidechain/src/lib.rs b/pallets/sidechain/src/lib.rs index b97c3920e..12315473f 100644 --- a/pallets/sidechain/src/lib.rs +++ b/pallets/sidechain/src/lib.rs @@ -32,11 +32,9 @@ pub mod pallet { } #[pallet::storage] - #[pallet::getter(fn epoch_number)] pub(super) type EpochNumber = StorageValue<_, ScEpochNumber, ValueQuery>; #[pallet::storage] - #[pallet::getter(fn slots_per_epoch)] pub(super) type SlotsPerEpoch = StorageValue<_, sidechain_slots::SlotsPerEpoch, ValueQuery>; @@ -53,6 +51,10 @@ pub mod pallet { let slots_per_epoch = Self::slots_per_epoch(); slots_per_epoch.epoch_number_from_sc_slot(current_slot) } + + pub fn slots_per_epoch() -> sidechain_slots::SlotsPerEpoch { + SlotsPerEpoch::::get() + } } #[pallet::genesis_config] diff --git a/pallets/sidechain/src/mock.rs b/pallets/sidechain/src/mock.rs index 4293bba90..9adcffacf 100644 --- a/pallets/sidechain/src/mock.rs +++ b/pallets/sidechain/src/mock.rs @@ -27,15 +27,12 @@ pub(crate) mod mock_pallet { pub trait Config: frame_system::Config {} #[pallet::storage] - #[pallet::getter(fn current_epoch)] pub type CurrentEpoch = StorageValue<_, ScEpochNumber, ValueQuery>; #[pallet::storage] - #[pallet::getter(fn current_slot)] pub type CurrentSlot = StorageValue<_, ScSlotNumber, ValueQuery>; #[pallet::storage] - #[pallet::getter(fn on_new_epoch_call_count)] pub type OnNewEpochCallCount = StorageValue<_, u32, ValueQuery>; impl OnNewEpoch for Pallet { @@ -97,7 +94,7 @@ impl frame_system::Config for Test { impl pallet::Config for Test { fn current_slot_number() -> ScSlotNumber { - Mock::current_slot() + mock_pallet::CurrentSlot::::get() } type OnNewEpoch = Mock; type SidechainParams = u64; diff --git a/pallets/sidechain/src/tests.rs b/pallets/sidechain/src/tests.rs index 21ff03553..fcd69dbdc 100644 --- a/pallets/sidechain/src/tests.rs +++ b/pallets/sidechain/src/tests.rs @@ -7,11 +7,11 @@ fn on_new_epoch_is_triggered_by_epoch_change() { new_test_ext().execute_with(|| { Mock::set_slot(4); Sidechain::on_initialize(1); - assert_eq!(Mock::on_new_epoch_call_count(), 0); + assert_eq!(mock_pallet::OnNewEpochCallCount::::get(), 0); Mock::set_slot(MOCK_SLOTS_PER_EPOCH.0.into()); Sidechain::on_initialize(3); - assert_eq!(Mock::on_new_epoch_call_count(), 1); + assert_eq!(mock_pallet::OnNewEpochCallCount::::get(), 1); }) } @@ -23,7 +23,7 @@ fn on_new_epoch_is_not_triggered_without_epoch_change() { Sidechain::on_initialize(2); Mock::set_slot(u64::from(MOCK_SLOTS_PER_EPOCH.0) - 1); Sidechain::on_initialize(3); - assert_eq!(Mock::on_new_epoch_call_count(), 0); + assert_eq!(mock_pallet::OnNewEpochCallCount::::get(), 0); }) }