executive tests are working after the cleanup
This commit is contained in:
parent
4fc52a92ac
commit
c67822a03c
@ -220,18 +220,18 @@ impl<'a> evmjit::Ext for ExtAdapter<'a> {
|
|||||||
|
|
||||||
// check if balance is sufficient and we are not too deep
|
// check if balance is sufficient and we are not too deep
|
||||||
if self.ext.balance(&self.address) >= value && self.ext.depth() < self.ext.schedule().max_depth {
|
if self.ext.balance(&self.address) >= value && self.ext.depth() < self.ext.schedule().max_depth {
|
||||||
if let evm::ContractCreateResult::Created(new_address, gas_left) = self.ext.create(&gas, &value, code) {
|
match self.ext.create(&gas, &value, code) {
|
||||||
unsafe {
|
evm::ContractCreateResult::Created(new_address, gas_left) => unsafe {
|
||||||
*io_gas = gas_left.low_u64();
|
|
||||||
*address = new_address.into_jit();
|
*address = new_address.into_jit();
|
||||||
return;
|
*io_gas = gas_left.low_u64();
|
||||||
|
},
|
||||||
|
evm::ContractCreateResult::Failed => unsafe {
|
||||||
|
*address = Address::new().into_jit();
|
||||||
|
*io_gas = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
unsafe { *address = Address::new().into_jit(); }
|
||||||
unsafe {
|
|
||||||
*io_gas = 0;
|
|
||||||
*address = Address::new().into_jit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use common::*;
|
use common::*;
|
||||||
use evm;
|
use evm;
|
||||||
use evm::{Ext, Schedule, Factory};
|
use evm::{Ext, Schedule, Factory, ContractCreateResult, MessageCallResult};
|
||||||
|
|
||||||
struct FakeLogEntry {
|
struct FakeLogEntry {
|
||||||
topics: Vec<H256>,
|
topics: Vec<H256>,
|
||||||
@ -30,7 +30,7 @@ impl Ext for FakeExt {
|
|||||||
self.store.get(key).unwrap_or(&H256::new()).clone()
|
self.store.get(key).unwrap_or(&H256::new()).clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_storage_at(&mut self, key: H256, value: H256) {
|
fn set_storage(&mut self, key: H256, value: H256) {
|
||||||
self.store.insert(key, value);
|
self.store.insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,18 +46,17 @@ impl Ext for FakeExt {
|
|||||||
self.blockhashes.get(number).unwrap_or(&H256::new()).clone()
|
self.blockhashes.get(number).unwrap_or(&H256::new()).clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(&mut self, _gas: &U256, _value: &U256, _code: &[u8]) -> (U256, Option<Address>) {
|
fn create(&mut self, _gas: &U256, _value: &U256, _code: &[u8]) -> ContractCreateResult {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call(&mut self,
|
fn call(&mut self,
|
||||||
_gas: &U256,
|
_gas: &U256,
|
||||||
_call_gas: &U256,
|
_address: &Address,
|
||||||
_receive_address: &Address,
|
|
||||||
_value: &U256,
|
_value: &U256,
|
||||||
_data: &[u8],
|
_data: &[u8],
|
||||||
_code_address: &Address,
|
_code_address: &Address,
|
||||||
_output: &mut [u8]) -> result::Result<(U256, bool), evm::Error> {
|
_output: &mut [u8]) -> MessageCallResult {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +90,10 @@ impl Ext for FakeExt {
|
|||||||
fn depth(&self) -> usize {
|
fn depth(&self) -> usize {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_sstore_refund(&mut self) {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -4,7 +4,7 @@ use executive::*;
|
|||||||
use spec::*;
|
use spec::*;
|
||||||
use engine::*;
|
use engine::*;
|
||||||
use evm;
|
use evm;
|
||||||
use evm::{Schedule, Ext, Factory};
|
use evm::{Schedule, Ext, Factory, ContractCreateResult, MessageCallResult};
|
||||||
use ethereum;
|
use ethereum;
|
||||||
use externalities::*;
|
use externalities::*;
|
||||||
use substate::*;
|
use substate::*;
|
||||||
@ -61,8 +61,8 @@ impl<'a> Ext for TestExt<'a> {
|
|||||||
self.ext.storage_at(key)
|
self.ext.storage_at(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_storage_at(&mut self, key: H256, value: H256) {
|
fn set_storage(&mut self, key: H256, value: H256) {
|
||||||
self.ext.set_storage_at(key, value)
|
self.ext.set_storage(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exists(&self, address: &Address) -> bool {
|
fn exists(&self, address: &Address) -> bool {
|
||||||
@ -77,60 +77,31 @@ impl<'a> Ext for TestExt<'a> {
|
|||||||
self.ext.blockhash(number)
|
self.ext.blockhash(number)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> (U256, Option<Address>) {
|
fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> ContractCreateResult {
|
||||||
// in call and create we need to check if we exited with insufficient balance or max limit reached.
|
let address = contract_address(&self.ext.params.address, &self.ext.state.nonce(&self.ext.params.address));
|
||||||
// in case of reaching max depth, we should store callcreates. Otherwise, ignore.
|
self.callcreates.push(CallCreate {
|
||||||
let res = self.ext.create(gas, value, code);
|
data: code.to_vec(),
|
||||||
let ext = &self.ext;
|
destination: None,
|
||||||
match res {
|
_gas_limit: *gas,
|
||||||
// just record call create
|
value: *value
|
||||||
(gas_left, Some(address)) => {
|
});
|
||||||
self.callcreates.push(CallCreate {
|
ContractCreateResult::Created(address, *gas)
|
||||||
data: code.to_vec(),
|
|
||||||
destination: Some(address.clone()),
|
|
||||||
_gas_limit: *gas,
|
|
||||||
value: *value
|
|
||||||
});
|
|
||||||
(gas_left, Some(address))
|
|
||||||
},
|
|
||||||
// creation failed only due to reaching max_depth
|
|
||||||
(gas_left, None) if ext.state.balance(&ext.params.address) >= *value => {
|
|
||||||
self.callcreates.push(CallCreate {
|
|
||||||
data: code.to_vec(),
|
|
||||||
// callcreate test does not need an address
|
|
||||||
destination: None,
|
|
||||||
_gas_limit: *gas,
|
|
||||||
value: *value
|
|
||||||
});
|
|
||||||
let address = contract_address(&ext.params.address, &ext.state.nonce(&ext.params.address));
|
|
||||||
(gas_left, Some(address))
|
|
||||||
},
|
|
||||||
other => other
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call(&mut self,
|
fn call(&mut self,
|
||||||
gas: &U256,
|
gas: &U256,
|
||||||
call_gas: &U256,
|
|
||||||
receive_address: &Address,
|
receive_address: &Address,
|
||||||
value: &U256,
|
value: &U256,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
code_address: &Address,
|
code_address: &Address,
|
||||||
output: &mut [u8]) -> Result<(U256, bool), evm::Error> {
|
output: &mut [u8]) -> MessageCallResult {
|
||||||
let res = self.ext.call(gas, call_gas, receive_address, value, data, code_address, output);
|
self.callcreates.push(CallCreate {
|
||||||
let ext = &self.ext;
|
data: data.to_vec(),
|
||||||
if let &Ok((gas_left, _)) = &res {
|
destination: Some(receive_address.clone()),
|
||||||
if ext.state.balance(&ext.params.address) >= *value {
|
_gas_limit: *gas,
|
||||||
self.callcreates.push(CallCreate {
|
value: *value
|
||||||
data: data.to_vec(),
|
});
|
||||||
destination: Some(receive_address.clone()),
|
MessageCallResult::Success(*gas)
|
||||||
_gas_limit: *call_gas,
|
|
||||||
value: *value
|
|
||||||
});
|
|
||||||
return Ok((gas_left, true))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extcode(&self, address: &Address) -> Vec<u8> {
|
fn extcode(&self, address: &Address) -> Vec<u8> {
|
||||||
@ -158,7 +129,11 @@ impl<'a> Ext for TestExt<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn depth(&self) -> usize {
|
fn depth(&self) -> usize {
|
||||||
self.ext.depth()
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_sstore_refund(&mut self) {
|
||||||
|
self.ext.add_sstore_refund()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +175,7 @@ fn do_json_test(json_data: &[u8]) -> Vec<String> {
|
|||||||
info.timestamp = xjson!(&env["currentTimestamp"]);
|
info.timestamp = xjson!(&env["currentTimestamp"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
let engine = TestEngine::new(0);
|
let engine = TestEngine::new(1);
|
||||||
|
|
||||||
// params
|
// params
|
||||||
let mut params = ActionParams::new();
|
let mut params = ActionParams::new();
|
||||||
|
Loading…
Reference in New Issue
Block a user