cleanup
This commit is contained in:
parent
1f4d5fb860
commit
cb16bdb350
@ -279,11 +279,17 @@ pub enum OutputPolicy<'a> {
|
|||||||
|
|
||||||
/// Implementation of evm Externalities.
|
/// Implementation of evm Externalities.
|
||||||
pub struct Externalities<'a> {
|
pub struct Externalities<'a> {
|
||||||
|
#[cfg(test)]
|
||||||
pub state: &'a mut State,
|
pub state: &'a mut State,
|
||||||
|
#[cfg(not(test))]
|
||||||
|
state: &'a mut State,
|
||||||
info: &'a EnvInfo,
|
info: &'a EnvInfo,
|
||||||
engine: &'a Engine,
|
engine: &'a Engine,
|
||||||
depth: usize,
|
depth: usize,
|
||||||
|
#[cfg(test)]
|
||||||
pub params: &'a ActionParams,
|
pub params: &'a ActionParams,
|
||||||
|
#[cfg(not(test))]
|
||||||
|
params: &'a ActionParams,
|
||||||
substate: &'a mut Substate,
|
substate: &'a mut Substate,
|
||||||
schedule: Schedule,
|
schedule: Schedule,
|
||||||
output: OutputPolicy<'a>
|
output: OutputPolicy<'a>
|
||||||
@ -482,7 +488,6 @@ mod tests {
|
|||||||
use engine::*;
|
use engine::*;
|
||||||
use spec::*;
|
use spec::*;
|
||||||
use evm::Schedule;
|
use evm::Schedule;
|
||||||
//use super::Substate;
|
|
||||||
|
|
||||||
struct TestEngine {
|
struct TestEngine {
|
||||||
spec: Spec,
|
spec: Spec,
|
||||||
|
@ -4,14 +4,14 @@ use ethereum;
|
|||||||
|
|
||||||
pub fn hashmap_h256_h256_from_json(json: &Json) -> HashMap<H256, H256> {
|
pub fn hashmap_h256_h256_from_json(json: &Json) -> HashMap<H256, H256> {
|
||||||
json.as_object().unwrap().iter().fold(HashMap::new(), |mut m, (key, value)| {
|
json.as_object().unwrap().iter().fold(HashMap::new(), |mut m, (key, value)| {
|
||||||
m.insert(H256::from(&u256_from_hex(key)), H256::from(&u256_from_json(value)));
|
m.insert(H256::from(&u256_from_str(key)), H256::from(&u256_from_json(value)));
|
||||||
m
|
m
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn map_h256_h256_from_json(json: &Json) -> BTreeMap<H256, H256> {
|
pub fn map_h256_h256_from_json(json: &Json) -> BTreeMap<H256, H256> {
|
||||||
json.as_object().unwrap().iter().fold(BTreeMap::new(), |mut m, (key, value)| {
|
json.as_object().unwrap().iter().fold(BTreeMap::new(), |mut m, (key, value)| {
|
||||||
m.insert(H256::from(&u256_from_hex(key)), H256::from(&u256_from_json(value)));
|
m.insert(H256::from(&u256_from_str(key)), H256::from(&u256_from_json(value)));
|
||||||
m
|
m
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
pub use common::*;
|
pub use common::*;
|
||||||
|
|
||||||
pub fn address_from_str<'a>(s: &'a str) -> Address {
|
|
||||||
if s.len() % 2 == 1 {
|
|
||||||
address_from_hex(&("0".to_string() + &(clean(s).to_string()))[..])
|
|
||||||
} else {
|
|
||||||
address_from_hex(clean(s))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn u256_from_str<'a>(s: &'a str) -> U256 {
|
|
||||||
if s.len() >= 2 && &s[0..2] == "0x" {
|
|
||||||
// hex
|
|
||||||
U256::from_str(&s[2..]).unwrap()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// dec
|
|
||||||
U256::from_dec_str(s).unwrap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! declare_test {
|
macro_rules! declare_test {
|
||||||
($id: ident, $name: expr) => {
|
($id: ident, $name: expr) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user