Commit f0e356b3 authored by Hero Bird's avatar Hero Bird
Browse files

[pdsl_core] Add test-env crate feature

This enabled TestEnv and disabled DefaultEnv.
Use this for testing.
Before this commit the standard "test" feature was used, however, its problem is that the test feature is crate-local and cannot be enabled or disabled by dependencies.
parent 6d6ea861
......@@ -21,6 +21,8 @@ include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
parity-codec = { version = "2.0" }
parity-codec-derive = { version = "2.0" }
tiny-keccak = "1.4"
lazy_static = { version = "1.2", optional = true }
[dev-dependencies]
lazy_static = "1.2"
[features]
default = []
test-env = ["lazy_static"]
......@@ -130,7 +130,7 @@ where
}
}
#[cfg(test)]
#[cfg(all(test, feature = "test-env"))]
mod test {
use super::*;
......
......@@ -56,7 +56,7 @@ pub trait Env {
fn return_(value: &[u8]) -> !;
}
#[cfg(not(test))]
#[cfg(not(feature = "test-env"))]
mod default {
use super::*;
......@@ -131,7 +131,7 @@ mod default {
}
}
#[cfg(test)]
#[cfg(feature = "test-env")]
mod test {
use super::*;
......@@ -208,10 +208,10 @@ mod test {
}
}
#[cfg(not(test))]
#[cfg(not(feature = "test-env"))]
pub use self::default::DefaultEnv;
#[cfg(test)]
#[cfg(feature = "test-env")]
pub use self::test::TestEnv;
/// The environment implementation that is currently being used.
......@@ -222,9 +222,9 @@ pub use self::test::TestEnv;
/// - `TestEnv` for emulating a contract environment
/// that can be inspected by the user and used
/// for testing contracts off-chain.
#[cfg(not(test))]
#[cfg(not(feature = "test-env"))]
pub type ContractEnv = self::default::DefaultEnv;
/// The environment implementation that is currently being used.
#[cfg(test)]
#[cfg(feature = "test-env")]
pub type ContractEnv = self::test::TestEnv;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment