From b6b35364f31281ed0243e0f99435b26b70e0de29 Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Tue, 26 May 2020 18:00:58 -0700 Subject: [PATCH] cleanup warnings throughout codebase --- zebra-chain/src/addresses/sapling.rs | 4 +-- zebra-chain/src/addresses/sprout.rs | 4 +-- zebra-chain/src/addresses/transparent.rs | 8 ++--- zebra-chain/src/block.rs | 1 + zebra-chain/src/equihash_solution.rs | 2 +- zebra-chain/src/keys/sapling.rs | 1 + zebra-chain/src/keys/sapling/test_vectors.rs | 36 +++++++++---------- zebra-chain/src/keys/sapling/tests.rs | 3 +- zebra-chain/src/keys/sprout.rs | 5 +-- zebra-chain/src/merkle_tree.rs | 1 + zebra-chain/src/note_commitment_tree.rs | 1 + zebra-chain/src/notes/sapling.rs | 5 +-- zebra-chain/src/notes/sprout.rs | 3 +- zebra-chain/src/proofs/bctv14.rs | 2 +- zebra-chain/src/proofs/groth16.rs | 2 +- zebra-chain/src/sha256d_writer.rs | 2 +- zebra-chain/src/transaction/hash.rs | 1 + zebra-chain/src/transaction/joinsplit.rs | 8 ++--- zebra-chain/src/transaction/shielded_data.rs | 12 +++---- zebra-chain/src/transaction/tests.rs | 38 ++++++++++---------- zebra-chain/src/transaction/transparent.rs | 1 + zebra-chain/src/types.rs | 2 +- zebra-network/src/meta_addr.rs | 2 +- zebra-network/src/peer/connection.rs | 2 +- zebra-network/src/peer/connector.rs | 2 +- zebra-network/src/peer/error.rs | 8 ----- zebra-network/src/peer_set/candidate_set.rs | 2 +- zebra-network/src/peer_set/initialize.rs | 4 +-- zebra-network/src/protocol/external/codec.rs | 2 +- zebra-network/src/protocol/external/types.rs | 3 +- zebrad/src/commands/connect.rs | 6 ++-- zebrad/src/commands/seed.rs | 2 +- zebrad/tests/acceptance.rs | 2 +- 33 files changed, 90 insertions(+), 87 deletions(-) diff --git a/zebra-chain/src/addresses/sapling.rs b/zebra-chain/src/addresses/sapling.rs index 4870bb57..b335f865 100644 --- a/zebra-chain/src/addresses/sapling.rs +++ b/zebra-chain/src/addresses/sapling.rs @@ -99,11 +99,11 @@ impl Arbitrary for SaplingShieldedAddress { any::(), ) .prop_map(|(network, diversifier, transmission_key)| { - return Self { + Self { network, diversifier, transmission_key, - }; + } }) .boxed() } diff --git a/zebra-chain/src/addresses/sprout.rs b/zebra-chain/src/addresses/sprout.rs index cb06dedb..8e0ad4f6 100644 --- a/zebra-chain/src/addresses/sprout.rs +++ b/zebra-chain/src/addresses/sprout.rs @@ -120,11 +120,11 @@ impl Arbitrary for SproutShieldedAddress { array::uniform32(any::()), ) .prop_map(|(network, paying_key_bytes, transmission_key_bytes)| { - return Self { + Self { network, paying_key: sprout::PayingKey(paying_key_bytes), transmission_key: sprout::TransmissionKey::from(transmission_key_bytes), - }; + } }) .boxed() } diff --git a/zebra-chain/src/addresses/transparent.rs b/zebra-chain/src/addresses/transparent.rs index 58cdb943..53cc6a45 100644 --- a/zebra-chain/src/addresses/transparent.rs +++ b/zebra-chain/src/addresses/transparent.rs @@ -209,10 +209,10 @@ impl TransparentAddress { .prop_map(|(network, payload_bytes)| { let mut bytes = [0; 20]; bytes.copy_from_slice(payload_bytes.as_slice()); - return Self::PayToPublicKeyHash { + Self::PayToPublicKeyHash { network, pub_key_hash: bytes, - }; + } }) .boxed() } @@ -222,10 +222,10 @@ impl TransparentAddress { .prop_map(|(network, payload_bytes)| { let mut bytes = [0; 20]; bytes.copy_from_slice(payload_bytes.as_slice()); - return Self::PayToScriptHash { + Self::PayToScriptHash { network, script_hash: bytes, - }; + } }) .boxed() } diff --git a/zebra-chain/src/block.rs b/zebra-chain/src/block.rs index 86ce1dac..5e698942 100644 --- a/zebra-chain/src/block.rs +++ b/zebra-chain/src/block.rs @@ -1,4 +1,5 @@ //! Definitions of block datastructures. +#![allow(clippy::unit_arg)] #[cfg(test)] pub mod test_vectors; diff --git a/zebra-chain/src/equihash_solution.rs b/zebra-chain/src/equihash_solution.rs index bf3a825e..2f39c8ac 100644 --- a/zebra-chain/src/equihash_solution.rs +++ b/zebra-chain/src/equihash_solution.rs @@ -76,7 +76,7 @@ impl Arbitrary for EquihashSolution { .prop_map(|v| { let mut bytes = [0; EQUIHASH_SOLUTION_SIZE]; bytes.copy_from_slice(v.as_slice()); - return Self(bytes); + Self(bytes) }) .boxed() } diff --git a/zebra-chain/src/keys/sapling.rs b/zebra-chain/src/keys/sapling.rs index f08c1537..c1c8359f 100644 --- a/zebra-chain/src/keys/sapling.rs +++ b/zebra-chain/src/keys/sapling.rs @@ -7,6 +7,7 @@ //! //! [ps]: https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents //! [3.1]: https://zips.z.cash/protocol/protocol.pdf#addressesandkeys +#![allow(clippy::unit_arg)] #[cfg(test)] mod test_vectors; diff --git a/zebra-chain/src/keys/sapling/test_vectors.rs b/zebra-chain/src/keys/sapling/test_vectors.rs index 3222814b..8e18a8af 100644 --- a/zebra-chain/src/keys/sapling/test_vectors.rs +++ b/zebra-chain/src/keys/sapling/test_vectors.rs @@ -124,7 +124,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0xd3, 0xcf, 0xb3, 0x92, 0x10, 0x83, 0x1e, 0xa3, 0xa2, 0x96, 0xba, 0x09, 0xa9, 0x22, 0x06, 0x0f, 0xd3, 0x8b, ], - note_v: 12227227834928555328, + note_v: 12_227_227_834_928_555_328, note_r: [ 0x47, 0x8b, 0xa0, 0xee, 0x6e, 0x1a, 0x75, 0xb6, 0x00, 0x03, 0x6f, 0x26, 0xf1, 0x8b, 0x70, 0x15, 0xab, 0x55, 0x6b, 0xed, 0xdf, 0x8b, 0x96, 0x02, 0x38, 0x86, 0x9f, 0x89, @@ -135,7 +135,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0x89, 0xe1, 0x0e, 0x26, 0x6b, 0xcf, 0xa3, 0x1c, 0x31, 0xb2, 0x9a, 0x53, 0xae, 0x72, 0xca, 0xd4, 0x69, 0x50, ], - note_pos: 763714296, + note_pos: 763_714_296, note_nf: [ 0x67, 0x9e, 0xb0, 0xc3, 0xa7, 0x57, 0xe2, 0xae, 0x83, 0xcd, 0xb4, 0x2a, 0x1a, 0xb2, 0x59, 0xd7, 0x83, 0x88, 0x31, 0x54, 0x19, 0xad, 0xc7, 0x1d, 0x2e, 0x37, 0x63, 0x17, @@ -186,7 +186,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0x5e, 0xed, 0x4d, 0x44, 0xc6, 0x22, 0x5c, 0x3c, 0x65, 0xd8, 0x8d, 0xd9, 0x90, 0x77, 0x08, 0x01, 0x2f, 0x5a, ], - note_v: 6007711596147559040, + note_v: 6_007_711_596_147_559_040, note_r: [ 0x14, 0x7c, 0xf2, 0xb5, 0x1b, 0x4c, 0x7c, 0x63, 0xcb, 0x77, 0xb9, 0x9e, 0x8b, 0x78, 0x3e, 0x5b, 0x51, 0x11, 0xdb, 0x0a, 0x7c, 0xa0, 0x4d, 0x6c, 0x01, 0x4a, 0x1d, 0x7d, @@ -197,7 +197,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0xb7, 0x40, 0x82, 0x96, 0x66, 0x17, 0x70, 0xb1, 0x01, 0xb0, 0xaa, 0x87, 0x83, 0x9f, 0x4e, 0x55, 0xf1, 0x51, ], - note_pos: 1527428592, + note_pos: 1_527_428_592, note_nf: [ 0xe9, 0x8f, 0x6a, 0x8f, 0x34, 0xff, 0x49, 0x80, 0x59, 0xb3, 0xc7, 0x31, 0xb9, 0x1f, 0x45, 0x11, 0x08, 0xc4, 0x95, 0x4d, 0x91, 0x94, 0x84, 0x36, 0x1c, 0xf9, 0xb4, 0x8f, @@ -248,7 +248,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0xea, 0xd7, 0x83, 0x2f, 0xb1, 0xf0, 0xf7, 0xa8, 0x31, 0x65, 0x89, 0x5b, 0xdf, 0xf9, 0x42, 0x92, 0x5f, 0x5c, ], - note_v: 18234939431076114368, + note_v: 18_234_939_431_076_114_368, note_r: [ 0x34, 0xa4, 0xb2, 0xa9, 0x14, 0x4f, 0xf5, 0xea, 0x54, 0xef, 0xee, 0x87, 0xcf, 0x90, 0x1b, 0x5b, 0xed, 0x5e, 0x35, 0xd2, 0x1f, 0xbb, 0xd7, 0x88, 0xd5, 0xbd, 0x9d, 0x83, @@ -259,7 +259,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0xbd, 0x10, 0x5d, 0x88, 0x39, 0x21, 0x2e, 0x0d, 0x16, 0x44, 0xb9, 0xd5, 0x5c, 0xaa, 0x60, 0xd1, 0x9b, 0x6c, ], - note_pos: 2291142888, + note_pos: 2_291_142_888, note_nf: [ 0x55, 0x47, 0xaa, 0x12, 0xff, 0x80, 0xa6, 0xb3, 0x30, 0x4e, 0x3b, 0x05, 0x86, 0x56, 0x47, 0x2a, 0xbd, 0x2c, 0x81, 0x83, 0xb5, 0x9d, 0x07, 0x37, 0xb9, 0x3c, 0xee, 0x75, @@ -310,7 +310,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0x69, 0x77, 0xf9, 0x05, 0x22, 0xe9, 0x2f, 0xde, 0x44, 0xc9, 0xd1, 0xbb, 0x09, 0x97, 0x14, 0xb9, 0xdb, 0x2b, ], - note_v: 12015423192295118080, + note_v: 12_015_423_192_295_118_080, note_r: [ 0xe5, 0x57, 0x85, 0x13, 0x55, 0x74, 0x7c, 0x09, 0xac, 0x59, 0x01, 0x3c, 0xbd, 0xe8, 0x59, 0x80, 0x96, 0x4e, 0xc1, 0x84, 0x4d, 0x9c, 0x69, 0x67, 0xca, 0x0c, 0x02, 0x9c, @@ -321,7 +321,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0xcf, 0x1e, 0x67, 0x15, 0xbf, 0xe7, 0x0b, 0x63, 0x2d, 0x04, 0x4b, 0x26, 0xfb, 0x2b, 0xc7, 0x1b, 0x7f, 0x36, ], - note_pos: 3054857184, + note_pos: 3_054_857_184, note_nf: [ 0x8a, 0x9a, 0xbd, 0xa3, 0xd4, 0xef, 0x85, 0xca, 0xf2, 0x2b, 0xfa, 0xf2, 0xc4, 0x8f, 0x62, 0x38, 0x2a, 0x73, 0xa1, 0x62, 0x4e, 0xb8, 0xeb, 0x2b, 0xd0, 0x0d, 0x27, 0x03, @@ -372,7 +372,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0x97, 0x86, 0x64, 0x8a, 0x11, 0xb5, 0x96, 0x6e, 0x51, 0xa2, 0xf7, 0xd8, 0x9e, 0x15, 0xd2, 0x9b, 0x8f, 0xdf, ], - note_v: 5795906953514121792, + note_v: 5_795_906_953_514_121_792, note_r: [ 0x68, 0xf0, 0x61, 0x04, 0x60, 0x6b, 0x0c, 0x54, 0x49, 0x84, 0x5f, 0xf4, 0xc6, 0x5f, 0x73, 0xe9, 0x0f, 0x45, 0xef, 0x5a, 0x43, 0xc9, 0xd7, 0x4c, 0xb2, 0xc8, 0x5c, 0xf5, @@ -383,7 +383,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0x1d, 0x74, 0xc5, 0xbc, 0xf2, 0xe1, 0xef, 0x95, 0x66, 0x90, 0x44, 0x73, 0x01, 0x69, 0xde, 0x1a, 0x5b, 0x4c, ], - note_pos: 3818571480, + note_pos: 3_818_571_480, note_nf: [ 0x33, 0x2a, 0xd9, 0x9e, 0xb9, 0xe9, 0x77, 0xeb, 0x62, 0x7a, 0x12, 0x2d, 0xbf, 0xb2, 0xf2, 0x5f, 0xe5, 0x88, 0xe5, 0x97, 0x75, 0x3e, 0xc5, 0x58, 0x0f, 0xf2, 0xbe, 0x20, @@ -434,7 +434,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0x71, 0xd2, 0x23, 0x49, 0x3c, 0x69, 0x80, 0x25, 0x44, 0x04, 0x3f, 0x77, 0xcf, 0x1d, 0x71, 0xc1, 0xcb, 0x8c, ], - note_v: 18023134788442677120, + note_v: 18_023_134_788_442_677_120, note_r: [ 0x49, 0xf9, 0x0b, 0x47, 0xfd, 0x52, 0xfe, 0xe7, 0xc1, 0xc8, 0x1f, 0x0d, 0xcb, 0x5b, 0x74, 0xc3, 0xfb, 0x9b, 0x3e, 0x03, 0x97, 0x6f, 0x8b, 0x75, 0x24, 0xea, 0xba, 0xd0, @@ -445,7 +445,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0x90, 0xb6, 0xe0, 0xf2, 0xf4, 0xbf, 0x4e, 0xc4, 0xa0, 0xdb, 0x5b, 0xbc, 0xcb, 0x5b, 0x78, 0x3a, 0x1e, 0x55, ], - note_pos: 287318480, + note_pos: 287_318_480, note_nf: [ 0xfc, 0x74, 0xcd, 0x0e, 0x4b, 0xe0, 0x49, 0x57, 0xb1, 0x96, 0xcf, 0x87, 0x34, 0xae, 0x99, 0x23, 0x96, 0xaf, 0x4c, 0xfa, 0x8f, 0xec, 0xbb, 0x86, 0xf9, 0x61, 0xe6, 0xb4, @@ -496,7 +496,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0xc4, 0xc8, 0xf7, 0x28, 0x13, 0x2c, 0xc1, 0x24, 0x56, 0x94, 0x6e, 0x7f, 0x4c, 0xb0, 0xfb, 0x05, 0x8d, 0xa9, ], - note_v: 11803618549661680832, + note_v: 11_803_618_549_661_680_832, note_r: [ 0x51, 0x65, 0xaf, 0xf2, 0x2d, 0xd4, 0xed, 0x56, 0xb4, 0xd8, 0x1d, 0x1f, 0x17, 0x1c, 0xc3, 0xd6, 0x43, 0x2f, 0xed, 0x1b, 0xeb, 0xf2, 0x0a, 0x7b, 0xea, 0xb1, 0x2d, 0xb1, @@ -507,7 +507,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0x60, 0xa0, 0x06, 0xf8, 0x2b, 0xb7, 0xad, 0xcd, 0x75, 0x22, 0x3f, 0xa8, 0x59, 0x36, 0xf7, 0x8c, 0x2b, 0x23, ], - note_pos: 1051032776, + note_pos: 1_051_032_776, note_nf: [ 0xd2, 0xe8, 0x87, 0xbd, 0x85, 0x4a, 0x80, 0x2b, 0xce, 0x85, 0x70, 0x53, 0x02, 0x0f, 0x5d, 0x3e, 0x7c, 0x8a, 0xe5, 0x26, 0x7c, 0x5b, 0x65, 0x83, 0xb3, 0xd2, 0x12, 0xcc, @@ -558,7 +558,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0x59, 0x45, 0xa4, 0x6d, 0x4f, 0xed, 0xf8, 0x06, 0x08, 0x28, 0x04, 0x1c, 0xd2, 0x0e, 0x62, 0xfd, 0x2c, 0xef, ], - note_v: 5584102310880684544, + note_v: 5_584_102_310_880_684_544, note_r: [ 0x8c, 0x3e, 0x56, 0x44, 0x9d, 0xc8, 0x63, 0x54, 0xd3, 0x3b, 0x02, 0x5e, 0xf2, 0x79, 0x34, 0x60, 0xbc, 0xb1, 0x69, 0xf3, 0x32, 0x4e, 0x4a, 0x6b, 0x64, 0xba, 0xa6, 0x08, @@ -569,7 +569,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0x23, 0x36, 0xc2, 0xa0, 0x5a, 0x08, 0x03, 0x23, 0x9b, 0x5b, 0x88, 0xfd, 0x92, 0x07, 0x8f, 0xea, 0x4d, 0x04, ], - note_pos: 1814747072, + note_pos: 1_814_747_072, note_nf: [ 0xa8, 0x2f, 0x17, 0x50, 0xcc, 0x5b, 0x2b, 0xee, 0x64, 0x9a, 0x36, 0x5c, 0x04, 0x20, 0xed, 0x87, 0x07, 0x5b, 0x88, 0x71, 0xfd, 0xa4, 0xa7, 0xf5, 0x84, 0x0d, 0x6b, 0xbe, @@ -620,7 +620,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0x25, 0x25, 0x5f, 0x7e, 0xe4, 0x87, 0x38, 0x5a, 0x30, 0x31, 0x6e, 0x15, 0xf6, 0x48, 0x2b, 0x87, 0x4f, 0xda, ], - note_v: 17811330145809239872, + note_v: 17_811_330_145_809_239_872, note_r: [ 0x6e, 0xbb, 0xed, 0x74, 0x36, 0x19, 0xa2, 0x56, 0xf9, 0xad, 0x2e, 0x85, 0x88, 0x0c, 0xfa, 0xa9, 0x09, 0x8a, 0x5f, 0xdb, 0x16, 0x29, 0x99, 0x0d, 0x9a, 0x7d, 0x3b, 0xb9, @@ -631,7 +631,7 @@ pub const TEST_VECTORS: [TestVector; 10] = [ 0x64, 0x41, 0x9b, 0x0e, 0x55, 0x0a, 0xbb, 0xcb, 0x8e, 0x2b, 0xcb, 0xda, 0x8b, 0x63, 0xe4, 0x1d, 0xeb, 0x37, ], - note_pos: 2578461368, + note_pos: 2_578_461_368, note_nf: [ 0x65, 0x36, 0x74, 0x87, 0x3b, 0x3c, 0x67, 0x0c, 0x58, 0x85, 0x84, 0x73, 0xe7, 0xfe, 0x72, 0x19, 0x72, 0xfb, 0x96, 0xe2, 0x15, 0xb8, 0x73, 0x77, 0xa1, 0x7c, 0xa3, 0x71, diff --git a/zebra-chain/src/keys/sapling/tests.rs b/zebra-chain/src/keys/sapling/tests.rs index 3d2a932c..252eae0d 100644 --- a/zebra-chain/src/keys/sapling/tests.rs +++ b/zebra-chain/src/keys/sapling/tests.rs @@ -1,3 +1,4 @@ +#![allow(clippy::module_inception)] use super::*; #[cfg(test)] @@ -21,7 +22,7 @@ impl Arbitrary for TransmissionKey { let diversifier = Diversifier::from(spending_key); - return Self::from((incoming_viewing_key, diversifier)); + Self::from((incoming_viewing_key, diversifier)) }) .boxed() } diff --git a/zebra-chain/src/keys/sprout.rs b/zebra-chain/src/keys/sprout.rs index b0525175..737446fa 100644 --- a/zebra-chain/src/keys/sprout.rs +++ b/zebra-chain/src/keys/sprout.rs @@ -5,6 +5,7 @@ //! derived from a_sk, as described in [‘Sprout Key Components’][ps] //! //! [ps]: https://zips.z.cash/protocol/protocol.pdf#sproutkeycomponents +#![allow(clippy::unit_arg)] use std::{fmt, io}; @@ -297,11 +298,11 @@ impl Arbitrary for IncomingViewingKey { array::uniform32(any::()), ) .prop_map(|(network, paying_key_bytes, receiving_key_bytes)| { - return Self { + Self { network, paying_key: PayingKey(paying_key_bytes), receiving_key: ReceivingKey::from(receiving_key_bytes), - }; + } }) .boxed() } diff --git a/zebra-chain/src/merkle_tree.rs b/zebra-chain/src/merkle_tree.rs index 54cf4846..891e1067 100644 --- a/zebra-chain/src/merkle_tree.rs +++ b/zebra-chain/src/merkle_tree.rs @@ -1,5 +1,6 @@ //! A binary hash tree of SHA256d (two rounds of SHA256) hashes for //! node values. +#![allow(clippy::unit_arg)] use std::{fmt, io}; diff --git a/zebra-chain/src/note_commitment_tree.rs b/zebra-chain/src/note_commitment_tree.rs index 19f1bd8b..143c7ea7 100644 --- a/zebra-chain/src/note_commitment_tree.rs +++ b/zebra-chain/src/note_commitment_tree.rs @@ -9,6 +9,7 @@ //! append-only. //! //! A root of a note commitment tree is associated with each treestate. +#![allow(clippy::unit_arg)] use std::{fmt, io}; diff --git a/zebra-chain/src/notes/sapling.rs b/zebra-chain/src/notes/sapling.rs index 0a34a86c..0c33ba14 100644 --- a/zebra-chain/src/notes/sapling.rs +++ b/zebra-chain/src/notes/sapling.rs @@ -1,4 +1,5 @@ //! +#![allow(dead_code)] use std::{fmt, io}; @@ -92,7 +93,7 @@ impl Arbitrary for EncryptedCiphertext { .prop_map(|v| { let mut bytes = [0; 580]; bytes.copy_from_slice(v.as_slice()); - return Self(bytes); + Self(bytes) }) .boxed() } @@ -155,7 +156,7 @@ impl Arbitrary for OutCiphertext { .prop_map(|v| { let mut bytes = [0; 80]; bytes.copy_from_slice(v.as_slice()); - return Self(bytes); + Self(bytes) }) .boxed() } diff --git a/zebra-chain/src/notes/sprout.rs b/zebra-chain/src/notes/sprout.rs index 70e12dcf..b7f249c2 100644 --- a/zebra-chain/src/notes/sprout.rs +++ b/zebra-chain/src/notes/sprout.rs @@ -1,4 +1,5 @@ //! +#![allow(dead_code)] use std::{ fmt, @@ -87,7 +88,7 @@ impl Arbitrary for EncryptedCiphertext { .prop_map(|v| { let mut bytes = [0; 601]; bytes.copy_from_slice(v.as_slice()); - return Self(bytes); + Self(bytes) }) .boxed() } diff --git a/zebra-chain/src/proofs/bctv14.rs b/zebra-chain/src/proofs/bctv14.rs index 52743454..280c68fd 100644 --- a/zebra-chain/src/proofs/bctv14.rs +++ b/zebra-chain/src/proofs/bctv14.rs @@ -60,7 +60,7 @@ impl Arbitrary for Bctv14Proof { .prop_map(|v| { let mut bytes = [0; 296]; bytes.copy_from_slice(v.as_slice()); - return Self(bytes); + Self(bytes) }) .boxed() } diff --git a/zebra-chain/src/proofs/groth16.rs b/zebra-chain/src/proofs/groth16.rs index 7200f677..4cc1789b 100644 --- a/zebra-chain/src/proofs/groth16.rs +++ b/zebra-chain/src/proofs/groth16.rs @@ -60,7 +60,7 @@ impl Arbitrary for Groth16Proof { .prop_map(|v| { let mut bytes = [0; 192]; bytes.copy_from_slice(v.as_slice()); - return Self(bytes); + Self(bytes) }) .boxed() } diff --git a/zebra-chain/src/sha256d_writer.rs b/zebra-chain/src/sha256d_writer.rs index 4e4c14a3..53c75bf2 100644 --- a/zebra-chain/src/sha256d_writer.rs +++ b/zebra-chain/src/sha256d_writer.rs @@ -46,6 +46,6 @@ mod tests { let mut sha_writer = Sha256dWriter::default(); let _ = sha_writer.write_all(preimage); - assert_eq!(sha_writer.flush().unwrap(), ()); + sha_writer.flush().unwrap(); } } diff --git a/zebra-chain/src/transaction/hash.rs b/zebra-chain/src/transaction/hash.rs index 1fbf7f3c..742363ec 100644 --- a/zebra-chain/src/transaction/hash.rs +++ b/zebra-chain/src/transaction/hash.rs @@ -1,3 +1,4 @@ +#![allow(clippy::unit_arg)] use std::fmt; #[cfg(test)] diff --git a/zebra-chain/src/transaction/joinsplit.rs b/zebra-chain/src/transaction/joinsplit.rs index aa58a84f..b4d13598 100644 --- a/zebra-chain/src/transaction/joinsplit.rs +++ b/zebra-chain/src/transaction/joinsplit.rs @@ -98,7 +98,7 @@ impl Arbitrary for JoinSplit

