cleanup warnings throughout codebase

This commit is contained in:
Jane Lusby 2020-05-26 18:00:58 -07:00 committed by Deirdre Connolly
parent 8d29d05761
commit b6b35364f3
33 changed files with 90 additions and 87 deletions

View File

@ -99,11 +99,11 @@ impl Arbitrary for SaplingShieldedAddress {
any::<sapling::TransmissionKey>(),
)
.prop_map(|(network, diversifier, transmission_key)| {
return Self {
Self {
network,
diversifier,
transmission_key,
};
}
})
.boxed()
}

View File

@ -120,11 +120,11 @@ impl Arbitrary for SproutShieldedAddress {
array::uniform32(any::<u8>()),
)
.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()
}

View File

@ -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()
}

View File

@ -1,4 +1,5 @@
//! Definitions of block datastructures.
#![allow(clippy::unit_arg)]
#[cfg(test)]
pub mod test_vectors;

View File

@ -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()
}

View File

@ -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;

View File

@ -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,

View File

@ -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()
}

View File

@ -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::<u8>()),
)
.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()
}

View File

@ -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};

View File

@ -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};

View File

@ -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()
}

View File

@ -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()
}

View File

@ -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()
}

View File

@ -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()
}

View File

@ -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();
}
}

View File

@ -1,3 +1,4 @@
#![allow(clippy::unit_arg)]
use std::fmt;
#[cfg(test)]

View File

@ -98,7 +98,7 @@ impl<P: ZkSnarkProof + Arbitrary + 'static> Arbitrary for JoinSplit<P> {
zkproof,
enc_ciphertexts,
)| {
return Self {
Self {
vpub_old,
vpub_new,
anchor,
@ -109,7 +109,7 @@ impl<P: ZkSnarkProof + Arbitrary + 'static> Arbitrary for JoinSplit<P> {
vmacs,
zkproof,
enc_ciphertexts,
};
}
},
)
.boxed()
@ -160,7 +160,7 @@ impl<P: ZkSnarkProof + Arbitrary + 'static> Arbitrary for JoinSplitData<P> {
vec(any::<u8>(), 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<P: ZkSnarkProof + Arbitrary + 'static> Arbitrary for JoinSplitData<P> {
b.copy_from_slice(sig_bytes.as_slice());
b
}),
};
}
})
.boxed()
}

View File

@ -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::<u8>(), 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()
}

View File

@ -21,9 +21,9 @@ impl Transaction {
any::<LockTime>(),
)
.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()

View File

@ -1,4 +1,5 @@
//! Transaction types.
#![allow(clippy::unit_arg)]
#[cfg(test)]
use proptest_derive::Arbitrary;

View File

@ -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<Self>;

View File

@ -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.

View File

@ -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);
}

View File

@ -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))
}

View File

@ -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,

View File

@ -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 {

View File

@ -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)

View File

@ -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();

View File

@ -1,3 +1,4 @@
#![allow(clippy::unit_arg)]
use std::fmt;
#[cfg(test)]
@ -76,7 +77,7 @@ pub struct Filter(pub Vec<u8>);
#[cfg(test)]
mod proptest {
use hex;
use proptest::prelude::*;

View File

@ -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())));
}

View File

@ -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)))?;

View File

@ -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<CmdRunner> = Lazy::new(|| CmdRunner::default());
pub static RUNNER: Lazy<CmdRunner> = Lazy::new(CmdRunner::default);
/*
* Disabled pending tracing config rework, so that merging abscissa fixes doesn't block on this