Skip to content

Commit

Permalink
fix task benches
Browse files Browse the repository at this point in the history
  • Loading branch information
haider-rs committed Oct 3, 2024
1 parent 237563f commit 3afe855
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
4 changes: 3 additions & 1 deletion pallets/tasks/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ benchmarks! {
};
// Fund and register all shard members
let mut i = 0u8;
let mut members = vec![];
while u16::from(i) < <T as Config>::Elections::default_shard_size() {
let member = [i; 32];
let member_account: AccountId = member.into();
members.push(member_account.clone());
pallet_balances::Pallet::<T>::resolve_creating(
&member_account,
pallet_balances::Pallet::<T>::issue(<T as pallet_members::Config>::MinStake::get() * 100),
Expand All @@ -197,7 +199,7 @@ benchmarks! {
}
<T as Config>::Shards::create_shard(
ETHEREUM,
[[0u8; 32].into(), [1u8; 32].into(), [2u8; 32].into()].to_vec(),
members,
1,
);
ShardState::<T>::insert(0, ShardStatus::Online);
Expand Down
16 changes: 2 additions & 14 deletions pallets/tasks/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ use sp_runtime::{
traits::{parameter_types, IdentifyAccount, IdentityLookup, Verify},
BuildStorage, DispatchResult, MultiSignature, Percent,
};
use time_primitives::{
Balance, DepreciationRate, ElectionsInterface, MemberStorage, NetworkId, PeerId, PublicKey,
TransferStake,
};
use time_primitives::{Balance, DepreciationRate, MemberStorage, PeerId, PublicKey, TransferStake};

pub type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
Expand Down Expand Up @@ -43,15 +40,6 @@ impl TransferStake for MockMembers {
}
}

pub struct MockElections;

impl ElectionsInterface for MockElections {
fn shard_offline(_: NetworkId, _: Vec<AccountId>) {}
fn default_shard_size() -> u16 {
3
}
}

// Configure a mock runtime to test the pallet.
frame_support::construct_runtime!(
pub struct Test {
Expand Down Expand Up @@ -120,7 +108,7 @@ impl pallet_shards::Config for Test {
impl task_schedule::Config for Test {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
type Elections = MockElections;
type Elections = Elections;
type Shards = Shards;
type Members = MockMembers;
type BaseReadReward = ConstU128<2>;
Expand Down

0 comments on commit 3afe855

Please sign in to comment.