Skip to content

Commit

Permalink
use system events for pallet
Browse files Browse the repository at this point in the history
  • Loading branch information
Ank4n committed May 13, 2024
1 parent 7782cab commit 6e3045f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
10 changes: 1 addition & 9 deletions substrate/frame/delegated-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ use frame_election_provider_support::{
};
use frame_support::dispatch::RawOrigin;
use pallet_staking::CurrentEra;
use sp_core::U256;
use sp_runtime::traits::Convert;
use sp_staking::{Stake, StakingInterface};

pub type T = Runtime;
Expand Down Expand Up @@ -293,13 +291,7 @@ parameter_types! {

#[allow(unused)]
pub(crate) fn events_since_last_call() -> Vec<crate::Event<Runtime>> {
let events = System::events()
.into_iter()
.map(|r| r.event)
.filter_map(
|e| if let RuntimeEvent::DelegatedStaking(inner) = e { Some(inner) } else { None },
)
.collect::<Vec<_>>();
let events = System::read_events_for_pallet::<crate::Event<Runtime>>();
let already_seen = ObservedEventsDelegatedStaking::get();
ObservedEventsDelegatedStaking::set(events.len());
events.into_iter().skip(already_seen).collect()
Expand Down
6 changes: 1 addition & 5 deletions substrate/frame/delegated-staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,7 @@ fn agent_restrictions() {

// agent cannot delegate to self
assert_noop!(
DelegatedStaking::delegate_to_agent(
RawOrigin::Signed(agent_one).into(),
agent_one,
10
),
DelegatedStaking::delegate_to_agent(RawOrigin::Signed(agent_one).into(), agent_one, 10),
Error::<T>::InvalidDelegation
);
});
Expand Down

0 comments on commit 6e3045f

Please sign in to comment.