Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Merge requests
!187
Distance pallet benchmark
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Distance pallet benchmark
bgallois/duniter-v2s:pallet-distance-benchmark
into
master
Overview
5
Commits
7
Pipelines
38
Changes
7
Merged
Benjamin Gallois
requested to merge
bgallois/duniter-v2s:pallet-distance-benchmark
into
master
1 year ago
Overview
4
Commits
7
Pipelines
38
Changes
7
Expand
0
0
Merge request reports
Viewing commit
1a5827be
Show latest version
7 files
+
101
−
7
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
Unverified
1a5827be
wip
· 1a5827be
bgallois
authored
1 year ago
pallets/distance/src/benchmarking.rs
0 → 100644
+
64
−
0
Options
// 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