Skip to content
Snippets Groups Projects

Distance pallet benchmark

7 files
+ 101
7
Compare changes
  • Side-by-side
  • Inline
Files
7
+ 64
0
 
// Copyright 2021-2023 Axiom-Team
 
//
 
// This file is part of Duniter-v2S.
 
//
 
// Duniter-v2S is free software: you can redistribute it and/or modify
 
// it under the terms of the GNU Affero General Public License as published by
 
// the Free Software Foundation, version 3 of the License.
 
//
 
// Duniter-v2S is distributed in the hope that it will be useful,
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
// GNU Affero General Public License for more details.
 
//
 
// You should have received a copy of the GNU Affero General Public License
 
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
 
 
#![cfg(feature = "runtime-benchmarks")]
 
 
use super::*;
 
 
use frame_benchmarking::{benchmarks, Vec};
 
use frame_support::traits::Currency;
 
use frame_system::RawOrigin;
 
use pallet_balances::Pallet as Balances;
 
use sp_runtime::traits::{Bounded, One};
 
use sp_runtime::Perbill;
 
 
use crate::Pallet;
 
 
benchmarks! {
 
where_clause {
 
where
 
T: pallet_balances::Config, T::Balance: From<u64>,
 
T::BlockNumber: From<u32>,
 
}
 
request_distance_evaluation {
 
let idty = T::IdtyIndex::one();
 
let caller: T::AccountId = pallet_identity::Identities::<T>::get(idty).unwrap().owner_key;
 
let caller_origin: <T as frame_system::Config>::RuntimeOrigin = RawOrigin::Signed(caller.clone()).into();
 
let _ = <Balances<T> as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value());
 
}: _<T::RuntimeOrigin>(caller_origin.clone())
 
verify {
 
assert!(IdentityDistanceStatus::<T>::get(&idty) == Some((caller, DistanceStatus::Pending)), "Request not added");
 
}
 
update_evaluation {
 
let idty = T::IdtyIndex::one();
 
let caller: T::AccountId = pallet_identity::Identities::<T>::get(idty).unwrap().owner_key;
 
let caller_origin: <T as frame_system::Config>::RuntimeOrigin = RawOrigin::Signed(caller.clone()).into();
 
let computation_result = ComputationResult{distances: Vec::<Perbill>::default()};
 
}: _<T::RuntimeOrigin>(RawOrigin::None.into(), computation_result)
 
force_update_evaluation {
 
let idty = T::IdtyIndex::one();
 
let caller: T::AccountId = pallet_identity::Identities::<T>::get(idty).unwrap().owner_key;
 
let computation_result = ComputationResult{distances: Vec::<Perbill>::default()};
 
}: _<T::RuntimeOrigin>(RawOrigin::Root.into(), caller, computation_result)
 
force_set_distance_status {
 
let idty = T::IdtyIndex::one();
 
let caller: T::AccountId = pallet_identity::Identities::<T>::get(idty).unwrap().owner_key;
 
let status = Some((caller.clone(), DistanceStatus::Valid));
 
}: _<T::RuntimeOrigin>(RawOrigin::Root.into(), idty, status)
 
verify {
 
assert!(IdentityDistanceStatus::<T>::get(&idty) == Some((caller, DistanceStatus::Valid)), "Status not set");
 
}
 
}
Loading