Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
ink
Commits
fd037c0e
Commit
fd037c0e
authored
Dec 13, 2018
by
Hero Bird
Browse files
[pdsl_core] Add loggin to TestEnv Env calls
parent
cf84e872
Changes
2
Hide whitespace changes
Inline
Side-by-side
pdsl_core/Cargo.toml
View file @
fd037c0e
...
...
@@ -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
=
[]
...
...
pdsl_core/src/env.rs
View file @
fd037c0e
...
...
@@ -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\t
key: {:?},
\n\t
val: {:?}
\n
)"
,
key
,
value
);
log
::
debug!
(
target
:
TEST_ENV_LOG_TARGET
,
"TestEnv::store(
\n\t
key: {:?},
\n\t
val: {:?}
\n
)"
,
key
,
value
,
);
TEST_ENV_DATA
.with
(|
test_env
|
{
test_env
.borrow_mut
()
.store
(
key
,
value
)
})
}
fn
clear
(
key
:
&
[
u8
])
{
println!
(
"TestEnv::clear(
\n\t
key: {:?}
\n
)"
,
key
);
log
::
debug!
(
target
:
TEST_ENV_LOG_TARGET
,
"TestEnv::clear(
\n\t
key: {:?}
\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\t
key: {:?}
\n
)"
,
key
);
log
::
debug!
(
target
:
TEST_ENV_LOG_TARGET
,
"TestEnv::load(
\n\t
key: {:?}
\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\t
data: {:?}
\n
)"
,
data
,
);
TEST_ENV_DATA
.with
(|
test_env
|
{
test_env
.borrow
()
.return_
(
data
)
})
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment