Skip to content
Snippets Groups Projects
Unverified Commit c48cb991 authored by bgallois's avatar bgallois
Browse files

wip

parent 7d3fae88
No related branches found
No related tags found
No related merge requests found
Pipeline #33744 failed
This commit is part of merge request !187. Comments created here will be created in the context of that merge request.
......@@ -5849,6 +5849,7 @@ dependencies = [
"frame-system",
"pallet-authority-members",
"pallet-authorship",
"pallet-balances",
"pallet-identity",
"pallet-membership",
"pallet-session",
......@@ -5857,6 +5858,8 @@ dependencies = [
"sp-core",
"sp-distance",
"sp-inherents",
"sp-io",
"sp-keystore",
"sp-runtime",
"sp-std 5.0.0",
]
......
......@@ -11,7 +11,9 @@ version = '1.0.0'
[features]
default = ['std']
runtime-benchmarks = ['frame-benchmarking/runtime-benchmarks']
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks",
"pallet-balances",
]
std = [
'codec/std',
'frame-support/std',
......@@ -39,11 +41,7 @@ scale-info = { version = "2.1.1", default-features = false, features = [
"derive",
] }
[dependencies.frame-benchmarking]
default-features = false
git = 'https://github.com/duniter/substrate'
optional = true
branch = 'duniter-substrate-v0.9.42'
pallet-balances = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.42', optional = true, default-features = false }
[dependencies.codec]
default-features = false
......@@ -51,6 +49,12 @@ features = ['derive']
package = 'parity-scale-codec'
version = '3.1.5'
[dependencies.frame-benchmarking]
default-features = false
git = 'https://github.com/duniter/substrate'
optional = true
branch = 'duniter-substrate-v0.9.42'
[dependencies.frame-support]
default-features = false
git = 'https://github.com/duniter/substrate'
......@@ -95,3 +99,8 @@ branch = 'duniter-substrate-v0.9.42'
[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
[dev-dependencies]
pallet-balances = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.42' }
sp-io = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.42' }
sp-keystore = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.42' }
// 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 codec::Encode;
use codec::Encode;
use frame_benchmarking::{account, benchmarks, Vec};
use frame_support::pallet_prelude::IsType;
use frame_support::traits::Currency;
use frame_support::traits::OnInitialize;
use frame_support::ConsensusEngineId;
use frame_system::RawOrigin;
use pallet_balances::Pallet as Balances;
use pallet_identity::Identities;
use sp_runtime::traits::{Bounded, One};
use sp_runtime::DigestItem;
use sp_runtime::Perbill;
use crate::Pallet;
/*fn assert_has_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_has_event(generic_event.into());
}*/
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 _ = <Balances<T> as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value());
let computation_result = ComputationResult{distances: Vec::<Perbill>::default()};
/// TODO: set the author of the block.
/*let author = 1;
let mut digest:<frame_system::Pallet<T>>::digest = <frame_system::Pallet<T>>::digest();
const TEST_ID: ConsensusEngineId = [1, 2, 3, 4];
digest.logs.push(DigestItem::PreRuntime(TEST_ID, author.encode()));
//digest.logs.push(DigestItem::Seal(TEST_ID, author.encode()));
//digest.pop();
frame_system::Pallet::<T>::reset_events();
frame_system::Pallet::<T>::initialize(&0.into(), &Default::default(), &digest);
pallet_authorship::Pallet::<T>::author().unwrap();*/
}: _<T::RuntimeOrigin>(RawOrigin::None.into(), computation_result)
}
......@@ -27,6 +27,7 @@ runtime-benchmarks = [
'pallet-balances/runtime-benchmarks',
'pallet-certification/runtime-benchmarks',
'pallet-collective/runtime-benchmarks',
'pallet-distance/runtime-benchmarks',
'pallet-duniter-test-parameters/runtime-benchmarks',
'pallet-duniter-account/runtime-benchmarks',
'pallet-duniter-wot/runtime-benchmarks',
......
......@@ -143,6 +143,7 @@ mod benches {
define_benchmarks!(
[pallet_certification, Cert]
[pallet_certification, SmithCert]
[pallet_distance, Distance]
[pallet_oneshot_account, OneshotAccount]
[pallet_universal_dividend, UniversalDividend]
[pallet_provide_randomness, ProvideRandomness]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment