Skip to content

Commit

Permalink
#80 Added benchmarking method for add_registrar
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmishra2005 committed Jan 25, 2021
1 parent 489d116 commit 1345d5f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
30 changes: 30 additions & 0 deletions pallets/polkadex-identity-pallet/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use super::*;

use sp_std::prelude::*;
use frame_system::RawOrigin;
use frame_benchmarking::{benchmarks, whitelisted_caller, account};
use orml_nft::Module as NftModule;
use crate::Module as KittiesModule;

benchmarks! {
_ {}

add_registrar {
let account_id = account("registrar", 0, 0);
}: _(RawOrigin::Root, account_id)

}

#[cfg(test)]
mod tests {
use super::*;
use crate::tests::{new_test_ext, Test};
use frame_support::assert_ok;

#[test]
fn test_benchmarks() {
new_test_ext().execute_with(|| {
assert_ok!(test_benchmark_add_registrar::<Test>());
});
}
}
4 changes: 3 additions & 1 deletion pallets/polkadex-identity-pallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use sp_std::prelude::*;
mod mock;
#[cfg(test)]
mod test;
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;

pub type RegistrarIndex = u32;

Expand Down Expand Up @@ -200,7 +202,7 @@ decl_module! {
///
/// This function returns a status that, judgement is successfully passed or not.
#[weight = 10_000]
fn provide_judgement_trader(origin,target: T::AccountId,judgement: Judgement) -> DispatchResult {
fn provide_judgement_trader(origin, target: T::AccountId, judgement: Judgement) -> DispatchResult {
let registrar = ensure_signed(origin)?;
ensure!(<Registrars<T>>::contains_key(&registrar), Error::<T>::SenderIsNotRegistrar); // Check for the existance
ensure!(!SuperOf::<T>::contains_key(&target), Error::<T>::GivenAccountIsSubAccount);
Expand Down
1 change: 1 addition & 0 deletions runtime/testnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ impl_runtime_apis! {
add_benchmark!(params, batches, pallet_collective, Council);
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
add_benchmark!(params, batches, pallet_treasury, Treasury);
add_benchmark!(params, batches, pallet_idenity, PolkadexIdentity);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
Expand Down

0 comments on commit 1345d5f

Please sign in to comment.