executive create

This commit is contained in:
debris
2016-01-14 17:40:38 +01:00
parent 05246c4f7d
commit d59e074d65
6 changed files with 66 additions and 69 deletions

View File

@@ -71,24 +71,24 @@ impl<'a> Ext for TestExt<'a> {
self.ext.blockhash(number)
}
fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> Result<(U256, Option<Address>), evm::Error> {
fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> (U256, Option<Address>) {
// in call and create we need to check if we exited with insufficient balance or max limit reached.
// in case of reaching max depth, we should store callcreates. Otherwise, ignore.
let res = self.ext.create(gas, value, code);
let ext = &self.ext;
match res {
// just record call create
Ok((gas_left, Some(address))) => {
(gas_left, Some(address)) => {
self.callcreates.push(CallCreate {
data: code.to_vec(),
destination: address.clone(),
_gas_limit: *gas,
value: *value
});
Ok((gas_left, Some(address)))
(gas_left, Some(address))
},
// creation failed only due to reaching max_depth
Ok((gas_left, None)) if ext.state.balance(&ext.params.address) >= *value => {
(gas_left, None) if ext.state.balance(&ext.params.address) >= *value => {
let address = contract_address(&ext.params.address, &ext.state.nonce(&ext.params.address));
self.callcreates.push(CallCreate {
data: code.to_vec(),
@@ -97,9 +97,10 @@ impl<'a> Ext for TestExt<'a> {
_gas_limit: *gas,
value: *value
});
Ok((gas_left, Some(address)))
(gas_left, Some(address))
},
other => other
// compiler is wrong...
_other => { unreachable!() }
}
}
@@ -156,6 +157,7 @@ fn do_json_test(json_data: &[u8]) -> Vec<String> {
let json = Json::from_str(::std::str::from_utf8(json_data).unwrap()).expect("Json is invalid");
let mut failed = Vec::new();
for (name, test) in json.as_object().unwrap() {
println!("name: {:?}", name);
// sync io is usefull when something crashes in jit
//::std::io::stdout().write(&name.as_bytes());
//::std::io::stdout().write(b"\n");

View File

@@ -10,6 +10,7 @@ fn do_json_test(json_data: &[u8]) -> Vec<String> {
let engine = ethereum::new_frontier_test().to_engine().unwrap();
for (name, test) in json.as_object().unwrap() {
println!("name: {:?}", name);
let mut fail = false;
let mut fail_unless = |cond: bool| if !cond && !fail { failed.push(name.to_string()); fail = true; true } else {false};