[dependencies]: remove util/macros (#11501)
* [dependencies]: remove `util/macros` * fix typo: `flish` -> flush` * [json tests]: add log if `write` or `flush` fails `write` is performed to `stdout` `logging` is performed to `stderr` * [rocksdb-migration]: remove unused `Progress` * [rpc test]: BTreeMap -> `btreemap!`
This commit is contained in:
@@ -27,7 +27,6 @@ use triehash::sec_trie_root;
|
||||
use parity_bytes::Bytes;
|
||||
use trie_db::TrieFactory;
|
||||
use ethtrie::Layout;
|
||||
use ethjson;
|
||||
use common_types::account_diff::*;
|
||||
use rlp::{self, RlpStream};
|
||||
use serde::{Serializer, Serialize};
|
||||
@@ -146,55 +145,54 @@ pub fn diff_pod(pre: Option<&PodAccount>, post: Option<&PodAccount>) -> Option<A
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::collections::BTreeMap;
|
||||
use common_types::account_diff::*;
|
||||
use super::{PodAccount, diff_pod};
|
||||
use ethereum_types::H256;
|
||||
use macros::map;
|
||||
use maplit::btreemap;
|
||||
|
||||
#[test]
|
||||
fn existence() {
|
||||
let a = PodAccount {
|
||||
balance: 69.into(), nonce: 0.into(), code: Some(vec![]), storage: map![], version: 0.into(),
|
||||
balance: 69.into(), nonce: 0.into(), code: Some(vec![]), storage: btreemap![], version: 0.into(),
|
||||
};
|
||||
assert_eq!(diff_pod(Some(&a), Some(&a)), None);
|
||||
assert_eq!(diff_pod(None, Some(&a)), Some(AccountDiff{
|
||||
balance: Diff::Born(69.into()),
|
||||
nonce: Diff::Born(0.into()),
|
||||
code: Diff::Born(vec![]),
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn basic() {
|
||||
let a = PodAccount {
|
||||
balance: 69.into(), nonce: 0.into(), code: Some(vec![]), storage: map![], version: 0.into(),
|
||||
balance: 69.into(), nonce: 0.into(), code: Some(vec![]), storage: btreemap![], version: 0.into(),
|
||||
};
|
||||
let b = PodAccount {
|
||||
balance: 42.into(), nonce: 1.into(), code: Some(vec![]), storage: map![], version: 0.into(),
|
||||
balance: 42.into(), nonce: 1.into(), code: Some(vec![]), storage: btreemap![], version: 0.into(),
|
||||
};
|
||||
assert_eq!(diff_pod(Some(&a), Some(&b)), Some(AccountDiff {
|
||||
balance: Diff::Changed(69.into(), 42.into()),
|
||||
nonce: Diff::Changed(0.into(), 1.into()),
|
||||
code: Diff::Same,
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn code() {
|
||||
let a = PodAccount {
|
||||
balance: 0.into(), nonce: 0.into(), code: Some(vec![]), storage: map![], version: 0.into(),
|
||||
balance: 0.into(), nonce: 0.into(), code: Some(vec![]), storage: btreemap![], version: 0.into(),
|
||||
};
|
||||
let b = PodAccount {
|
||||
balance: 0.into(), nonce: 1.into(), code: Some(vec![0]), storage: map![], version: 0.into(),
|
||||
balance: 0.into(), nonce: 1.into(), code: Some(vec![0]), storage: btreemap![], version: 0.into(),
|
||||
};
|
||||
assert_eq!(diff_pod(Some(&a), Some(&b)), Some(AccountDiff {
|
||||
balance: Diff::Same,
|
||||
nonce: Diff::Changed(0.into(), 1.into()),
|
||||
code: Diff::Changed(vec![], vec![0]),
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -204,7 +202,7 @@ mod test {
|
||||
balance: 0.into(),
|
||||
nonce: 0.into(),
|
||||
code: Some(vec![]),
|
||||
storage: map![
|
||||
storage: btreemap![
|
||||
H256::from_low_u64_be(1) => H256::from_low_u64_be(1),
|
||||
H256::from_low_u64_be(2) => H256::from_low_u64_be(2),
|
||||
H256::from_low_u64_be(3) => H256::from_low_u64_be(3),
|
||||
@@ -219,7 +217,7 @@ mod test {
|
||||
balance: 0.into(),
|
||||
nonce: 0.into(),
|
||||
code: Some(vec![]),
|
||||
storage: map![
|
||||
storage: btreemap![
|
||||
H256::from_low_u64_be(1) => H256::from_low_u64_be(1),
|
||||
H256::from_low_u64_be(2) => H256::from_low_u64_be(3),
|
||||
H256::from_low_u64_be(3) => H256::from_low_u64_be(0),
|
||||
@@ -234,7 +232,7 @@ mod test {
|
||||
balance: Diff::Same,
|
||||
nonce: Diff::Same,
|
||||
code: Diff::Same,
|
||||
storage: map![
|
||||
storage: btreemap![
|
||||
H256::from_low_u64_be(2) => Diff::new(H256::from_low_u64_be(2), H256::from_low_u64_be(3)),
|
||||
H256::from_low_u64_be(3) => Diff::new(H256::from_low_u64_be(3), H256::from_low_u64_be(0)),
|
||||
H256::from_low_u64_be(4) => Diff::new(H256::from_low_u64_be(4), H256::from_low_u64_be(0)),
|
||||
|
||||
@@ -20,7 +20,6 @@ use std::collections::BTreeMap;
|
||||
use ethereum_types::{H256, Address};
|
||||
use triehash::sec_trie_root;
|
||||
use common_types::state_diff::StateDiff;
|
||||
use ethjson;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::account::PodAccount;
|
||||
@@ -74,7 +73,6 @@ pub fn diff_pod(pre: &PodState, post: &PodState) -> StateDiff {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::collections::BTreeMap;
|
||||
use common_types::{
|
||||
account_diff::{AccountDiff, Diff},
|
||||
state_diff::StateDiff,
|
||||
@@ -82,122 +80,122 @@ mod test {
|
||||
use ethereum_types::Address;
|
||||
use crate::account::PodAccount;
|
||||
use super::PodState;
|
||||
use macros::map;
|
||||
use maplit::btreemap;
|
||||
|
||||
#[test]
|
||||
fn create_delete() {
|
||||
let a = PodState::from(map![
|
||||
let a = PodState::from(btreemap![
|
||||
Address::from_low_u64_be(1) => PodAccount {
|
||||
balance: 69.into(),
|
||||
nonce: 0.into(),
|
||||
code: Some(Vec::new()),
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
version: 0.into(),
|
||||
}
|
||||
]);
|
||||
assert_eq!(super::diff_pod(&a, &PodState::default()), StateDiff { raw: map![
|
||||
assert_eq!(super::diff_pod(&a, &PodState::default()), StateDiff { raw: btreemap![
|
||||
Address::from_low_u64_be(1) => AccountDiff{
|
||||
balance: Diff::Died(69.into()),
|
||||
nonce: Diff::Died(0.into()),
|
||||
code: Diff::Died(vec![]),
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
}
|
||||
]});
|
||||
assert_eq!(super::diff_pod(&PodState::default(), &a), StateDiff { raw: map![
|
||||
assert_eq!(super::diff_pod(&PodState::default(), &a), StateDiff { raw: btreemap![
|
||||
Address::from_low_u64_be(1) => AccountDiff{
|
||||
balance: Diff::Born(69.into()),
|
||||
nonce: Diff::Born(0.into()),
|
||||
code: Diff::Born(vec![]),
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
}
|
||||
]});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_delete_with_unchanged() {
|
||||
let a = PodState::from(map![
|
||||
let a = PodState::from(btreemap![
|
||||
Address::from_low_u64_be(1) => PodAccount {
|
||||
balance: 69.into(),
|
||||
nonce: 0.into(),
|
||||
code: Some(Vec::new()),
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
version: 0.into(),
|
||||
}
|
||||
]);
|
||||
let b = PodState::from(map![
|
||||
let b = PodState::from(btreemap![
|
||||
Address::from_low_u64_be(1) => PodAccount {
|
||||
balance: 69.into(),
|
||||
nonce: 0.into(),
|
||||
code: Some(Vec::new()),
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
version: 0.into(),
|
||||
},
|
||||
Address::from_low_u64_be(2) => PodAccount {
|
||||
balance: 69.into(),
|
||||
nonce: 0.into(),
|
||||
code: Some(Vec::new()),
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
version: 0.into(),
|
||||
}
|
||||
]);
|
||||
assert_eq!(super::diff_pod(&a, &b), StateDiff { raw: map![
|
||||
assert_eq!(super::diff_pod(&a, &b), StateDiff { raw: btreemap![
|
||||
Address::from_low_u64_be(2) => AccountDiff {
|
||||
balance: Diff::Born(69.into()),
|
||||
nonce: Diff::Born(0.into()),
|
||||
code: Diff::Born(vec![]),
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
}
|
||||
]});
|
||||
assert_eq!(super::diff_pod(&b, &a), StateDiff { raw: map![
|
||||
assert_eq!(super::diff_pod(&b, &a), StateDiff { raw: btreemap![
|
||||
Address::from_low_u64_be(2) => AccountDiff {
|
||||
balance: Diff::Died(69.into()),
|
||||
nonce: Diff::Died(0.into()),
|
||||
code: Diff::Died(vec![]),
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
}
|
||||
]});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn change_with_unchanged() {
|
||||
let a = PodState::from(map![
|
||||
let a = PodState::from(btreemap![
|
||||
Address::from_low_u64_be(1) => PodAccount {
|
||||
balance: 69.into(),
|
||||
nonce: 0.into(),
|
||||
code: Some(Vec::new()),
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
version: 0.into(),
|
||||
},
|
||||
Address::from_low_u64_be(2) => PodAccount {
|
||||
balance: 69.into(),
|
||||
nonce: 0.into(),
|
||||
code: Some(Vec::new()),
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
version: 0.into(),
|
||||
}
|
||||
]);
|
||||
let b = PodState::from(map![
|
||||
let b = PodState::from(btreemap![
|
||||
Address::from_low_u64_be(1) => PodAccount {
|
||||
balance: 69.into(),
|
||||
nonce: 1.into(),
|
||||
code: Some(Vec::new()),
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
version: 0.into(),
|
||||
},
|
||||
Address::from_low_u64_be(2) => PodAccount {
|
||||
balance: 69.into(),
|
||||
nonce: 0.into(),
|
||||
code: Some(Vec::new()),
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
version: 0.into(),
|
||||
}
|
||||
]);
|
||||
assert_eq!(super::diff_pod(&a, &b), StateDiff { raw: map![
|
||||
assert_eq!(super::diff_pod(&a, &b), StateDiff { raw: btreemap![
|
||||
Address::from_low_u64_be(1) => AccountDiff {
|
||||
balance: Diff::Same,
|
||||
nonce: Diff::Changed(0.into(), 1.into()),
|
||||
code: Diff::Same,
|
||||
storage: map![],
|
||||
storage: btreemap![],
|
||||
}
|
||||
]});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user