Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frame/support/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pretty_assertions = "0.6.1"
rustversion = "1.0.0"
frame-metadata = { version = "13.0.0", default-features = false, path = "../../metadata" }
frame-system = { version = "3.0.0", default-features = false, path = "../../system" }
test-pallet = { package = "frame-support-test-pallet", default-features = false, path = "pallet" }
Comment thread
KiChjang marked this conversation as resolved.

[features]
default = ["std"]
Expand Down
31 changes: 31 additions & 0 deletions frame/support/test/pallet/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "frame-support-test-pallet"
version = "3.0.0"
Comment thread
gui1117 marked this conversation as resolved.
Outdated
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
license = "Apache-2.0"
publish = false
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/substrate/"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
sp-io = { version = "3.0.0", path = "../../../../primitives/io", default-features = false }
sp-runtime = { version = "3.0.0", default-features = false, path = "../../../../primitives/runtime" }
sp-std = { version = "3.0.0", default-features = false, path = "../../../../primitives/std" }
frame-support = { version = "3.0.0", default-features = false, path = "../../" }
Comment thread
gui1117 marked this conversation as resolved.
Outdated
frame-system = { version = "3.0.0", default-features = false, path = "../../../system" }
Comment thread
gui1117 marked this conversation as resolved.
Outdated

[features]
default = ["std"]
std = [
"codec/std",
"frame-support/std",
"frame-system/std",
"sp-io/std",
"sp-std/std",
"sp-runtime/std",
]
Comment thread
KiChjang marked this conversation as resolved.
46 changes: 46 additions & 0 deletions frame/support/test/pallet/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// This file is part of Substrate.

// Copyright (C) 2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
pub use pallet::*;

#[frame_support::pallet]
pub mod pallet {
#[allow(unused_imports)]
use frame_support::pallet_prelude::*;
#[allow(unused_imports)]
use frame_system::pallet_prelude::*;

#[pallet::pallet]
pub struct Pallet<T>(_);

#[pallet::config]
pub trait Config: frame_system::Config {}

#[pallet::genesis_config]
pub struct GenesisConfig {}

#[cfg(feature = "std")]
impl Default for GenesisConfig {
fn default() -> Self {
Self {}
}
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig {
fn build(&self) {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use frame_support::construct_runtime;
use sp_runtime::{generic, traits::BlakeTwo256};
use sp_core::sr25519;

pub type Signature = sr25519::Signature;
pub type BlockNumber = u64;
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<u32, Call, Signature, ()>;

impl test_pallet::Config for Runtime {}

construct_runtime! {
pub enum Runtime where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: system::{Pallet, Call, Storage, Config, Event<T>},
Pallet: test_pallet::{Pallet, Config},
}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
error: `Pallet` does not have the std feature enabled, this will cause the `PalletConfig` type to be undefined.
Comment thread
KiChjang marked this conversation as resolved.
Outdated
--> $DIR/no_std_genesis_config.rs:13:1
|
13 | / construct_runtime! {
14 | | pub enum Runtime where
15 | | Block = Block,
16 | | NodeBlock = Block,
... |
21 | | }
22 | | }
| |_^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: use of undeclared crate or module `system`
--> $DIR/no_std_genesis_config.rs:19:11
|
19 | System: system::{Pallet, Call, Storage, Config, Event<T>},
| ^^^^^^ use of undeclared crate or module `system`

error[E0433]: failed to resolve: use of undeclared crate or module `system`
--> $DIR/no_std_genesis_config.rs:13:1
|
13 | / construct_runtime! {
14 | | pub enum Runtime where
15 | | Block = Block,
16 | | NodeBlock = Block,
... |
21 | | }
22 | | }
| |_^ not found in `system`
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this enum
|
1 | use frame_system::RawOrigin;
|

error[E0412]: cannot find type `GenesisConfig` in crate `test_pallet`
--> $DIR/no_std_genesis_config.rs:13:1
|
13 | / construct_runtime! {
14 | | pub enum Runtime where
15 | | Block = Block,
16 | | NodeBlock = Block,
... |
21 | | }
22 | | }
| |_^ not found in `test_pallet`
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this struct
|
1 | use frame_system::GenesisConfig;
|

error[E0277]: the trait bound `Runtime: frame_system::pallet::Config` is not satisfied
--> $DIR/no_std_genesis_config.rs:11:6
|
11 | impl test_pallet::Config for Runtime {}
| ^^^^^^^^^^^^^^^^^^^ the trait `frame_system::pallet::Config` is not implemented for `Runtime`
|
::: $WORKSPACE/frame/support/test/pallet/src/lib.rs
|
| pub trait Config: frame_system::Config {}
| -------------------- required by this bound in `Config`