We often use some basic substrate crates such as sp-core, and sp-io while doing pallet tests. In general, those dependencies are put under [dev-dependencies]. But I have an issue with whether we should add default-features = false or not. Seems both work.

For example:

# pallet crate level

frame-system = = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
# no sp-io here

# With`default-features = false`
sp-io = = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }


# Without default-features = false
sp-io = = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }

In the pallet tests (both ways can compile):

// mock.rs
use sp_io::TestExternalities;

Check from the substrate repo:

/// Type alias for Externalities implementation used in tests.
#[cfg(feature = "std")]  // this line
pub type TestExternalities = sp_state_machine::TestExternalities<sp_core::Blake2Hasher>;

As the code snippet shows, the TestExternalities is only available understd feature.So why the first way, With default-features = false can be compiled?

1 Answer 1


I think it's because the frame-system also depends on sp-io. And you enable the std for the frame-system in the test env, which also enables the sp-io/std for the whole scope.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.