diff --git a/src/account.rs b/src/account.rs
index 095380116..cbae80a61 100644
--- a/src/account.rs
+++ b/src/account.rs
@@ -54,13 +54,34 @@ impl AccountDiff {
}
}
-/*impl Debug for AccountDiff {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{:?}", PodAccount::from_account(self))
- }
-}*/
+#[derive(Debug,Clone,PartialEq,Eq)]
+pub struct StateDiff (BTreeMap
);
-pub type StateDiff = BTreeMap;
+impl fmt::Display for AccountDiff {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "...\n")
+ }
+}
+
+impl fmt::Display for Existance {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ match self {
+ &Existance::Born => try!(write!(f, "+++")),
+ &Existance::Alive => try!(write!(f, "***")),
+ &Existance::Died => try!(write!(f, "---")),
+ }
+ Ok(())
+ }
+}
+
+impl fmt::Display for StateDiff {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ for (add, acc) in self.0.iter() {
+ try!(write!(f, "{} {}: {}", acc.existance(), add, acc));
+ }
+ Ok(())
+ }
+}
pub fn pod_diff(pre: Option<&PodAccount>, post: Option<&PodAccount>) -> Option {
match (pre, post) {
@@ -101,7 +122,7 @@ pub fn pod_diff(pre: Option<&PodAccount>, post: Option<&PodAccount>) -> Option, post: &BTreeMap) -> StateDiff {
- pre.keys().merge(post.keys()).filter_map(|acc| pod_diff(pre.get(acc), post.get(acc)).map(|d|(acc.clone(), d))).collect()
+ StateDiff(pre.keys().merge(post.keys()).filter_map(|acc| pod_diff(pre.get(acc), post.get(acc)).map(|d|(acc.clone(), d))).collect())
}
#[test]
@@ -114,22 +135,22 @@ fn state_diff_create_delete() {
storage: map![]
}
];
- assert_eq!(pod_map_diff(&a, &map![]), map![
+ assert_eq!(pod_map_diff(&a, &map![]), StateDiff(map![
x!(1) => AccountDiff{
balance: Diff::Died(x!(69)),
nonce: Diff::Died(x!(0)),
code: Diff::Died(vec![]),
storage: map![],
}
- ]);
- assert_eq!(pod_map_diff(&map![], &a), map![
+ ]));
+ assert_eq!(pod_map_diff(&map![], &a), StateDiff(map![
x!(1) => AccountDiff{
balance: Diff::Born(x!(69)),
nonce: Diff::Born(x!(0)),
code: Diff::Born(vec![]),
storage: map![],
}
- ]);
+ ]));
}
#[test]
@@ -156,22 +177,22 @@ fn state_diff_cretae_delete_with_unchanged() {
storage: map![]
}
];
- assert_eq!(pod_map_diff(&a, &b), map![
+ assert_eq!(pod_map_diff(&a, &b), StateDiff(map![
x!(2) => AccountDiff{
balance: Diff::Born(x!(69)),
nonce: Diff::Born(x!(0)),
code: Diff::Born(vec![]),
storage: map![],
}
- ]);
- assert_eq!(pod_map_diff(&b, &a), map![
+ ]));
+ assert_eq!(pod_map_diff(&b, &a), StateDiff(map![
x!(2) => AccountDiff{
balance: Diff::Died(x!(69)),
nonce: Diff::Died(x!(0)),
code: Diff::Died(vec![]),
storage: map![],
}
- ]);
+ ]));
}
#[test]
@@ -204,14 +225,14 @@ fn state_diff_change_with_unchanged() {
storage: map![]
}
];
- assert_eq!(pod_map_diff(&a, &b), map![
+ assert_eq!(pod_map_diff(&a, &b), StateDiff(map![
x!(1) => AccountDiff{
balance: Diff::Same,
nonce: Diff::Changed(x!(0), x!(1)),
code: Diff::Same,
storage: map![],
}
- ]);
+ ]));
}
#[test]
diff --git a/src/evm/schedule.rs b/src/evm/schedule.rs
index d02fedc91..a8807735e 100644
--- a/src/evm/schedule.rs
+++ b/src/evm/schedule.rs
@@ -50,7 +50,7 @@ impl Schedule {
exceptional_failed_code_deposit: efcd,
have_delegate_call: hdc,
stack_limit: 1024,
- tier_step_gas: [0usize, 2, 3, 4, 5, 8, 10, 20],
+ tier_step_gas: [0, 2, 3, 5, 8, 10, 20, 0],
exp_gas: 10,
exp_byte_gas: 10,
sha3_gas: 30,
diff --git a/src/tests/state.rs b/src/tests/state.rs
index 6ae01a334..23d894936 100644
--- a/src/tests/state.rs
+++ b/src/tests/state.rs
@@ -56,7 +56,7 @@ fn do_json_test(json_data: &[u8]) -> Vec {
let our_post = s.to_pod_map();
if fail_unless(s.root() == &post_state_root) {
- println!("DIFF:\n{:?}", pod_map_diff(&post, &our_post));
+ println!("DIFF:\n{}", pod_map_diff(&post, &our_post));
}
// TODO: Compare logs.