{ zkproof, enc_ciphertexts, )| { - return Self { + Self { vpub_old, vpub_new, anchor, @@ -109,7 +109,7 @@ impl Arbitrary for JoinSplit

{ vmacs, zkproof, enc_ciphertexts, - }; + } }, ) .boxed() @@ -160,7 +160,7 @@ impl Arbitrary for JoinSplitData

{ vec(any::(), 64), ) .prop_map(|(first, rest, pub_key_bytes, sig_bytes)| { - return Self { + Self { first, rest, pub_key: ed25519_zebra::PublicKeyBytes::from(pub_key_bytes), @@ -169,7 +169,7 @@ impl Arbitrary for JoinSplitData

{ b.copy_from_slice(sig_bytes.as_slice()); b }), - }; + } }) .boxed() } diff --git a/zebra-chain/src/transaction/shielded_data.rs b/zebra-chain/src/transaction/shielded_data.rs index 75d52204..6dbfbaaa 100644 --- a/zebra-chain/src/transaction/shielded_data.rs +++ b/zebra-chain/src/transaction/shielded_data.rs @@ -47,7 +47,7 @@ impl Arbitrary for Spend { ) .prop_map( |(cv_bytes, anchor, nullifier_bytes, rpk_bytes, proof, sig_bytes)| { - return Self { + Self { anchor, cv: cv_bytes, nullifier: nullifier_bytes, @@ -58,7 +58,7 @@ impl Arbitrary for Spend { b.copy_from_slice(sig_bytes.as_slice()); b }), - }; + } }, ) .boxed() @@ -109,7 +109,7 @@ impl Arbitrary for Output { ) .prop_map( |(cv, cmu, ephemeral_key_bytes, enc_ciphertext, out_ciphertext, zkproof)| { - return Self { + Self { cv, cmu, ephemeral_key: jubjub::AffinePoint::from_bytes(ephemeral_key_bytes) @@ -117,7 +117,7 @@ impl Arbitrary for Output { enc_ciphertext, out_ciphertext, zkproof, - }; + } }, ) .boxed() @@ -215,7 +215,7 @@ impl Arbitrary for ShieldedData { vec(any::(), 64), ) .prop_map(|(first, rest_spends, rest_outputs, sig_bytes)| { - return Self { + Self { first, rest_spends, rest_outputs, @@ -224,7 +224,7 @@ impl Arbitrary for ShieldedData { b.copy_from_slice(sig_bytes.as_slice()); b }), - }; + } }) .boxed() } diff --git a/zebra-chain/src/transaction/tests.rs b/zebra-chain/src/transaction/tests.rs index 3ac5bf19..ed78f0dd 100644 --- a/zebra-chain/src/transaction/tests.rs +++ b/zebra-chain/src/transaction/tests.rs @@ -21,9 +21,9 @@ impl Transaction { any::(), ) .prop_map(|(inputs, outputs, lock_time)| Transaction::V1 { - inputs: inputs, - outputs: outputs, - lock_time: lock_time, + inputs, + outputs, + lock_time, }) .boxed() } @@ -37,10 +37,10 @@ impl Transaction { ) .prop_map( |(inputs, outputs, lock_time, joinsplit_data)| Transaction::V2 { - inputs: inputs, - outputs: outputs, - lock_time: lock_time, - joinsplit_data: joinsplit_data, + inputs, + outputs, + lock_time, + joinsplit_data, }, ) .boxed() @@ -56,11 +56,11 @@ impl Transaction { ) .prop_map( |(inputs, outputs, lock_time, expiry_height, joinsplit_data)| Transaction::V3 { - inputs: inputs, - outputs: outputs, - lock_time: lock_time, - expiry_height: expiry_height, - joinsplit_data: joinsplit_data, + inputs, + outputs, + lock_time, + expiry_height, + joinsplit_data, }, ) .boxed() @@ -86,13 +86,13 @@ impl Transaction { shielded_data, joinsplit_data, )| Transaction::V4 { - inputs: inputs, - outputs: outputs, - lock_time: lock_time, - expiry_height: expiry_height, - value_balance: value_balance, - shielded_data: shielded_data, - joinsplit_data: joinsplit_data, + inputs, + outputs, + lock_time, + expiry_height, + value_balance, + shielded_data, + joinsplit_data, }, ) .boxed() diff --git a/zebra-chain/src/transaction/transparent.rs b/zebra-chain/src/transaction/transparent.rs index baab89f5..d7ff6e37 100644 --- a/zebra-chain/src/transaction/transparent.rs +++ b/zebra-chain/src/transaction/transparent.rs @@ -1,4 +1,5 @@ //! Transaction types. +#![allow(clippy::unit_arg)] #[cfg(test)] use proptest_derive::Arbitrary; diff --git a/zebra-chain/src/types.rs b/zebra-chain/src/types.rs index 6c8217b2..bacbb1d2 100644 --- a/zebra-chain/src/types.rs +++ b/zebra-chain/src/types.rs @@ -51,7 +51,7 @@ impl Arbitrary for BlockHeight { type Parameters = (); fn arbitrary_with(_args: ()) -> Self::Strategy { - (0u32..500_000_000_u32).prop_map(|h| BlockHeight(h)).boxed() + (0u32..500_000_000_u32).prop_map(BlockHeight).boxed() } type Strategy = BoxedStrategy; diff --git a/zebra-network/src/meta_addr.rs b/zebra-network/src/meta_addr.rs index 867d20a1..792e6d1c 100644 --- a/zebra-network/src/meta_addr.rs +++ b/zebra-network/src/meta_addr.rs @@ -95,7 +95,7 @@ mod tests { let entry = MetaAddr { services: PeerServices::default(), addr: "127.0.0.1:8233".parse().unwrap(), - last_seen: Utc.timestamp(1573680222, 0), + last_seen: Utc.timestamp(1_573_680_222, 0), } .sanitize(); // We want the sanitized timestamp to be a multiple of the truncation interval. diff --git a/zebra-network/src/peer/connection.rs b/zebra-network/src/peer/connection.rs index 3f4b0bf1..c27bbc57 100644 --- a/zebra-network/src/peer/connection.rs +++ b/zebra-network/src/peer/connection.rs @@ -407,7 +407,7 @@ where trace!(?req); use tower::{load_shed::error::Overloaded, ServiceExt}; - if self.svc.ready().await.is_err() { + if self.svc.ready_and().await.is_err() { // Treat all service readiness errors as Overloaded self.fail_with(PeerError::Overloaded); } diff --git a/zebra-network/src/peer/connector.rs b/zebra-network/src/peer/connector.rs index 7c1633c9..06414592 100644 --- a/zebra-network/src/peer/connector.rs +++ b/zebra-network/src/peer/connector.rs @@ -52,7 +52,7 @@ where let mut hs = self.handshaker.clone(); async move { let stream = TcpStream::connect(addr).await?; - hs.ready().await?; + hs.ready_and().await?; let client = hs.call((stream, addr)).await?; Ok(Change::Insert(addr, client)) } diff --git a/zebra-network/src/peer/error.rs b/zebra-network/src/peer/error.rs index 59f27808..2ad946aa 100644 --- a/zebra-network/src/peer/error.rs +++ b/zebra-network/src/peer/error.rs @@ -37,14 +37,6 @@ pub enum PeerError { /// disconnect from upon receipt. #[error("Remote peer sent an unsupported message type.")] UnsupportedMessage, - /// We got a `Reject` message. This does not necessarily mean that - /// the peer connection is in a bad state, but for the time being - /// we are considering it a PeerError. - // TODO: Create a different error type (more at the application - // level than network/connection level) that will include the - // appropriate error when a `Reject` message is received. - #[error("Received a Reject message")] - Rejected, /// The remote peer responded with a block we didn't ask for. #[error("Remote peer responded with a block we didn't ask for.")] WrongBlock, diff --git a/zebra-network/src/peer_set/candidate_set.rs b/zebra-network/src/peer_set/candidate_set.rs index cecc5456..5619ac11 100644 --- a/zebra-network/src/peer_set/candidate_set.rs +++ b/zebra-network/src/peer_set/candidate_set.rs @@ -107,7 +107,7 @@ where // called while the peer set is already loaded. let mut responses = FuturesUnordered::new(); for _ in 0..2usize { - self.peer_service.ready().await?; + self.peer_service.ready_and().await?; responses.push(self.peer_service.call(Request::Peers)); } while let Some(rsp) = responses.next().await { diff --git a/zebra-network/src/peer_set/initialize.rs b/zebra-network/src/peer_set/initialize.rs index 61683617..7dc2c1b4 100644 --- a/zebra-network/src/peer_set/initialize.rs +++ b/zebra-network/src/peer_set/initialize.rs @@ -181,7 +181,7 @@ where loop { if let Ok((tcp_stream, addr)) = listener.accept().await { debug!(?addr, "got incoming connection"); - handshaker.ready().await?; + handshaker.ready_and().await?; // Construct a handshake future but do not drive it yet.... let handshake = handshaker.call((tcp_stream, addr)); // ... instead, spawn a new task to handle this connection @@ -254,7 +254,7 @@ where } if let Some(candidate) = candidates.next() { debug!(?candidate.addr, "attempting outbound connection in response to demand"); - connector.ready().await?; + connector.ready_and().await?; handshakes.push( connector .call(candidate.addr) diff --git a/zebra-network/src/protocol/external/codec.rs b/zebra-network/src/protocol/external/codec.rs index 301013db..bbe123b2 100644 --- a/zebra-network/src/protocol/external/codec.rs +++ b/zebra-network/src/protocol/external/codec.rs @@ -554,7 +554,7 @@ mod tests { fn version_message_round_trip() { use std::net::{IpAddr, Ipv4Addr, SocketAddr}; let services = PeerServices::NODE_NETWORK; - let timestamp = Utc.timestamp(1568000000, 0); + let timestamp = Utc.timestamp(1_568_000_000, 0); let mut rt = Runtime::new().unwrap(); diff --git a/zebra-network/src/protocol/external/types.rs b/zebra-network/src/protocol/external/types.rs index 3be3f08c..083a3f55 100644 --- a/zebra-network/src/protocol/external/types.rs +++ b/zebra-network/src/protocol/external/types.rs @@ -1,3 +1,4 @@ +#![allow(clippy::unit_arg)] use std::fmt; #[cfg(test)] @@ -76,7 +77,7 @@ pub struct Filter(pub Vec); #[cfg(test)] mod proptest { - use hex; + use proptest::prelude::*; diff --git a/zebrad/src/commands/connect.rs b/zebrad/src/commands/connect.rs index fe8e0993..a599f009 100644 --- a/zebrad/src/commands/connect.rs +++ b/zebrad/src/commands/connect.rs @@ -68,7 +68,7 @@ impl ConnectCmd { info!("waiting for peer_set ready"); peer_set - .ready() + .ready_and() .await .map_err(|e| Error::from(ErrorKind::Io.context(e)))?; @@ -91,7 +91,7 @@ impl ConnectCmd { let mut requested_block_heights = 0; while requested_block_heights < 700_000 { // Request the next 500 hashes. - retry_peer_set.ready().await.unwrap(); + retry_peer_set.ready_and().await.unwrap(); let hashes = if let Ok(Response::BlockHeaderHashes(hashes)) = retry_peer_set .call(Request::FindBlocks { known_blocks: vec![tip], @@ -117,7 +117,7 @@ impl ConnectCmd { // Request the corresponding blocks in chunks for chunk in hashes.chunks(10usize) { - peer_set.ready().await.unwrap(); + peer_set.ready_and().await.unwrap(); block_requests .push(peer_set.call(Request::BlocksByHash(chunk.iter().cloned().collect()))); } diff --git a/zebrad/src/commands/seed.rs b/zebrad/src/commands/seed.rs index 2a80c178..33c36456 100644 --- a/zebrad/src/commands/seed.rs +++ b/zebrad/src/commands/seed.rs @@ -145,7 +145,7 @@ impl SeedCmd { info!("waiting for peer_set ready"); peer_set - .ready() + .ready_and() .await .map_err(|e| Error::from(ErrorKind::Io.context(e)))?; diff --git a/zebrad/tests/acceptance.rs b/zebrad/tests/acceptance.rs index dbcf191a..f7a2b995 100644 --- a/zebrad/tests/acceptance.rs +++ b/zebrad/tests/acceptance.rs @@ -14,7 +14,7 @@ use abscissa_core::testing::prelude::*; use once_cell::sync::Lazy; /// Executes your application binary via `cargo run`. -pub static RUNNER: Lazy = Lazy::new(|| CmdRunner::default()); +pub static RUNNER: Lazy = Lazy::new(CmdRunner::default); /* * Disabled pending tracing config rework, so that merging abscissa fixes doesn't block on this