-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into it/simplify-xtransfer-tests
- Loading branch information
Showing
17 changed files
with
891 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
[package] | ||
name = "pallet-anchors-v2" | ||
description = "Anchors V2 pallet for runtime" | ||
version = "1.0.0" | ||
authors.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
documentation.workspace = true | ||
|
||
[package.metadata.docs.rs] | ||
targets = ["x86_64-unknown-linux-gnu"] | ||
|
||
[dependencies] | ||
parity-scale-codec = { workspace = true } | ||
scale-info = { workspace = true } | ||
|
||
frame-benchmarking = { workspace = true, optional = true } | ||
frame-support = { workspace = true } | ||
frame-system = { workspace = true } | ||
sp-core = { workspace = true } | ||
sp-runtime = { workspace = true } | ||
sp-std = { workspace = true } | ||
|
||
[dev-dependencies] | ||
pallet-balances = { workspace = true, default-features = true } | ||
sp-core = { workspace = true, default-features = true } | ||
sp-io = { workspace = true, default-features = true } | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"parity-scale-codec/std", | ||
"scale-info/std", | ||
"frame-support/std", | ||
"frame-system/std", | ||
"sp-runtime/std", | ||
"sp-std/std", | ||
"frame-benchmarking/std", | ||
] | ||
runtime-benchmarks = [ | ||
"frame-benchmarking/runtime-benchmarks", | ||
"frame-support/runtime-benchmarks", | ||
"frame-system/runtime-benchmarks", | ||
"sp-runtime/runtime-benchmarks", | ||
] | ||
try-runtime = [ | ||
"frame-support/try-runtime", | ||
"frame-system/try-runtime", | ||
"sp-runtime/try-runtime", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright 2021 Centrifuge Foundation (centrifuge.io). | ||
// This file is part of Centrifuge chain project. | ||
|
||
// Centrifuge is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version (see http://www.gnu.org/licenses). | ||
|
||
// Centrifuge 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 General Public License for more details. | ||
|
||
use frame_benchmarking::{account, impl_benchmark_test_suite, v2::*}; | ||
use frame_support::traits::Currency; | ||
use frame_system::RawOrigin; | ||
use parity_scale_codec::EncodeLike; | ||
use sp_core::H256; | ||
|
||
use super::*; | ||
|
||
#[benchmarks( | ||
where | ||
T: Config<Balance = u128, Hash = H256>, | ||
T::AccountId: EncodeLike<<T as frame_system::Config>::AccountId>, | ||
)] | ||
mod benchmarks { | ||
use super::*; | ||
|
||
#[benchmark] | ||
fn set_anchor() -> Result<(), BenchmarkError> { | ||
let caller: T::AccountId = account("acc_0", 0, 0); | ||
|
||
let document_id = 123; | ||
let document_version = 456; | ||
let hash = H256::from_low_u64_be(1); | ||
|
||
let _ = T::Currency::deposit_creating( | ||
&caller.clone().into(), | ||
T::Currency::minimum_balance() + T::DefaultAnchorDeposit::get(), | ||
); | ||
|
||
#[extrinsic_call] | ||
set_anchor( | ||
RawOrigin::Signed(caller), | ||
document_id, | ||
document_version, | ||
hash, | ||
); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[benchmark] | ||
fn remove_anchor() -> Result<(), BenchmarkError> { | ||
let caller: T::AccountId = account("acc_0", 0, 0); | ||
|
||
let document_id = 123; | ||
let document_version = 456; | ||
let hash = H256::from_low_u64_be(1); | ||
let deposit = AnchorDeposit::<T>::get(); | ||
|
||
let anchor = Anchor::<T> { | ||
account_id: caller.clone(), | ||
document_id, | ||
document_version, | ||
hash, | ||
deposit, | ||
}; | ||
|
||
Anchors::<T>::insert((document_id, document_version), anchor); | ||
PersonalAnchors::<T>::insert(caller.clone(), (document_id, document_version), ()); | ||
|
||
#[extrinsic_call] | ||
remove_anchor(RawOrigin::Signed(caller), document_id, document_version); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[benchmark] | ||
fn set_deposit_value() -> Result<(), BenchmarkError> { | ||
let deposit = 2 * T::DefaultAnchorDeposit::get(); | ||
|
||
#[extrinsic_call] | ||
set_deposit_value(RawOrigin::Root, deposit); | ||
|
||
Ok(()) | ||
} | ||
|
||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Runtime); | ||
} |
Oops, something went wrong.