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 uses: actions-rs/clippy@master # Next gen Clippy Action, unstable
with: with:
args: --all-features --all-targets 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::Diversifier>(),
any::<sapling::TransmissionKey>(), any::<sapling::TransmissionKey>(),
) )
.prop_map(|(network, diversifier, transmission_key)| { .prop_map(|(network, diversifier, transmission_key)| Self {
Self { network,
network, diversifier,
diversifier, transmission_key,
transmission_key,
}
}) })
.boxed() .boxed()
} }

View File

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

View File

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

View File

@ -74,7 +74,10 @@ mod tests {
#[test] #[test]
fn transactionhash_from_str() { fn transactionhash_from_str() {
let hash:TransactionHash = "bf46b4b5030752fedac6f884976162bbfb29a9398f104a280b3e34d51b416631".parse().unwrap(); let hash: TransactionHash =
"bf46b4b5030752fedac6f884976162bbfb29a9398f104a280b3e34d51b416631"
.parse()
.unwrap();
assert_eq!( assert_eq!(
format!("{:?}", hash), format!("{:?}", hash),
r#"TransactionHash("bf46b4b5030752fedac6f884976162bbfb29a9398f104a280b3e34d51b416631")"# r#"TransactionHash("bf46b4b5030752fedac6f884976162bbfb29a9398f104a280b3e34d51b416631")"#

View File

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

View File

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

View File

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

View File

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

View File

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