Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address clippy warnings #55

Merged
merged 2 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tendermint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
html_root_url = "https://docs.rs/tendermint/0.10.0"
)]

// NOTE(EB): can't figure out how to easily remove the extern crate per Rust2018 upgrade ...
#[allow(unused_extern_crates)]
extern crate prost_amino as prost;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the easiest way to actually fix this is through the Cargo.toml:

prost = { package = "prost-amino", version = "0.4.0" }
prost-derive = { package = "prost-amino-derive", version = "0.4.0" }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to get this working. When I try it and then comment out these extern crate lines, I get tons of errors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ebuchman oh, I bet it hasn't been updated to the 2018 edition, so prost-amino-derive is still dependent on the extern crate directives.

Probably the best solution would be to switch to upstream prost when Amino has been fully replaced with protos.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol cannot wait!


// NOTE(EB): can't figure out how to easily remove the extern crate per Rust2018 upgrade ...
#[allow(unused_extern_crates)]
#[macro_use]
extern crate prost_amino_derive as prost_derive;

Expand Down
7 changes: 4 additions & 3 deletions tendermint/tests/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod files {
}

/// Parse an example `config.toml` file to a `TendermintConfig` struct
#[allow(clippy::cognitive_complexity)]
#[test]
fn config_toml_parser() {
let config_toml = read_fixture("config.toml");
Expand Down Expand Up @@ -118,8 +119,8 @@ mod files {
assert_eq!(p2p.max_num_outbound_peers, 10);
assert_eq!(*p2p.flush_throttle_timeout, Duration::from_millis(100));
assert_eq!(p2p.max_packet_msg_payload_size, 1024);
assert_eq!(p2p.send_rate.bytes_per_sec(), 5120000);
assert_eq!(p2p.recv_rate.bytes_per_sec(), 5120000);
assert_eq!(p2p.send_rate.bytes_per_sec(), 5_120_000);
assert_eq!(p2p.recv_rate.bytes_per_sec(), 5_120_000);
assert!(p2p.pex);
assert!(!p2p.seed_mode);
assert_eq!(p2p.private_peer_ids.len(), 3);
Expand Down Expand Up @@ -152,7 +153,7 @@ mod files {
assert!(mempool.broadcast);
assert_eq!(mempool.wal_dir, None);
assert_eq!(mempool.size, 5000);
assert_eq!(mempool.max_txs_bytes, 1073741824);
assert_eq!(mempool.max_txs_bytes, 1_073_741_824);
assert_eq!(mempool.cache_size, 10000);

// consensus configuration options
Expand Down
16 changes: 8 additions & 8 deletions tendermint/tests/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod endpoints {
.response;

assert_eq!(response.data.as_str(), EXAMPLE_APP);
assert_eq!(response.last_block_height.value(), 488120);
assert_eq!(response.last_block_height.value(), 488_120);
}

#[test]
Expand Down Expand Up @@ -62,8 +62,8 @@ mod endpoints {

let tendermint::abci::Responses {
deliver_tx,
begin_block: _,
end_block,
..
} = response.results;

let log_json = &deliver_tx[0].log.as_ref().unwrap().parse_json().unwrap();
Expand All @@ -72,8 +72,8 @@ mod endpoints {
assert_eq!(log_json_value["msg_index"].as_str().unwrap(), "0");
assert_eq!(log_json_value["success"].as_bool().unwrap(), true);

assert_eq!(deliver_tx[0].gas_wanted.value(), 200000);
assert_eq!(deliver_tx[0].gas_used.value(), 105662);
assert_eq!(deliver_tx[0].gas_wanted.value(), 200_000);
assert_eq!(deliver_tx[0].gas_used.value(), 105_662);

let tag = deliver_tx[0]
.tags
Expand All @@ -87,15 +87,15 @@ mod endpoints {
);

let validator_update = &end_block.as_ref().unwrap().validator_updates[0];
assert_eq!(validator_update.power.value(), 1233243);
assert_eq!(validator_update.power.value(), 1_233_243);
}

#[test]
fn blockchain() {
let response =
endpoint::blockchain::Response::from_json(&read_json_fixture("blockchain")).unwrap();

assert_eq!(response.last_height.value(), 488556);
assert_eq!(response.last_height.value(), 488_556);
assert_eq!(response.block_metas.len(), 10);

let block_meta = &response.block_metas[0];
Expand Down Expand Up @@ -183,7 +183,7 @@ mod endpoints {
} = response.genesis;

assert_eq!(chain_id.as_str(), EXAMPLE_CHAIN);
assert_eq!(consensus_params.block.max_bytes, 200000);
assert_eq!(consensus_params.block.max_bytes, 200_000);
}

#[test]
Expand All @@ -205,7 +205,7 @@ mod endpoints {
let response = endpoint::status::Response::from_json(&read_json_fixture("status")).unwrap();

assert_eq!(response.node_info.network.as_str(), EXAMPLE_CHAIN);
assert_eq!(response.sync_info.latest_block_height.value(), 410744);
assert_eq!(response.sync_info.latest_block_height.value(), 410_744);
assert_eq!(response.validator_info.voting_power.value(), 0);
}

Expand Down