feat: Rebrand Polkadot/Substrate references to PezkuwiChain
This commit systematically rebrands various references from Parity Technologies' Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk. Key changes include: - Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks. - Modified internal documentation and code comments to reflect PezkuwiChain naming and structure. - Replaced direct references to with or specific paths within the for XCM, Pezkuwi, and other modules. - Cleaned up deprecated issue and PR references in various and files, particularly in and modules. - Adjusted image and logo URLs in documentation to point to PezkuwiChain assets. - Removed or rephrased comments related to external Polkadot/Substrate PRs and issues. This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: MIT-0
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
// of the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
//! Benchmarking for `pezpallet-example-kitchensink`.
|
||||
|
||||
// Only enable this module for benchmarking.
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
use super::*;
|
||||
|
||||
#[allow(unused)]
|
||||
use crate::Pallet as Kitchensink;
|
||||
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::pezpallet_prelude::TransactionSource;
|
||||
use pezframe_system::RawOrigin;
|
||||
|
||||
// To actually run this benchmark on pezpallet-example-kitchensink, we need to put this pallet into the
|
||||
// runtime and compile it with `runtime-benchmarks` feature. The detail procedures are
|
||||
// documented at:
|
||||
// https://docs.pezkuwichain.io/reference/how-to-guides/weights/add-benchmarks/
|
||||
//
|
||||
// The auto-generated weight estimate of this pallet is copied over to the `weights.rs` file.
|
||||
// The exact command of how the estimate generated is printed at the top of the file.
|
||||
|
||||
// Details on using the benchmarks macro can be seen at:
|
||||
// https://docs.pezkuwichain.io/bizinikiwi/master/pezframe_benchmarking/trait.Benchmarking.html#tymethod.benchmarks
|
||||
#[benchmarks]
|
||||
mod benchmarks {
|
||||
use super::*;
|
||||
|
||||
// This will measure the execution time of `set_foo`.
|
||||
#[benchmark]
|
||||
fn set_foo_benchmark() {
|
||||
// This is the benchmark setup phase.
|
||||
// `set_foo` is a constant time function, hence we hard-code some random value here.
|
||||
let value = 1000u32.into();
|
||||
#[extrinsic_call]
|
||||
set_foo(RawOrigin::Root, value, 10u128); // The execution phase is just running `set_foo` extrinsic call
|
||||
|
||||
// This is the optional benchmark verification phase, asserting certain states.
|
||||
assert_eq!(Foo::<T>::get(), Some(value))
|
||||
}
|
||||
|
||||
// This will measure the execution time of `set_foo_using_authorize`.
|
||||
#[benchmark]
|
||||
fn set_foo_using_authorize() {
|
||||
// This is the benchmark setup phase.
|
||||
|
||||
// `set_foo_using_authorize` is only authorized when value is 42 so we will use it.
|
||||
let value = 42u32;
|
||||
// We dispatch with authorized origin, it is the origin resulting from authorization.
|
||||
let origin = RawOrigin::Authorized;
|
||||
|
||||
#[extrinsic_call]
|
||||
_(origin, value); // The execution phase is just running `set_foo_using_authorize` extrinsic call
|
||||
|
||||
// This is the optional benchmark verification phase, asserting certain states.
|
||||
assert_eq!(Foo::<T>::get(), Some(42))
|
||||
}
|
||||
|
||||
// This will measure the weight for the closure in `[pallet::authorize(...)]`.
|
||||
#[benchmark]
|
||||
fn authorize_set_foo_using_authorize() {
|
||||
// This is the benchmark setup phase.
|
||||
|
||||
let call = Call::<T>::set_foo_using_authorize { new_foo: 42 };
|
||||
let source = TransactionSource::External;
|
||||
Foo::<T>::kill();
|
||||
|
||||
// We use a block with specific code to benchmark the closure.
|
||||
#[block]
|
||||
{
|
||||
use pezframe_support::traits::Authorize;
|
||||
call.authorize(source)
|
||||
.expect("Call give some authorization")
|
||||
.expect("Authorization is successful");
|
||||
}
|
||||
}
|
||||
|
||||
// This line generates test cases for benchmarking, and could be run by:
|
||||
// `cargo test -p pezpallet-example-kitchensink --all-features`, you will see one line per case:
|
||||
// `test benchmarking::bench_set_foo_benchmark ... ok`
|
||||
// `test benchmarking::bench_set_foo_using_authorize_benchmark ... ok` in the result.
|
||||
// `test benchmarking::bench_authorize_set_foo_using_authorize_benchmark ... ok` in the
|
||||
// result.
|
||||
//
|
||||
// The line generates three steps per benchmark, with repeat=1 and the three steps are
|
||||
// [low, mid, high] of the range.
|
||||
impl_benchmark_test_suite!(Kitchensink, crate::tests::new_test_ext(), crate::tests::Test);
|
||||
}
|
||||
@@ -0,0 +1,354 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: MIT-0
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
// of the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
//! # Kitchensink Example Pallet
|
||||
//!
|
||||
//! **This pallet serves as an example and is not meant to be used in production.**
|
||||
//!
|
||||
//! The kitchen-sink catalog of the the FRAME macros and their various syntax options.
|
||||
//!
|
||||
//! This example does not focus on pallet instancing, `dev_mode`, and does nto include any 'where'
|
||||
//! clauses on `T`. These will both incur additional complexity to the syntax, but are not discussed
|
||||
//! here.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
// Re-export pallet items so that they can be accessed from the crate namespace.
|
||||
pub use pallet::*;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
mod benchmarking;
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
use pezsp_runtime::TryRuntimeError;
|
||||
|
||||
pub mod weights;
|
||||
pub use weights::*;
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
|
||||
/// The config trait of the pallet. You can basically do anything with the config trait that you
|
||||
/// can do with a normal rust trait: import items consisting of types, constants and functions.
|
||||
///
|
||||
/// A very common pattern is for a pallet to import implementations of traits such as
|
||||
/// [`pezframe_support::traits::Currency`], [`pezframe_support::traits::fungibles::Inspect`] and
|
||||
/// [`pezframe_support::traits::Get`]. These are all types that the pallet is delegating to the top
|
||||
/// level runtime to provide to it.
|
||||
///
|
||||
/// The `FRAME`-specific syntax are:
|
||||
///
|
||||
/// * the use of `#[pallet::constant]`([`pezframe_support::procedural`]), which places a `Get`
|
||||
/// implementation in the metadata.
|
||||
/// * `type RuntimeEvent`, which is mandatory if your pallet has events. See TODO.
|
||||
/// * Needless to say, because [`Config`] is bounded by [`pezframe_system::Config`], you can use
|
||||
/// all the items from [`pezframe_system::Config`] as well, such as `AccountId`.
|
||||
/// * `#[pallet::disable_pezframe_system_supertrait_check]` would remove the need for
|
||||
/// `pezframe_system::Config` to exist, which you should almost never need.
|
||||
#[pallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// Type representing the weight of this pallet
|
||||
type WeightInfo: WeightInfo;
|
||||
|
||||
/// This is a normal Rust type, nothing specific to FRAME here.
|
||||
type Currency: pezframe_support::traits::fungible::Inspect<Self::AccountId>;
|
||||
|
||||
/// Similarly, let the runtime decide this.
|
||||
fn some_function() -> u32;
|
||||
|
||||
/// And this
|
||||
const FOO: u32;
|
||||
|
||||
/// This is a FRAME-specific item. It will be placed in the metadata of the pallet, and
|
||||
/// therefore can be queried by offchain applications.
|
||||
#[pallet::constant]
|
||||
type InMetadata: Get<u32>;
|
||||
}
|
||||
|
||||
/// Allows you to define some extra constants to be added into constant metadata.
|
||||
#[pallet::extra_constants]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[allow(non_snake_case)]
|
||||
fn SomeValue() -> u32 {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[pallet::constant_name(OtherValue)]
|
||||
fn arbitrary_name() -> u32 {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
const STORAGE_VERSION: pezframe_support::traits::StorageVersion = StorageVersion::new(1);
|
||||
|
||||
/// The pallet struct. There's nothing special to FRAME about this; it can implement functions
|
||||
/// in an impl blocks, traits and so on.
|
||||
#[pallet::pallet]
|
||||
#[pallet::without_storage_info]
|
||||
#[pallet::storage_version(STORAGE_VERSION)]
|
||||
pub struct Pallet<T>(_);
|
||||
|
||||
/// Allows you to define some origin for the pallet.
|
||||
#[pallet::origin]
|
||||
pub type Origin<T> = pezframe_system::RawOrigin<<T as pezframe_system::Config>::AccountId>;
|
||||
|
||||
// first, we showcase all the possible storage types, with most of their details.
|
||||
|
||||
/// A storage value. We mark this as unbounded, alter its prefix, and define a custom storage
|
||||
/// getter for it.
|
||||
///
|
||||
/// The value is stored a single trie node, and therefore can be retrieved with a single
|
||||
/// database access.
|
||||
#[pallet::storage]
|
||||
#[pallet::unbounded] // optional
|
||||
#[pallet::storage_prefix = "OtherFoo"] // optional
|
||||
pub type Foo<T> = StorageValue<Value = u32>;
|
||||
|
||||
#[pallet::type_value]
|
||||
pub fn DefaultForFoo() -> u32 {
|
||||
1
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
pub type FooWithDefault<T> =
|
||||
StorageValue<Value = u32, QueryKind = ValueQuery, OnEmpty = DefaultForFoo>;
|
||||
|
||||
/// A storage map. This creates a mapping from keys of type `u32` to values of type `u32`.
|
||||
///
|
||||
/// Keys and values can be iterated, albeit each value is stored under a unique trie key,
|
||||
/// meaning that an iteration consists of many database accesses.
|
||||
#[pallet::storage]
|
||||
pub type Bar<T> = StorageMap<Hasher = Blake2_128Concat, Key = u32, Value = u32>;
|
||||
|
||||
/// Conceptually same as `StorageMap<>` where the key is a tuple of `(u32, u32)`. On top, it
|
||||
/// provides some functions to iterate or remove items based on only the first key.
|
||||
#[pallet::storage]
|
||||
pub type Qux<T> = StorageDoubleMap<
|
||||
Hasher1 = Blake2_128Concat,
|
||||
Key1 = u32,
|
||||
Hasher2 = Blake2_128Concat,
|
||||
Key2 = u32,
|
||||
Value = u32,
|
||||
>;
|
||||
|
||||
/// Same as `StorageDoubleMap`, but with arbitrary number of keys.
|
||||
#[pallet::storage]
|
||||
pub type Quux<T> = StorageNMap<
|
||||
Key = (
|
||||
NMapKey<Blake2_128Concat, u8>,
|
||||
NMapKey<Blake2_128Concat, u16>,
|
||||
NMapKey<Blake2_128Concat, u32>,
|
||||
),
|
||||
Value = u64,
|
||||
>;
|
||||
|
||||
/// In all of these examples, we chose a syntax where the storage item is defined using the
|
||||
/// explicit generic syntax (`X = Y`). Alternatively:
|
||||
#[pallet::storage]
|
||||
pub type AlternativeSyntax<T> = StorageMap<_, Blake2_128Concat, u32, u32>;
|
||||
|
||||
/// Lastly, all storage items, as you saw, had to be generic over `T`. If they want to use an
|
||||
/// item from `Config`, `<T: Config>` should be used.
|
||||
#[pallet::storage]
|
||||
pub type AlternativeSyntax2<T: Config> = StorageMap<_, Blake2_128Concat, T::AccountId, u32>;
|
||||
|
||||
/// The genesis config type. This allows the pallet to define how it should initialized upon
|
||||
/// genesis.
|
||||
///
|
||||
/// It can be generic over `T` or not, depending on whether it is or not.
|
||||
#[pallet::genesis_config]
|
||||
pub struct GenesisConfig<T: Config> {
|
||||
pub foo: u32,
|
||||
pub bar: BlockNumberFor<T>,
|
||||
}
|
||||
|
||||
impl<T: Config> Default for GenesisConfig<T> {
|
||||
fn default() -> Self {
|
||||
Self { foo: 0, bar: Default::default() }
|
||||
}
|
||||
}
|
||||
|
||||
/// Allows you to define how `genesis_configuration is built.
|
||||
#[pallet::genesis_build]
|
||||
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
||||
fn build(&self) {
|
||||
Foo::<T>::put(self.foo);
|
||||
}
|
||||
}
|
||||
|
||||
/// The call declaration. This states the entry points that we handle. The
|
||||
/// macro takes care of the marshalling of arguments and dispatch.
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(T::WeightInfo::set_foo_benchmark())]
|
||||
/// Marks this call as feeless if `new_foo` is zero.
|
||||
#[pallet::feeless_if(|_origin: &OriginFor<T>, new_foo: &u32, _other_compact: &u128| -> bool {
|
||||
*new_foo == 0
|
||||
})]
|
||||
pub fn set_foo(
|
||||
_: OriginFor<T>,
|
||||
new_foo: u32,
|
||||
#[pallet::compact] _other_compact: u128,
|
||||
) -> DispatchResult {
|
||||
Foo::<T>::set(Some(new_foo));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// A call that is specially authorized.
|
||||
/// Authorized call can be dispatched by anybody without requiring any signature or fee.
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::authorize(|
|
||||
_source: TransactionSource,
|
||||
new_foo: &u32,
|
||||
| -> TransactionValidityWithRefund {
|
||||
if *new_foo == 42 && Foo::<T>::get().is_none() {
|
||||
// This is the amount to refund, here we refund nothing.
|
||||
let refund = Weight::zero();
|
||||
// The transaction needs to give a provided tag.
|
||||
// See `ValidTransaction` documentation.
|
||||
let validity = ValidTransaction::with_tag_prefix("pezpallet-kitchen-sink")
|
||||
.and_provides("set_foo_using_authorize")
|
||||
.into();
|
||||
Ok((validity, refund))
|
||||
} else {
|
||||
Err(InvalidTransaction::Call.into())
|
||||
}
|
||||
})]
|
||||
#[pallet::weight(T::WeightInfo::set_foo_using_authorize())]
|
||||
#[pallet::weight_of_authorize(T::WeightInfo::authorize_set_foo_using_authorize())]
|
||||
pub fn set_foo_using_authorize(origin: OriginFor<T>, new_foo: u32) -> DispatchResult {
|
||||
// We only dispatch if it comes from the authorized origin. Meaning that the closure
|
||||
// passed in `pallet::authorize` has successfully authorized the call.
|
||||
ensure_authorized(origin)?;
|
||||
Foo::<T>::set(Some(new_foo));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// The event type. This exactly like a normal Rust enum.
|
||||
///
|
||||
/// It can or cannot be generic over `<T: Config>`. Note that unlike a normal enum, if none of
|
||||
/// the variants actually use `<T: Config>`, the macro will generate a hidden `PhantomData`
|
||||
/// variant.
|
||||
///
|
||||
/// The `generate_deposit` macro generates a function on `Pallet` called `deposit_event` which
|
||||
/// will properly convert the error type of your pallet into `RuntimeEvent` (recall `type
|
||||
/// RuntimeEvent: From<Event<Self>>`, so it can be converted) and deposit it via
|
||||
/// `pezframe_system::Pallet::deposit_event`.
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// A simple tuple style variant.
|
||||
SomethingHappened(u32),
|
||||
/// A simple struct-style variant. Note that we use `AccountId` from `T` because `T:
|
||||
/// Config`, which by extension implies `T: pezframe_system::Config`.
|
||||
SomethingDetailedHappened { at: u32, to: T::AccountId },
|
||||
/// Another variant.
|
||||
SomeoneJoined(T::AccountId),
|
||||
}
|
||||
|
||||
/// The error enum. Must always be generic over `<T>`, which is expanded to `<T: Config>`.
|
||||
#[pallet::error]
|
||||
pub enum Error<T> {
|
||||
SomethingWentWrong,
|
||||
SomethingBroke,
|
||||
}
|
||||
|
||||
/// All the possible hooks that a pallet can have. See [`pezframe_support::traits::Hooks`] for more
|
||||
/// info.
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
|
||||
fn integrity_test() {}
|
||||
|
||||
fn offchain_worker(_n: BlockNumberFor<T>) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn on_initialize(_n: BlockNumberFor<T>) -> Weight {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn on_finalize(_n: BlockNumberFor<T>) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn on_idle(_n: BlockNumberFor<T>, _remaining_weight: Weight) -> Weight {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade(_state: Vec<u8>) -> Result<(), TryRuntimeError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn try_state(_n: BlockNumberFor<T>) -> Result<(), TryRuntimeError> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
/// Allows you to define an enum on the pallet which will then instruct `construct_runtime` to
|
||||
/// amalgamate all similarly-named enums from other pallets into an aggregate enum.
|
||||
#[pallet::composite_enum]
|
||||
pub enum HoldReason {
|
||||
Staking,
|
||||
}
|
||||
|
||||
/// Allows the pallet to provide some inherent. See [`pezframe_support::inherent::ProvideInherent`]
|
||||
/// for more info.
|
||||
#[pallet::inherent]
|
||||
impl<T: Config> ProvideInherent for Pallet<T> {
|
||||
type Call = Call<T>;
|
||||
type Error = MakeFatalError<()>;
|
||||
|
||||
const INHERENT_IDENTIFIER: [u8; 8] = *b"test1234";
|
||||
|
||||
fn create_inherent(_data: &InherentData) -> Option<Self::Call> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn is_inherent(_call: &Self::Call) -> bool {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: MIT-0
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
// of the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
//! Tests for pezpallet-example-kitchensink.
|
||||
|
||||
use crate::*;
|
||||
use pezframe_support::{assert_ok, derive_impl, parameter_types, traits::VariantCountOf};
|
||||
use pezsp_runtime::BuildStorage;
|
||||
// Reexport crate as its pallet name for construct_runtime.
|
||||
use crate as pezpallet_example_kitchensink;
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Test>;
|
||||
|
||||
// For testing the pallet, we construct a mock runtime.
|
||||
pezframe_support::construct_runtime!(
|
||||
pub enum Test
|
||||
{
|
||||
System: pezframe_system::{Pallet, Call, Config<T>, Storage, Event<T>},
|
||||
Balances: pezpallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
Kitchensink: pezpallet_example_kitchensink::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
}
|
||||
);
|
||||
|
||||
/// Using a default config for [`pezframe_system`] in tests. See `default-config` example for more
|
||||
/// details.
|
||||
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
|
||||
impl pezframe_system::Config for Test {
|
||||
type Block = Block;
|
||||
type AccountData = pezpallet_balances::AccountData<u64>;
|
||||
}
|
||||
|
||||
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_balances::Config for Test {
|
||||
type AccountStore = System;
|
||||
type WeightInfo = ();
|
||||
type FreezeIdentifier = RuntimeFreezeReason;
|
||||
type MaxFreezes = VariantCountOf<RuntimeFreezeReason>;
|
||||
type RuntimeHoldReason = RuntimeHoldReason;
|
||||
type RuntimeFreezeReason = RuntimeFreezeReason;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const InMetadata: u32 = 30;
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
type WeightInfo = ();
|
||||
|
||||
type Currency = Balances;
|
||||
type InMetadata = InMetadata;
|
||||
|
||||
const FOO: u32 = 100;
|
||||
|
||||
fn some_function() -> u32 {
|
||||
5u32
|
||||
}
|
||||
}
|
||||
|
||||
// This function basically just builds a genesis storage key/value store according to
|
||||
// our desired mockup.
|
||||
pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
let t = RuntimeGenesisConfig {
|
||||
// We use default for brevity, but you can configure as desired if needed.
|
||||
system: Default::default(),
|
||||
balances: Default::default(),
|
||||
kitchensink: pezpallet_example_kitchensink::GenesisConfig { bar: 32, foo: 24 },
|
||||
}
|
||||
.build_storage()
|
||||
.unwrap();
|
||||
t.into()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_foo_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_eq!(Foo::<Test>::get(), Some(24)); // From genesis config.
|
||||
|
||||
let val1 = 42;
|
||||
assert_ok!(Kitchensink::set_foo(RuntimeOrigin::root(), val1, 2));
|
||||
assert_eq!(Foo::<Test>::get(), Some(val1));
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: MIT-0
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
// of the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
//! Autogenerated weights for `pezpallet_example_kitchensink`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2023-06-02, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `MacBook.local`, CPU: `<UNKNOWN>`
|
||||
//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./target/release/node-template
|
||||
// benchmark
|
||||
// pallet
|
||||
// --chain
|
||||
// dev
|
||||
// --pallet
|
||||
// pezpallet_example_kitchensink
|
||||
// --extrinsic
|
||||
// *
|
||||
// --steps
|
||||
// 20
|
||||
// --repeat
|
||||
// 10
|
||||
// --output
|
||||
// frame/examples/kitchensink/src/weights.rs
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions needed for pezpallet_template.
|
||||
pub trait WeightInfo {
|
||||
fn set_foo_benchmark() -> Weight;
|
||||
fn set_foo_using_authorize() -> Weight;
|
||||
fn authorize_set_foo_using_authorize() -> Weight;
|
||||
}
|
||||
|
||||
/// Weight functions for `pezpallet_example_kitchensink`.
|
||||
pub struct BizinikiwiWeight<T>(PhantomData<T>);
|
||||
impl<T: pezframe_system::Config> WeightInfo for BizinikiwiWeight<T> {
|
||||
/// Storage: Kitchensink OtherFoo (r:0 w:1)
|
||||
/// Proof Skipped: Kitchensink OtherFoo (max_values: Some(1), max_size: None, mode: Measured)
|
||||
fn set_foo_benchmark() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 1_000_000 picoseconds.
|
||||
Weight::from_parts(1_000_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 0))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
fn set_foo_using_authorize() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
fn authorize_set_foo_using_authorize() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
}
|
||||
|
||||
impl WeightInfo for () {
|
||||
/// Storage: Kitchensink OtherFoo (r:0 w:1)
|
||||
/// Proof Skipped: Kitchensink OtherFoo (max_values: Some(1), max_size: None, mode: Measured)
|
||||
fn set_foo_benchmark() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 1_000_000 picoseconds.
|
||||
Weight::from_parts(1_000_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 0))
|
||||
.saturating_add(RocksDbWeight::get().writes(1))
|
||||
}
|
||||
fn set_foo_using_authorize() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
fn authorize_set_foo_using_authorize() -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user