add cargo fmt to ci (#403)

* add cargo fmt to ci

* rebase on main

* switch to stable

Co-authored-by: Jane Lusby <jane@zfnd.org>
This commit is contained in:
Jane Lusby 2020-05-27 19:12:25 -07:00 committed by GitHub
parent 8c178c3ee4
commit 4a2d2a359c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 73 additions and 71 deletions

View File

@ -86,3 +86,18 @@ jobs:
uses: actions-rs/clippy@master # Next gen Clippy Action, unstable
with:
args: --all-features --all-targets
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

View File

@ -98,12 +98,10 @@ impl Arbitrary for SaplingShieldedAddress {
any::<sapling::Diversifier>(),
any::<sapling::TransmissionKey>(),
)
.prop_map(|(network, diversifier, transmission_key)| {
Self {
network,
diversifier,
transmission_key,
}
.prop_map(|(network, diversifier, transmission_key)| Self {
network,
diversifier,
transmission_key,
})
.boxed()
}

View File

@ -119,12 +119,10 @@ impl Arbitrary for SproutShieldedAddress {
array::uniform32(any::<u8>()),
array::uniform32(any::<u8>()),
)
.prop_map(|(network, paying_key_bytes, transmission_key_bytes)| {
Self {
network,
paying_key: sprout::PayingKey(paying_key_bytes),
transmission_key: sprout::TransmissionKey::from(transmission_key_bytes),
}
.prop_map(|(network, paying_key_bytes, transmission_key_bytes)| Self {
network,
paying_key: sprout::PayingKey(paying_key_bytes),
transmission_key: sprout::TransmissionKey::from(transmission_key_bytes),
})
.boxed()
}

View File

@ -297,12 +297,10 @@ impl Arbitrary for IncomingViewingKey {
array::uniform32(any::<u8>()),
array::uniform32(any::<u8>()),
)
.prop_map(|(network, paying_key_bytes, receiving_key_bytes)| {
Self {
network,
paying_key: PayingKey(paying_key_bytes),
receiving_key: ReceivingKey::from(receiving_key_bytes),
}
.prop_map(|(network, paying_key_bytes, receiving_key_bytes)| Self {
network,
paying_key: PayingKey(paying_key_bytes),
receiving_key: ReceivingKey::from(receiving_key_bytes),
})
.boxed()
}

View File

@ -39,7 +39,7 @@ impl fmt::Debug for TransactionHash {
impl std::str::FromStr for TransactionHash {
type Err = SerializationError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut bytes = [0; 32];
if hex::decode_to_slice(s, &mut bytes[..]).is_err() {
@ -74,7 +74,10 @@ mod tests {
#[test]
fn transactionhash_from_str() {
let hash:TransactionHash = "bf46b4b5030752fedac6f884976162bbfb29a9398f104a280b3e34d51b416631".parse().unwrap();
let hash: TransactionHash =
"bf46b4b5030752fedac6f884976162bbfb29a9398f104a280b3e34d51b416631"
.parse()
.unwrap();
assert_eq!(
format!("{:?}", hash),
r#"TransactionHash("bf46b4b5030752fedac6f884976162bbfb29a9398f104a280b3e34d51b416631")"#

View File

@ -159,17 +159,15 @@ impl<P: ZkSnarkProof + Arbitrary + 'static> Arbitrary for JoinSplitData<P> {
array::uniform32(any::<u8>()),
vec(any::<u8>(), 64),
)
.prop_map(|(first, rest, pub_key_bytes, sig_bytes)| {
Self {
first,
rest,
pub_key: ed25519_zebra::PublicKeyBytes::from(pub_key_bytes),
sig: ed25519_zebra::Signature::from({
let mut b = [0u8; 64];
b.copy_from_slice(sig_bytes.as_slice());
b
}),
}
.prop_map(|(first, rest, pub_key_bytes, sig_bytes)| Self {
first,
rest,
pub_key: ed25519_zebra::PublicKeyBytes::from(pub_key_bytes),
sig: ed25519_zebra::Signature::from({
let mut b = [0u8; 64];
b.copy_from_slice(sig_bytes.as_slice());
b
}),
})
.boxed()
}

View File

@ -46,19 +46,17 @@ impl Arbitrary for Spend {
vec(any::<u8>(), 64),
)
.prop_map(
|(cv_bytes, anchor, nullifier_bytes, rpk_bytes, proof, sig_bytes)| {
Self {
anchor,
cv: cv_bytes,
nullifier: nullifier_bytes,
rk: redjubjub::PublicKeyBytes::from(rpk_bytes),
zkproof: proof,
spend_auth_sig: redjubjub::Signature::from({
let mut b = [0u8; 64];
b.copy_from_slice(sig_bytes.as_slice());
b
}),
}
|(cv_bytes, anchor, nullifier_bytes, rpk_bytes, proof, sig_bytes)| Self {
anchor,
cv: cv_bytes,
nullifier: nullifier_bytes,
rk: redjubjub::PublicKeyBytes::from(rpk_bytes),
zkproof: proof,
spend_auth_sig: redjubjub::Signature::from({
let mut b = [0u8; 64];
b.copy_from_slice(sig_bytes.as_slice());
b
}),
},
)
.boxed()
@ -108,16 +106,13 @@ impl Arbitrary for Output {
any::<Groth16Proof>(),
)
.prop_map(
|(cv, cmu, ephemeral_key_bytes, enc_ciphertext, out_ciphertext, zkproof)| {
Self {
cv,
cmu,
ephemeral_key: jubjub::AffinePoint::from_bytes(ephemeral_key_bytes)
.unwrap(),
enc_ciphertext,
out_ciphertext,
zkproof,
}
|(cv, cmu, ephemeral_key_bytes, enc_ciphertext, out_ciphertext, zkproof)| Self {
cv,
cmu,
ephemeral_key: jubjub::AffinePoint::from_bytes(ephemeral_key_bytes).unwrap(),
enc_ciphertext,
out_ciphertext,
zkproof,
},
)
.boxed()
@ -214,17 +209,15 @@ impl Arbitrary for ShieldedData {
vec(any::<Output>(), 0..10),
vec(any::<u8>(), 64),
)
.prop_map(|(first, rest_spends, rest_outputs, sig_bytes)| {
Self {
first,
rest_spends,
rest_outputs,
binding_sig: redjubjub::Signature::from({
let mut b = [0u8; 64];
b.copy_from_slice(sig_bytes.as_slice());
b
}),
}
.prop_map(|(first, rest_spends, rest_outputs, sig_bytes)| Self {
first,
rest_spends,
rest_outputs,
binding_sig: redjubjub::Signature::from({
let mut b = [0u8; 64];
b.copy_from_slice(sig_bytes.as_slice());
b
}),
})
.boxed()
}

View File

@ -1,7 +1,8 @@
use std::{
collections::HashSet,
net::{SocketAddr, ToSocketAddrs},
string::String,
time::Duration, collections::HashSet,
time::Duration,
};
use zebra_chain::Network;

View File

@ -64,8 +64,8 @@ pub use crate::{
config::Config,
peer_set::init,
policies::{RetryErrors, RetryLimit},
protocol::internal::{Request, Response},
protocol::external::codec::Builder,
protocol::internal::{Request, Response},
};
/// Types used in the definition of [`Request`] and [`Response`] messages.

View File

@ -181,8 +181,8 @@ where
return Err(HandshakeError::UnexpectedMessage(Box::new(remote_msg)));
}
// XXX in zcashd remote peer can only send one version message and
// we would disconnect here if it received a second one. Is it even possible
// XXX in zcashd remote peer can only send one version message and
// we would disconnect here if it received a second one. Is it even possible
// for that to happen to us here?
if remote_version < constants::MIN_VERSION {

View File

@ -77,8 +77,6 @@ pub struct Filter(pub Vec<u8>);
#[cfg(test)]
mod proptest {
use proptest::prelude::*;
use super::Magic;