fixed conflicting namespaces
This commit is contained in:
parent
dabce9ab45
commit
4ab99a6bb3
@ -26,29 +26,29 @@ use externalities::*;
|
|||||||
use substate::*;
|
use substate::*;
|
||||||
use tests::helpers::*;
|
use tests::helpers::*;
|
||||||
|
|
||||||
struct TestEngine {
|
struct TestEngineFrontier {
|
||||||
vm_factory: Factory,
|
vm_factory: Factory,
|
||||||
spec: Spec,
|
spec: Spec,
|
||||||
max_depth: usize
|
max_depth: usize
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestEngine {
|
impl TestEngineFrontier {
|
||||||
fn new(max_depth: usize, vm_type: VMType) -> TestEngine {
|
fn new(max_depth: usize, vm_type: VMType) -> TestEngineFrontier {
|
||||||
TestEngine {
|
TestEngineFrontier {
|
||||||
vm_factory: Factory::new(vm_type),
|
vm_factory: Factory::new(vm_type),
|
||||||
spec: ethereum::new_frontier_test(),
|
spec: ethereum::new_frontier_test(),
|
||||||
max_depth: max_depth
|
max_depth: max_depth
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Engine for TestEngine {
|
impl Engine for TestEngineFrontier {
|
||||||
fn name(&self) -> &str { "TestEngine" }
|
fn name(&self) -> &str { "TestEngine" }
|
||||||
fn spec(&self) -> &Spec { &self.spec }
|
fn spec(&self) -> &Spec { &self.spec }
|
||||||
fn vm_factory(&self) -> &Factory { &self.vm_factory }
|
fn vm_factory(&self) -> &Factory { &self.vm_factory }
|
||||||
fn schedule(&self, _env_info: &EnvInfo) -> Schedule {
|
fn schedule(&self, _env_info: &EnvInfo) -> Schedule {
|
||||||
let mut schedule = Schedule::new_frontier();
|
let mut schedule = Schedule::new_frontier();
|
||||||
schedule.max_depth = self.max_depth;
|
schedule.max_depth = self.max_depth;
|
||||||
schedule
|
schedule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,12 +69,12 @@ struct TestExt<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TestExt<'a> {
|
impl<'a> TestExt<'a> {
|
||||||
fn new(state: &'a mut State,
|
fn new(state: &'a mut State,
|
||||||
info: &'a EnvInfo,
|
info: &'a EnvInfo,
|
||||||
engine: &'a Engine,
|
engine: &'a Engine,
|
||||||
depth: usize,
|
depth: usize,
|
||||||
origin_info: OriginInfo,
|
origin_info: OriginInfo,
|
||||||
substate: &'a mut Substate,
|
substate: &'a mut Substate,
|
||||||
output: OutputPolicy<'a>,
|
output: OutputPolicy<'a>,
|
||||||
address: Address) -> Self {
|
address: Address) -> Self {
|
||||||
TestExt {
|
TestExt {
|
||||||
@ -116,13 +116,13 @@ impl<'a> Ext for TestExt<'a> {
|
|||||||
ContractCreateResult::Created(self.contract_address.clone(), *gas)
|
ContractCreateResult::Created(self.contract_address.clone(), *gas)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call(&mut self,
|
fn call(&mut self,
|
||||||
gas: &U256,
|
gas: &U256,
|
||||||
_sender_address: &Address,
|
_sender_address: &Address,
|
||||||
receive_address: &Address,
|
receive_address: &Address,
|
||||||
value: Option<U256>,
|
value: Option<U256>,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
_code_address: &Address,
|
_code_address: &Address,
|
||||||
_output: &mut [u8]) -> MessageCallResult {
|
_output: &mut [u8]) -> MessageCallResult {
|
||||||
self.callcreates.push(CallCreate {
|
self.callcreates.push(CallCreate {
|
||||||
data: data.to_vec(),
|
data: data.to_vec(),
|
||||||
@ -136,7 +136,7 @@ impl<'a> Ext for TestExt<'a> {
|
|||||||
fn extcode(&self, address: &Address) -> Bytes {
|
fn extcode(&self, address: &Address) -> Bytes {
|
||||||
self.ext.extcode(address)
|
self.ext.extcode(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn log(&mut self, topics: Vec<H256>, data: &[u8]) {
|
fn log(&mut self, topics: Vec<H256>, data: &[u8]) {
|
||||||
self.ext.log(topics, data)
|
self.ext.log(topics, data)
|
||||||
}
|
}
|
||||||
@ -185,11 +185,11 @@ fn do_json_test_for(vm: &VMType, json_data: &[u8]) -> Vec<String> {
|
|||||||
// ::std::io::stdout().flush();
|
// ::std::io::stdout().flush();
|
||||||
let mut fail = false;
|
let mut fail = false;
|
||||||
//let mut fail_unless = |cond: bool| if !cond && !fail { failed.push(name.to_string()); fail = true };
|
//let mut fail_unless = |cond: bool| if !cond && !fail { failed.push(name.to_string()); fail = true };
|
||||||
let mut fail_unless = |cond: bool, s: &str | if !cond && !fail {
|
let mut fail_unless = |cond: bool, s: &str | if !cond && !fail {
|
||||||
failed.push(format!("[{}] {}: {}", vm, name, s));
|
failed.push(format!("[{}] {}: {}", vm, name, s));
|
||||||
fail = true
|
fail = true
|
||||||
};
|
};
|
||||||
|
|
||||||
// test env
|
// test env
|
||||||
let mut state_result = get_temp_state();
|
let mut state_result = get_temp_state();
|
||||||
let mut state = state_result.reference_mut();
|
let mut state = state_result.reference_mut();
|
||||||
@ -209,7 +209,7 @@ fn do_json_test_for(vm: &VMType, json_data: &[u8]) -> Vec<String> {
|
|||||||
EnvInfo::from_json(env)
|
EnvInfo::from_json(env)
|
||||||
}).unwrap_or_default();
|
}).unwrap_or_default();
|
||||||
|
|
||||||
let engine = TestEngine::new(1, vm.clone());
|
let engine = TestEngineFrontier::new(1, vm.clone());
|
||||||
|
|
||||||
// params
|
// params
|
||||||
let mut params = ActionParams::default();
|
let mut params = ActionParams::default();
|
||||||
@ -226,18 +226,18 @@ fn do_json_test_for(vm: &VMType, json_data: &[u8]) -> Vec<String> {
|
|||||||
|
|
||||||
let out_of_gas = test.find("callcreates").map(|_calls| {
|
let out_of_gas = test.find("callcreates").map(|_calls| {
|
||||||
}).is_none();
|
}).is_none();
|
||||||
|
|
||||||
let mut substate = Substate::new();
|
let mut substate = Substate::new();
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
|
|
||||||
// execute
|
// execute
|
||||||
let (res, callcreates) = {
|
let (res, callcreates) = {
|
||||||
let mut ex = TestExt::new(&mut state,
|
let mut ex = TestExt::new(&mut state,
|
||||||
&info,
|
&info,
|
||||||
&engine,
|
&engine,
|
||||||
0,
|
0,
|
||||||
OriginInfo::from(¶ms),
|
OriginInfo::from(¶ms),
|
||||||
&mut substate,
|
&mut substate,
|
||||||
OutputPolicy::Return(BytesRef::Flexible(&mut output)),
|
OutputPolicy::Return(BytesRef::Flexible(&mut output)),
|
||||||
params.address.clone());
|
params.address.clone());
|
||||||
let evm = engine.vm_factory().create();
|
let evm = engine.vm_factory().create();
|
||||||
|
Loading…
Reference in New Issue
Block a user