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

  • 相关阅读:
    数据绑定表达式语法(Eval,Bind区别)
    使用博客园的第一件事 自定义主题
    sql2000 跨服务器复制表数据
    使用UpdatePanel 局部刷新出现中文乱码的解决方法!!
    MMC不能打开文件MSC文件
    sql 日期 、时间相关
    loaded AS2 swf call function in AS3 holder
    Rewrite the master page form action attribute in asp.net 2.0
    100万个不重复的8位的随机数
    flash 中实现斜切变型
  • 原文地址:https://www.cnblogs.com/Davirain/p/14241320.html
Copyright © 2011-2022 走看看