[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:
Niklas Adolfsson
2020-02-19 13:07:33 +01:00
committed by GitHub
parent 70f08e1549
commit a49950e9c0
41 changed files with 296 additions and 434 deletions

View File

@@ -120,7 +120,7 @@ extern crate pretty_assertions;
#[cfg(test)]
#[macro_use]
extern crate macros;
extern crate maplit;
#[cfg(test)]
extern crate fake_fetch;

View File

@@ -113,16 +113,16 @@ impl SyncProvider for TestSyncProvider {
}
fn transactions_stats(&self) -> BTreeMap<H256, TransactionStats> {
map![
btreemap![
H256::from_low_u64_be(1) => TransactionStats {
first_seen: 10,
propagated_to: map![
propagated_to: btreemap![
H512::from_low_u64_be(128) => 16
],
},
H256::from_low_u64_be(5) => TransactionStats {
first_seen: 16,
propagated_to: map![
propagated_to: btreemap![
H512::from_low_u64_be(16) => 1
],
}

View File

@@ -206,10 +206,16 @@ impl<T: Serialize> Serialize for Rich<T> {
mod tests {
use std::collections::BTreeMap;
use ethereum_types::{H64, H160, H256, U256, Bloom as H2048};
use serde_json;
use v1::types::{Transaction, Bytes};
use super::{Block, RichBlock, BlockTransactions, Header, RichHeader};
fn default_extra_info() -> BTreeMap<String, String> {
btreemap![
"mixHash".into() => format!("{:?}", H256::default()),
"nonce".into() => format!("{:?}", H64::default())
]
}
#[test]
fn test_serialize_block_transactions() {
let t = BlockTransactions::Full(vec![Transaction::default()]);
@@ -248,10 +254,7 @@ mod tests {
let serialized_block = serde_json::to_string(&block).unwrap();
let rich_block = RichBlock {
inner: block,
extra_info: map![
"mixHash".into() => format!("{:?}", H256::zero()),
"nonce".into() => format!("{:?}", H64::default())
],
extra_info: default_extra_info(),
};
let serialized_rich_block = serde_json::to_string(&rich_block).unwrap();
@@ -286,10 +289,7 @@ mod tests {
let serialized_block = serde_json::to_string(&block).unwrap();
let rich_block = RichBlock {
inner: block,
extra_info: map![
"mixHash".into() => format!("{:?}", H256::zero()),
"nonce".into() => format!("{:?}", H64::default())
],
extra_info: default_extra_info(),
};
let serialized_rich_block = serde_json::to_string(&rich_block).unwrap();
@@ -321,10 +321,7 @@ mod tests {
let serialized_header = serde_json::to_string(&header).unwrap();
let rich_header = RichHeader {
inner: header,
extra_info: map![
"mixHash".into() => format!("{:?}", H256::zero()),
"nonce".into() => format!("{:?}", H64::default())
],
extra_info: default_extra_info(),
};
let serialized_rich_header = serde_json::to_string(&rich_header).unwrap();

View File

@@ -195,8 +195,6 @@ pub struct ChainStatus {
#[cfg(test)]
mod tests {
use serde_json;
use std::collections::BTreeMap;
use super::{SyncInfo, SyncStatus, Peers, TransactionStats, ChainStatus, H512};
#[test]
@@ -240,9 +238,7 @@ mod tests {
fn test_serialize_transaction_stats() {
let stats = TransactionStats {
first_seen: 100,
propagated_to: map![
H512::from_low_u64_be(10) => 50
],
propagated_to: btreemap![H512::from_low_u64_be(10) => 50],
};
let serialized = serde_json::to_string(&stats).unwrap();

View File

@@ -674,8 +674,6 @@ impl From<(H256, Executed)> for TraceResultsWithTransactionHash {
#[cfg(test)]
mod tests {
use serde_json;
use std::collections::BTreeMap;
use v1::types::Bytes;
use trace::TraceError;
use ethereum_types::Address;
@@ -875,12 +873,12 @@ mod tests {
#[test]
fn test_statediff_serialize() {
let t = StateDiff(map![
let t = StateDiff(btreemap![
Address::from_low_u64_be(42) => AccountDiff {
balance: Diff::Same,
nonce: Diff::Born(1.into()),
code: Diff::Same,
storage: map![
storage: btreemap![
H256::from_low_u64_be(42) => Diff::Same
]
},
@@ -888,7 +886,7 @@ mod tests {
balance: Diff::Same,
nonce: Diff::Changed(ChangedType { from: 1.into(), to: 0.into() }),
code: Diff::Died(vec![96].into()),
storage: map![],
storage: btreemap![],
}
]);
let serialized = serde_json::to_string(&t).unwrap();