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

  • 相关阅读:
    fatal error LNK1123: failure during conversion to COFF: file invalid or corr
    BEGIN_SINK_MAP(CMainDlg) SINK_ENTRY(IDC_EXPLORER1, ..。响应不到的
    第三周项目3-程序的多文件组织
    第三周项目2-三角形类(二)
    第三周项目1-三角形类(一)
    第三周课后实践-阅读程序
    第二周项目4-图书馆的书
    第二周项目3-时间类
    第二周项目2-长方柱类
    第二周项目1-旱冰场造价
  • 原文地址:https://www.cnblogs.com/Davirain/p/14241320.html
Copyright © 2011-2022 走看看