indent state tests

This commit is contained in:
Robert Habermeier 2016-11-14 17:47:56 +01:00
parent 5127b997eb
commit 25b0b8641e

View File

@ -783,22 +783,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();
@ -836,10 +836,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();
@ -855,10 +855,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();
@ -892,10 +892,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();
@ -935,10 +935,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();
@ -977,10 +977,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();
@ -1019,10 +1019,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();
@ -1062,10 +1062,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();
@ -1121,10 +1121,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();
@ -1183,10 +1183,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();
@ -1223,10 +1223,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();
@ -1283,10 +1283,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();
@ -1338,10 +1338,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();
@ -1381,10 +1381,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();
@ -1437,10 +1437,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();
@ -1512,10 +1512,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();
@ -1585,10 +1585,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();
@ -1638,10 +1638,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) = {
@ -1656,10 +1656,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) = {
@ -1671,10 +1671,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) = {
@ -1689,10 +1689,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();
@ -1706,10 +1706,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());
@ -1722,10 +1722,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());
@ -1738,10 +1738,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) = {
@ -1767,10 +1767,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();
@ -1789,10 +1789,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();
@ -1806,10 +1806,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();
@ -1818,20 +1818,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();
@ -1845,10 +1845,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();
@ -1860,18 +1860,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();
@ -1884,6 +1884,6 @@ fn should_not_panic_on_state_diff_with_storage() {
new_state.set_storage(&a, 0xb.into(), 0xd.into());
new_state.diff_from(state);
}
}
}