common changes, added json state tests
This commit is contained in:
parent
98ae8ce36a
commit
4ca353b021
@ -513,6 +513,10 @@ impl Account {
|
||||
pub fn set_storage(&mut self, key: H256, value: H256) {
|
||||
self.storage_overlay.borrow_mut().insert(key, (Filth::Dirty, value));
|
||||
}
|
||||
|
||||
pub fn reset_storage(&mut self, key: &H256) {
|
||||
self.storage_overlay.borrow_mut().remove(key);
|
||||
}
|
||||
|
||||
/// Get (and cache) the contents of the trie's storage at `key`.
|
||||
pub fn storage_at(&self, db: &HashDB, key: &H256) -> H256 {
|
||||
@ -741,4 +745,4 @@ fn create_account() {
|
||||
assert_eq!(a.rlp().to_hex(), "f8448045a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ impl EnvInfo {
|
||||
|
||||
pub fn from_json(json: &Json) -> EnvInfo {
|
||||
let current_number = u64_from_json(&json["currentNumber"]);
|
||||
EnvInfo {
|
||||
let e = EnvInfo {
|
||||
number: current_number,
|
||||
author: address_from_json(&json["currentCoinbase"]),
|
||||
difficulty: u256_from_json(&json["currentDifficulty"]),
|
||||
@ -47,7 +47,9 @@ impl EnvInfo {
|
||||
timestamp: u64_from_json(&json["currentTimestamp"]),
|
||||
last_hashes: (0..current_number).map(|i| format!("{}", current_number - i).as_bytes().sha3()).collect(),
|
||||
gas_used: x!(0),
|
||||
}
|
||||
};
|
||||
println!("hashes: {:?}", e.last_hashes);
|
||||
e
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,6 @@ impl evm::Evm for JitEvm {
|
||||
|
||||
let mut context = unsafe { evmjit::ContextHandle::new(data.into_jit(), &mut ext_handle) };
|
||||
let res = context.exec();
|
||||
println!("jit res: {:?}", res);
|
||||
|
||||
// check in adapter if execution of children contracts failed.
|
||||
if let Some(err) = optional_err {
|
||||
|
@ -278,7 +278,17 @@ impl<'a> Executive<'a> {
|
||||
contracts_created: substate.contracts_created
|
||||
})
|
||||
},
|
||||
_err => { unreachable!() }
|
||||
_err => {
|
||||
Ok(Executed {
|
||||
gas: t.gas,
|
||||
gas_used: t.gas,
|
||||
refunded: U256::zero(),
|
||||
cumulative_gas_used: self.info.gas_used + t.gas,
|
||||
logs: vec![],
|
||||
out_of_gas: true,
|
||||
contracts_created: vec![]
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,10 @@ impl State {
|
||||
|
||||
/// Mutate storage of account `a` so that it is `value` for `key`.
|
||||
pub fn set_storage(&mut self, a: &Address, key: H256, value: H256) {
|
||||
self.require(a, false).set_storage(key, value);
|
||||
match value == H256::new() {
|
||||
true => self.require(a, false).reset_storage(&key),
|
||||
false => self.require(a, false).set_storage(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialise the code of account `a` so that it is `value` for `key`.
|
||||
@ -138,7 +141,7 @@ impl State {
|
||||
/// This will change the state accordingly.
|
||||
pub fn apply(&mut self, env_info: &EnvInfo, engine: &Engine, t: &Transaction) -> ApplyResult {
|
||||
let e = try!(Executive::new(self, env_info, engine).transact(t));
|
||||
println!("Executed: {:?}", e);
|
||||
//println!("Executed: {:?}", e);
|
||||
self.commit();
|
||||
Ok(Receipt::new(self.root().clone(), e.gas_used, e.logs))
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ fn do_json_test(json_data: &[u8]) -> Vec<String> {
|
||||
if fail_unless(&r.state_root == &post_state_root) {
|
||||
println!("!!! {}: State mismatch (got: {}, expect: {}):", name, r.state_root, post_state_root);
|
||||
let our_post = s.to_pod();
|
||||
println!("Got:\n{}", our_post);
|
||||
println!("Expect:\n{}", post);
|
||||
println!("Got:\n{:?}", our_post);
|
||||
println!("Expect:\n{:?}", post);
|
||||
println!("Diff ---expect -> +++got:\n{}", pod_state_diff(&post, &our_post));
|
||||
}
|
||||
|
||||
@ -58,4 +58,7 @@ fn do_json_test(json_data: &[u8]) -> Vec<String> {
|
||||
}
|
||||
|
||||
declare_test!{StateTests_stExample, "StateTests/stExample"}
|
||||
declare_test!{StateTests_stBlockHashTest, "StateTests/stBlockHashTest"}
|
||||
declare_test!{StateTests_stLogTests, "StateTests/stLogTests"}
|
||||
declare_test!{StateTests_stCallCodes, "StateTests/stCallCodes"}
|
||||
declare_test_ignore!{StateTests_stCallCreateCallCodeTest, "StateTests/stCallCreateCallCodeTest"}
|
||||
|
Loading…
Reference in New Issue
Block a user