Skip to content

Commit

Permalink
Merge pull request #179 from 5ire-tech/fix/pallet-reward
Browse files Browse the repository at this point in the history
fix: added benchmarking and weights.rs
  • Loading branch information
dung5ire authored Aug 5, 2024
2 parents 20f56bc + e25c6b2 commit c051cde
Show file tree
Hide file tree
Showing 16 changed files with 333 additions and 377 deletions.
129 changes: 15 additions & 114 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frame/esg/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

use crate::{Pallet as Esg, *};
use frame_benchmarking::{account, benchmarks, whitelisted_caller};
use frame_support::{inherent::Vec, WeakBoundedVec};
use frame_support::WeakBoundedVec;
use sp_std::vec::Vec;
use frame_system::RawOrigin;

benchmarks! {
Expand Down
28 changes: 28 additions & 0 deletions frame/reward/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#![cfg(feature = "runtime-benchmarks")]
use super::*;
use frame_benchmarking::whitelisted_caller;
#[allow(unused)]
use crate::Pallet as Reward;
use frame_benchmarking::v2::*;
use frame_system::RawOrigin as SystemOrigin;
use sp_std::vec;

#[benchmarks]
mod benchmarks {
use super::*;

#[benchmark]
fn get_rewards() {
let caller: T::AccountId = whitelisted_caller();
let validator: T::AccountId = whitelisted_caller();
let balance : T::Balance = 5000u128.into();
ValidatorRewardAccounts::<T>::insert(validator.clone(),balance);

#[extrinsic_call]
get_rewards(SystemOrigin::Signed(caller), validator.clone());

assert!(ValidatorRewardAccounts::<T>::contains_key(&validator.clone()));
}

impl_benchmark_test_suite!(Reward, crate::mock::new_test_ext(), crate::mock::Test);
}
Loading

0 comments on commit c051cde

Please sign in to comment.