zoukankan      html  css  js  c++  java
  • substrate 编译出错unresolved import `sp_runtime::testing` failed to resolve: could not find `GenesisConfig` in `system`

     error[E0432]: unresolved import `sp_runtime::testing`
       --> /Users/suyinrong/bitcoin-proj/substrate-course/substrate-node-template/pallets/poe/src/mock.rs:5:41
        |
      5 |     traits::{BlakeTwo256, IdentityLookup}, testing::Header, Perbill,
        |                                            ^^^^^^^ could not find `testing` in `sp_runtime`
    
      error[E0433]: failed to resolve: could not find `GenesisConfig` in `system`
        --> /Users/suyinrong/bitcoin-proj/substrate-course/substrate-node-template/pallets/poe/src/mock.rs:66:10
         |
      66 |     system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
         |             ^^^^^^^^^^^^^ could not find `GenesisConfig` in `system`
    
      error[E0412]: cannot find type `Box` in this scope
        --> /Users/suyinrong/bitcoin-proj/substrate-course/substrate-node-template/pallets/poe/src/mock.rs:10:1
         |
      10 | / impl_outer_origin! {
      11 | |     pub enum Origin for Test {}
      12 | | }
         | |_^ not found in this scope
         |
         = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
      help: consider importing one of these items
         |
      1  | use crate::Box;
         |
      1  | use frame_support::traits::Box;
         |
      1  | use sp_std::boxed::Box;
         |
    
      error[E0433]: failed to resolve: use of undeclared type `Box`
        --> /Users/suyinrong/bitcoin-proj/substrate-course/substrate-node-template/pallets/poe/src/mock.rs:10:1
         |
      10 | / impl_outer_origin! {
      11 | |     pub enum Origin for Test {}
      12 | | }
         | |_^ not found in this scope
         |
         = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
      help: consider importing one of these items
         |
      1  | use crate::Box;
         |
      1  | use frame_support::traits::Box;
         |
      1  | use sp_std::boxed::Box;
         |
    
      error[E0433]: failed to resolve: use of undeclared type `Box`
        --> /Users/suyinrong/bitcoin-proj/substrate-course/substrate-node-template/pallets/poe/src/mock.rs:10:1
         |
      10 | / impl_outer_origin! {
      11 | |     pub enum Origin for Test {}
      12 | | }
         | |_^ not found in this scope
         |
         = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
      help: consider importing one of these items
         |
      1  | use crate::Box;
         |
      1  | use frame_support::traits::Box;
         |
      1  | use sp_std::boxed::Box;
         |
    
      error[E0433]: failed to resolve: use of undeclared type `Box`
        --> /Users/suyinrong/bitcoin-proj/substrate-course/substrate-node-template/pallets/poe/src/mock.rs:10:1
         |
      10 | / impl_outer_origin! {
      11 | |     pub enum Origin for Test {}
      12 | | }
         | |_^ not found in this scope
         |
         = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
      help: consider importing one of these items
         |
      1  | use crate::Box;
         |
      1  | use frame_support::traits::Box;
         |
      1  | use sp_std::boxed::Box;
         |
    
      error[E0412]: cannot find type `TestExternalities` in crate `sp_io`
        --> /Users/suyinrong/bitcoin-proj/substrate-course/substrate-node-template/pallets/poe/src/mock.rs:65:33
         |
      65 | pub fn new_test_ext() -> sp_io::TestExternalities {
         |                                 ^^^^^^^^^^^^^^^^^ not found in `sp_io`
    
      error: aborting due to 7 previous errors
    
      Some errors have detailed explanations: E0412, E0432, E0433.
      For more information about an error, try `rustc --explain E0412`.
      error: could not compile `pallet-poe`
    
      To learn more, run the command again with --verbose.
    

    遇见此类错误信息是因为,在你的测试mod上面需要加上#[cfg(test)]

    例如我这里就是在mod mork上没有添加此类设置报错。  

  • 相关阅读:
    五十二、使用Adb命令卸载android应用配置方法
    五十五、application用法
    五十七、SlidingDrawer (抽屉)的用法
    五十三、android启动过程
    六十、百度地图
    六十一、ListView,GridView和ScrollView上拉刷新和下拉更多
    显示设备信息
    打开HTML代码对应的页面
    体质指数计算
    OpenWebPage
  • 原文地址:https://www.cnblogs.com/Davirain/p/14241320.html
Copyright © 2011-2022 走看看