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上没有添加此类设置报错。  

  • 相关阅读:
    Js原型对象理解
    Garbage In Garbage Out
    JournalNode的作用
    SecondaryNameNode 的作用
    Hive Map数据长尾问题
    Hive基本操作
    Hadoop中NameNode的工作机制
    技术架构分析与架构分析
    Sqoop报错Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
    项目管理PMP相关
  • 原文地址:https://www.cnblogs.com/Davirain/p/14241320.html
Copyright © 2011-2022 走看看