My question is
What is the difference between dependencies and dev-dependencies in Cargo.toml. And for developing pallet, now I have to declare crate in
This is a general Rust concept:
[dev-dependencies] are the crates you only need for compiling and running tests.
There are at least two advantages of separating test crates in this way:
When compiling for release, these test crates are not compiled into your binary, which can save space and compilation time.
Normally, the Rust compiler checks for and prohibits any cyclic dependencies. For
[dev-dependencies], this check is ignored, allowing two crates to be dependent on eachother specifically for tests.
If you use a crate in your main code, you must include it as a
[dependencies], however, if you only use it for tests, then you should place it as a
If you are confused, I recommend to copy patterns from other crates found in Substrate.