From a0086428a2047b83718fa29a71f0b3fa1961d982 Mon Sep 17 00:00:00 2001 From: debris Date: Sat, 17 Feb 2018 22:25:18 +0100 Subject: [PATCH 1/2] removed redundant PodAccount::new method --- ethcore/src/pod_account.rs | 6 ---- ethcore/src/pod_state.rs | 56 ++++++++++++++++++++++++++++++++------ 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/ethcore/src/pod_account.rs b/ethcore/src/pod_account.rs index 7af9fbc0614..027e2765fff 100644 --- a/ethcore/src/pod_account.rs +++ b/ethcore/src/pod_account.rs @@ -43,12 +43,6 @@ pub struct PodAccount { } impl PodAccount { - /// Construct new object. - #[cfg(test)] - pub fn new(balance: U256, nonce: U256, code: Bytes, storage: BTreeMap) -> PodAccount { - PodAccount { balance: balance, nonce: nonce, code: Some(code), storage: storage } - } - /// Convert Account to a PodAccount. /// NOTE: This will silently fail unless the account is fully cached. pub fn from_account(acc: &Account) -> PodAccount { diff --git a/ethcore/src/pod_state.rs b/ethcore/src/pod_state.rs index f626c72d7ef..4225df27a1b 100644 --- a/ethcore/src/pod_state.rs +++ b/ethcore/src/pod_state.rs @@ -89,7 +89,12 @@ mod test { #[test] fn create_delete() { - let a = PodState::from(map![ 1.into() => PodAccount::new(69.into(), 0.into(), vec![], map![]) ]); + let a = PodState::from(map![ 1.into() => PodAccount { + balance: 69.into(), + nonce: 0.into(), + code: Some(Vec::new()), + storage: map![], + }]); assert_eq!(super::diff_pod(&a, &PodState::new()), StateDiff { raw: map![ 1.into() => AccountDiff{ balance: Diff::Died(69.into()), @@ -110,10 +115,25 @@ mod test { #[test] fn create_delete_with_unchanged() { - let a = PodState::from(map![ 1.into() => PodAccount::new(69.into(), 0.into(), vec![], map![]) ]); + let a = PodState::from(map![ 1.into() => PodAccount { + balance: 69.into(), + nonce: 0.into(), + code: Some(Vec::new()), + storage: map![], + }]); let b = PodState::from(map![ - 1.into() => PodAccount::new(69.into(), 0.into(), vec![], map![]), - 2.into() => PodAccount::new(69.into(), 0.into(), vec![], map![]) + 1.into() => PodAccount { + balance: 69.into(), + nonce: 0.into(), + code: Some(Vec::new()), + storage: map![], + }, + 2.into() => PodAccount { + balance: 69.into(), + nonce: 0.into(), + code: Some(Vec::new()), + storage: map![], + } ]); assert_eq!(super::diff_pod(&a, &b), StateDiff { raw: map![ 2.into() => AccountDiff{ @@ -136,12 +156,32 @@ mod test { #[test] fn change_with_unchanged() { let a = PodState::from(map![ - 1.into() => PodAccount::new(69.into(), 0.into(), vec![], map![]), - 2.into() => PodAccount::new(69.into(), 0.into(), vec![], map![]) + 1.into() => PodAccount { + balance: 69.into(), + nonce: 0.into(), + code: Some(Vec::new()), + storage: map![], + }, + 2.into() => PodAccount { + balance: 69.into(), + nonce: 0.into(), + code: Some(Vec::new()), + storage: map![], + } ]); let b = PodState::from(map![ - 1.into() => PodAccount::new(69.into(), 1.into(), vec![], map![]), - 2.into() => PodAccount::new(69.into(), 0.into(), vec![], map![]) + 1.into() => PodAccount { + balance: 69.into(), + nonce: 0.into(), + code: Some(Vec::new()), + storage: map![], + }, + 2.into() => PodAccount { + balance: 69.into(), + nonce: 0.into(), + code: Some(Vec::new()), + storage: map![], + } ]); assert_eq!(super::diff_pod(&a, &b), StateDiff { raw: map![ 1.into() => AccountDiff{ From c9547caba58bcf95fe848c4c2734eba52198968b Mon Sep 17 00:00:00 2001 From: debris Date: Sun, 18 Feb 2018 11:45:11 +0100 Subject: [PATCH 2/2] fixed failing test --- ethcore/src/pod_state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/src/pod_state.rs b/ethcore/src/pod_state.rs index 4225df27a1b..2bb7a35224f 100644 --- a/ethcore/src/pod_state.rs +++ b/ethcore/src/pod_state.rs @@ -172,7 +172,7 @@ mod test { let b = PodState::from(map![ 1.into() => PodAccount { balance: 69.into(), - nonce: 0.into(), + nonce: 1.into(), code: Some(Vec::new()), storage: map![], },