Merge pull request #3431 from ethcore/state-tests-indentation
indent state tests
This commit is contained in:
commit
3837114eb2
@ -790,22 +790,22 @@ impl Clone for State {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::str::FromStr;
|
||||
use rustc_serialize::hex::FromHex;
|
||||
use super::*;
|
||||
use util::{U256, H256, FixedHash, Address, Hashable};
|
||||
use tests::helpers::*;
|
||||
use devtools::*;
|
||||
use env_info::EnvInfo;
|
||||
use spec::*;
|
||||
use transaction::*;
|
||||
use util::log::init_log;
|
||||
use trace::{FlatTrace, TraceError, trace};
|
||||
use types::executed::CallType;
|
||||
use std::sync::Arc;
|
||||
use std::str::FromStr;
|
||||
use rustc_serialize::hex::FromHex;
|
||||
use super::*;
|
||||
use util::{U256, H256, FixedHash, Address, Hashable};
|
||||
use tests::helpers::*;
|
||||
use devtools::*;
|
||||
use env_info::EnvInfo;
|
||||
use spec::*;
|
||||
use transaction::*;
|
||||
use util::log::init_log;
|
||||
use trace::{FlatTrace, TraceError, trace};
|
||||
use types::executed::CallType;
|
||||
|
||||
#[test]
|
||||
fn should_apply_create_transaction() {
|
||||
#[test]
|
||||
fn should_apply_create_transaction() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -843,10 +843,10 @@ fn should_apply_create_transaction() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_work_when_cloned() {
|
||||
#[test]
|
||||
fn should_work_when_cloned() {
|
||||
init_log();
|
||||
|
||||
let a = Address::zero();
|
||||
@ -862,10 +862,10 @@ fn should_work_when_cloned() {
|
||||
|
||||
state.inc_nonce(&a);
|
||||
state.commit().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_trace_failed_create_transaction() {
|
||||
#[test]
|
||||
fn should_trace_failed_create_transaction() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -899,10 +899,10 @@ fn should_trace_failed_create_transaction() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_trace_call_transaction() {
|
||||
#[test]
|
||||
fn should_trace_call_transaction() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -942,10 +942,10 @@ fn should_trace_call_transaction() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_trace_basic_call_transaction() {
|
||||
#[test]
|
||||
fn should_trace_basic_call_transaction() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -984,10 +984,10 @@ fn should_trace_basic_call_transaction() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_trace_call_transaction_to_builtin() {
|
||||
#[test]
|
||||
fn should_trace_call_transaction_to_builtin() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -1026,10 +1026,10 @@ fn should_trace_call_transaction_to_builtin() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_not_trace_subcall_transaction_to_builtin() {
|
||||
#[test]
|
||||
fn should_not_trace_subcall_transaction_to_builtin() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -1069,10 +1069,10 @@ fn should_not_trace_subcall_transaction_to_builtin() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_not_trace_callcode() {
|
||||
#[test]
|
||||
fn should_not_trace_callcode() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -1128,10 +1128,10 @@ fn should_not_trace_callcode() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_not_trace_delegatecall() {
|
||||
#[test]
|
||||
fn should_not_trace_delegatecall() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -1190,10 +1190,10 @@ fn should_not_trace_delegatecall() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_trace_failed_call_transaction() {
|
||||
#[test]
|
||||
fn should_trace_failed_call_transaction() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -1230,10 +1230,10 @@ fn should_trace_failed_call_transaction() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_trace_call_with_subcall_transaction() {
|
||||
#[test]
|
||||
fn should_trace_call_with_subcall_transaction() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -1290,10 +1290,10 @@ fn should_trace_call_with_subcall_transaction() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_trace_call_with_basic_subcall_transaction() {
|
||||
#[test]
|
||||
fn should_trace_call_with_basic_subcall_transaction() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -1345,10 +1345,10 @@ fn should_trace_call_with_basic_subcall_transaction() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_not_trace_call_with_invalid_basic_subcall_transaction() {
|
||||
#[test]
|
||||
fn should_not_trace_call_with_invalid_basic_subcall_transaction() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -1388,10 +1388,10 @@ fn should_not_trace_call_with_invalid_basic_subcall_transaction() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_trace_failed_subcall_transaction() {
|
||||
#[test]
|
||||
fn should_trace_failed_subcall_transaction() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -1444,10 +1444,10 @@ fn should_trace_failed_subcall_transaction() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_trace_call_with_subcall_with_subcall_transaction() {
|
||||
#[test]
|
||||
fn should_trace_call_with_subcall_with_subcall_transaction() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -1519,10 +1519,10 @@ fn should_trace_call_with_subcall_with_subcall_transaction() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_trace_failed_subcall_with_subcall_transaction() {
|
||||
#[test]
|
||||
fn should_trace_failed_subcall_with_subcall_transaction() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -1592,10 +1592,10 @@ fn should_trace_failed_subcall_with_subcall_transaction() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_trace_suicide() {
|
||||
#[test]
|
||||
fn should_trace_suicide() {
|
||||
init_log();
|
||||
|
||||
let temp = RandomTempPath::new();
|
||||
@ -1645,10 +1645,10 @@ fn should_trace_suicide() {
|
||||
}];
|
||||
|
||||
assert_eq!(result.trace, expected_trace);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn code_from_database() {
|
||||
#[test]
|
||||
fn code_from_database() {
|
||||
let a = Address::zero();
|
||||
let temp = RandomTempPath::new();
|
||||
let (root, db) = {
|
||||
@ -1663,10 +1663,10 @@ fn code_from_database() {
|
||||
|
||||
let state = State::from_existing(db, root, U256::from(0u8), Default::default()).unwrap();
|
||||
assert_eq!(state.code(&a), Some(Arc::new([1u8, 2, 3].to_vec())));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn storage_at_from_database() {
|
||||
#[test]
|
||||
fn storage_at_from_database() {
|
||||
let a = Address::zero();
|
||||
let temp = RandomTempPath::new();
|
||||
let (root, db) = {
|
||||
@ -1678,10 +1678,10 @@ fn storage_at_from_database() {
|
||||
|
||||
let s = State::from_existing(db, root, U256::from(0u8), Default::default()).unwrap();
|
||||
assert_eq!(s.storage_at(&a, &H256::from(&U256::from(1u64))), H256::from(&U256::from(69u64)));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_from_database() {
|
||||
#[test]
|
||||
fn get_from_database() {
|
||||
let a = Address::zero();
|
||||
let temp = RandomTempPath::new();
|
||||
let (root, db) = {
|
||||
@ -1696,10 +1696,10 @@ fn get_from_database() {
|
||||
let state = State::from_existing(db, root, U256::from(0u8), Default::default()).unwrap();
|
||||
assert_eq!(state.balance(&a), U256::from(69u64));
|
||||
assert_eq!(state.nonce(&a), U256::from(1u64));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove() {
|
||||
#[test]
|
||||
fn remove() {
|
||||
let a = Address::zero();
|
||||
let mut state_result = get_temp_state();
|
||||
let mut state = state_result.reference_mut();
|
||||
@ -1713,10 +1713,10 @@ fn remove() {
|
||||
assert_eq!(state.exists(&a), false);
|
||||
assert_eq!(state.exists_and_not_null(&a), false);
|
||||
assert_eq!(state.nonce(&a), U256::from(0u64));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_account_is_not_created() {
|
||||
#[test]
|
||||
fn empty_account_is_not_created() {
|
||||
let a = Address::zero();
|
||||
let path = RandomTempPath::new();
|
||||
let db = get_temp_state_db_in(path.as_path());
|
||||
@ -1729,10 +1729,10 @@ fn empty_account_is_not_created() {
|
||||
let state = State::from_existing(db, root, U256::from(0u8), Default::default()).unwrap();
|
||||
assert!(!state.exists(&a));
|
||||
assert!(!state.exists_and_not_null(&a));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_account_exists_when_creation_forced() {
|
||||
#[test]
|
||||
fn empty_account_exists_when_creation_forced() {
|
||||
let a = Address::zero();
|
||||
let path = RandomTempPath::new();
|
||||
let db = get_temp_state_db_in(path.as_path());
|
||||
@ -1745,10 +1745,10 @@ fn empty_account_exists_when_creation_forced() {
|
||||
let state = State::from_existing(db, root, U256::from(0u8), Default::default()).unwrap();
|
||||
assert!(state.exists(&a));
|
||||
assert!(!state.exists_and_not_null(&a));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_from_database() {
|
||||
#[test]
|
||||
fn remove_from_database() {
|
||||
let a = Address::zero();
|
||||
let temp = RandomTempPath::new();
|
||||
let (root, db) = {
|
||||
@ -1774,10 +1774,10 @@ fn remove_from_database() {
|
||||
let state = State::from_existing(db, root, U256::from(0u8), Default::default()).unwrap();
|
||||
assert_eq!(state.exists(&a), false);
|
||||
assert_eq!(state.nonce(&a), U256::from(0u64));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn alter_balance() {
|
||||
#[test]
|
||||
fn alter_balance() {
|
||||
let mut state_result = get_temp_state();
|
||||
let mut state = state_result.reference_mut();
|
||||
let a = Address::zero();
|
||||
@ -1796,10 +1796,10 @@ fn alter_balance() {
|
||||
state.commit().unwrap();
|
||||
assert_eq!(state.balance(&a), U256::from(9u64));
|
||||
assert_eq!(state.balance(&b), U256::from(18u64));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn alter_nonce() {
|
||||
#[test]
|
||||
fn alter_nonce() {
|
||||
let mut state_result = get_temp_state();
|
||||
let mut state = state_result.reference_mut();
|
||||
let a = Address::zero();
|
||||
@ -1813,10 +1813,10 @@ fn alter_nonce() {
|
||||
assert_eq!(state.nonce(&a), U256::from(3u64));
|
||||
state.commit().unwrap();
|
||||
assert_eq!(state.nonce(&a), U256::from(3u64));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn balance_nonce() {
|
||||
#[test]
|
||||
fn balance_nonce() {
|
||||
let mut state_result = get_temp_state();
|
||||
let mut state = state_result.reference_mut();
|
||||
let a = Address::zero();
|
||||
@ -1825,20 +1825,20 @@ fn balance_nonce() {
|
||||
state.commit().unwrap();
|
||||
assert_eq!(state.balance(&a), U256::from(0u64));
|
||||
assert_eq!(state.nonce(&a), U256::from(0u64));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ensure_cached() {
|
||||
#[test]
|
||||
fn ensure_cached() {
|
||||
let mut state_result = get_temp_state();
|
||||
let mut state = state_result.reference_mut();
|
||||
let a = Address::zero();
|
||||
state.require(&a, false);
|
||||
state.commit().unwrap();
|
||||
assert_eq!(state.root().hex(), "0ce23f3c809de377b008a4a3ee94a0834aac8bec1f86e28ffe4fdb5a15b0c785");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checkpoint_basic() {
|
||||
#[test]
|
||||
fn checkpoint_basic() {
|
||||
let mut state_result = get_temp_state();
|
||||
let mut state = state_result.reference_mut();
|
||||
let a = Address::zero();
|
||||
@ -1852,10 +1852,10 @@ fn checkpoint_basic() {
|
||||
assert_eq!(state.balance(&a), U256::from(70u64));
|
||||
state.revert_to_checkpoint();
|
||||
assert_eq!(state.balance(&a), U256::from(69u64));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checkpoint_nested() {
|
||||
#[test]
|
||||
fn checkpoint_nested() {
|
||||
let mut state_result = get_temp_state();
|
||||
let mut state = state_result.reference_mut();
|
||||
let a = Address::zero();
|
||||
@ -1867,18 +1867,18 @@ fn checkpoint_nested() {
|
||||
assert_eq!(state.balance(&a), U256::from(69u64));
|
||||
state.revert_to_checkpoint();
|
||||
assert_eq!(state.balance(&a), U256::from(0));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_empty() {
|
||||
#[test]
|
||||
fn create_empty() {
|
||||
let mut state_result = get_temp_state();
|
||||
let mut state = state_result.reference_mut();
|
||||
state.commit().unwrap();
|
||||
assert_eq!(state.root().hex(), "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_not_panic_on_state_diff_with_storage() {
|
||||
#[test]
|
||||
fn should_not_panic_on_state_diff_with_storage() {
|
||||
let state = get_temp_state();
|
||||
let mut state = state.reference().clone();
|
||||
|
||||
@ -1891,6 +1891,6 @@ fn should_not_panic_on_state_diff_with_storage() {
|
||||
new_state.set_storage(&a, 0xb.into(), 0xd.into());
|
||||
|
||||
new_state.diff_from(state);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user