Fix consensus test code.
This commit is contained in:
parent
22c4298bee
commit
af05939d74
@ -25,6 +25,7 @@ use substate::*;
|
|||||||
use tests::helpers::*;
|
use tests::helpers::*;
|
||||||
use ethjson;
|
use ethjson;
|
||||||
use trace::{Tracer, NoopTracer};
|
use trace::{Tracer, NoopTracer};
|
||||||
|
use trace::{VMTracer, NoopVMTracer};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
struct CallCreate {
|
struct CallCreate {
|
||||||
@ -48,14 +49,15 @@ impl From<ethjson::vm::Call> for CallCreate {
|
|||||||
|
|
||||||
/// Tiny wrapper around executive externalities.
|
/// Tiny wrapper around executive externalities.
|
||||||
/// Stores callcreates.
|
/// Stores callcreates.
|
||||||
struct TestExt<'a, T> where T: 'a + Tracer {
|
struct TestExt<'a, T, V> where T: 'a + Tracer, V: 'a + VMTracer {
|
||||||
ext: Externalities<'a, T>,
|
ext: Externalities<'a, T, V>,
|
||||||
callcreates: Vec<CallCreate>,
|
callcreates: Vec<CallCreate>,
|
||||||
contract_address: Address
|
contract_address: Address
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T> TestExt<'a, T> where T: 'a + Tracer {
|
impl<'a, T, V> TestExt<'a, T, V> where T: 'a + Tracer, V: 'a + VMTracer {
|
||||||
fn new(state: &'a mut State,
|
fn new(
|
||||||
|
state: &'a mut State,
|
||||||
info: &'a EnvInfo,
|
info: &'a EnvInfo,
|
||||||
engine: &'a Engine,
|
engine: &'a Engine,
|
||||||
vm_factory: &'a Factory,
|
vm_factory: &'a Factory,
|
||||||
@ -64,16 +66,18 @@ impl<'a, T> TestExt<'a, T> where T: 'a + Tracer {
|
|||||||
substate: &'a mut Substate,
|
substate: &'a mut Substate,
|
||||||
output: OutputPolicy<'a, 'a>,
|
output: OutputPolicy<'a, 'a>,
|
||||||
address: Address,
|
address: Address,
|
||||||
tracer: &'a mut T) -> Self {
|
tracer: &'a mut T,
|
||||||
|
vm_tracer: &'a mut V,
|
||||||
|
) -> Self {
|
||||||
TestExt {
|
TestExt {
|
||||||
contract_address: contract_address(&address, &state.nonce(&address)),
|
contract_address: contract_address(&address, &state.nonce(&address)),
|
||||||
ext: Externalities::new(state, info, engine, vm_factory, depth, origin_info, substate, output, tracer),
|
ext: Externalities::new(state, info, engine, vm_factory, depth, origin_info, substate, output, tracer, vm_tracer),
|
||||||
callcreates: vec![]
|
callcreates: vec![]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T> Ext for TestExt<'a, T> where T: Tracer {
|
impl<'a, T, V> Ext for TestExt<'a, T, V> where T: Tracer, V: VMTracer {
|
||||||
fn storage_at(&self, key: &H256) -> H256 {
|
fn storage_at(&self, key: &H256) -> H256 {
|
||||||
self.ext.storage_at(key)
|
self.ext.storage_at(key)
|
||||||
}
|
}
|
||||||
@ -186,6 +190,7 @@ fn do_json_test_for(vm_type: &VMType, json_data: &[u8]) -> Vec<String> {
|
|||||||
|
|
||||||
let mut substate = Substate::new();
|
let mut substate = Substate::new();
|
||||||
let mut tracer = NoopTracer;
|
let mut tracer = NoopTracer;
|
||||||
|
let mut vm_tracer = NoopVMTracer;
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
|
|
||||||
// execute
|
// execute
|
||||||
@ -201,6 +206,7 @@ fn do_json_test_for(vm_type: &VMType, json_data: &[u8]) -> Vec<String> {
|
|||||||
OutputPolicy::Return(BytesRef::Flexible(&mut output), None),
|
OutputPolicy::Return(BytesRef::Flexible(&mut output), None),
|
||||||
params.address.clone(),
|
params.address.clone(),
|
||||||
&mut tracer,
|
&mut tracer,
|
||||||
|
&mut vm_tracer,
|
||||||
);
|
);
|
||||||
let evm = vm_factory.create();
|
let evm = vm_factory.create();
|
||||||
let res = evm.exec(params, &mut ex);
|
let res = evm.exec(params, &mut ex);
|
||||||
|
Loading…
Reference in New Issue
Block a user