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:
parent
8c178c3ee4
commit
4a2d2a359c
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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")"#
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use std::{
|
||||
collections::HashSet,
|
||||
net::{SocketAddr, ToSocketAddrs},
|
||||
string::String,
|
||||
time::Duration, collections::HashSet,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use zebra_chain::Network;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -77,8 +77,6 @@ pub struct Filter(pub Vec<u8>);
|
|||
#[cfg(test)]
|
||||
mod proptest {
|
||||
|
||||
|
||||
|
||||
use proptest::prelude::*;
|
||||
|
||||
use super::Magic;
|
||||
|
|
Loading…
Reference in New Issue