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

[pdsl_core] Add loggin to TestEnv Env calls

parent cf84e872
......@@ -21,6 +21,7 @@ include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
parity-codec = { version = "2.0" }
parity-codec-derive = { version = "2.0" }
tiny-keccak = "1.4"
log = "0.4"
[features]
default = []
......
......@@ -453,42 +453,69 @@ mod test {
}
}
const TEST_ENV_LOG_TARGET: &'static str = "test-env";
impl Env for TestEnv {
fn caller() -> Vec<u8> {
println!("TestEnv::caller()");
log::debug!(
target: TEST_ENV_LOG_TARGET,
"TestEnv::caller()"
);
TEST_ENV_DATA.with(|test_env| {
test_env.borrow().caller()
})
}
fn store(key: &[u8], value: &[u8]) {
println!("TestEnv::store(\n\tkey: {:?},\n\tval: {:?}\n)", key, value);
log::debug!(
target: TEST_ENV_LOG_TARGET,
"TestEnv::store(\n\tkey: {:?},\n\tval: {:?}\n)",
key,
value,
);
TEST_ENV_DATA.with(|test_env| {
test_env.borrow_mut().store(key, value)
})
}
fn clear(key: &[u8]) {
println!("TestEnv::clear(\n\tkey: {:?}\n)", key);
log::debug!(
target: TEST_ENV_LOG_TARGET,
"TestEnv::clear(\n\tkey: {:?}\n)",
key,
);
TEST_ENV_DATA.with(|test_env| {
test_env.borrow_mut().clear(key)
})
}
fn load(key: &[u8]) -> Option<Vec<u8>> {
println!("TestEnv::load(\n\tkey: {:?}\n)", key);
log::debug!(
target: TEST_ENV_LOG_TARGET,
"TestEnv::load(\n\tkey: {:?}\n)",
key,
);
TEST_ENV_DATA.with(|test_env| {
test_env.borrow().load(key)
})
}
fn input() -> Vec<u8> {
log::debug!(
target: TEST_ENV_LOG_TARGET,
"TestEnv::input()",
);
TEST_ENV_DATA.with(|test_env| {
test_env.borrow().input()
})
}
fn return_(data: &[u8]) -> ! {
log::debug!(
target: TEST_ENV_LOG_TARGET,
"TestEnv::return_(\n\tdata: {:?}\n)",
data,
);
TEST_ENV_DATA.with(|test_env| {
test_env.borrow().return_(data)
})
......
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