Merge rust-bitcoin/rust-secp256k1#526: Run the formatter in CI
75f3886812
Add cargo fmt to pre-commit githook (Tobin C. Harding)0516ddeb8d
Add formatting check to CI (Tobin C. Harding)c7807dff9c
Run the formatter (Tobin C. Harding) Pull request description: We recently introduced `rustfmt` to the codebase but I forgot to turn it on in CI. - Patch 1: Preparatory formatting fixes, introduced since we merged the [formatting PR](https://github.com/rust-bitcoin/rust-secp256k1/pull/499) - Patch 2: Enable formatting in CI - Patch 3: Add formatting to the pre-commit hook ACKs for top commit: apoelstra: ACK75f3886812
Tree-SHA512: 5ac4ab4015a9728ef890e0c4fe90afcb5e45ab7665da5a8ee289dc877c1ea5c6236e54b68b7122841597864b04606c8bfae7dec86c4b6be74d32437299057b5f
This commit is contained in:
commit
ba47a25295
|
@ -18,6 +18,10 @@ jobs:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
override: true
|
override: true
|
||||||
components: rust-src
|
components: rust-src
|
||||||
|
- name: Check formatting
|
||||||
|
env:
|
||||||
|
DO_FMT: true
|
||||||
|
run: ./contrib/test.sh
|
||||||
- name: Running address sanitizer
|
- name: Running address sanitizer
|
||||||
env:
|
env:
|
||||||
DO_ASAN: true
|
DO_ASAN: true
|
||||||
|
|
|
@ -88,6 +88,15 @@ if [ "$DO_ASAN" = true ]; then
|
||||||
cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully"
|
cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Run formatter if told to.
|
||||||
|
if [ "$DO_FMT" = true ]; then
|
||||||
|
if [ "$NIGHTLY" = false ]; then
|
||||||
|
echo "DO_FMT requires a nightly toolchain (consider using RUSTUP_TOOLCHAIN)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
rustup component add rustfmt
|
||||||
|
cargo fmt --check || exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Bench if told to, only works with non-stable toolchain (nightly, beta).
|
# Bench if told to, only works with non-stable toolchain (nightly, beta).
|
||||||
if [ "$DO_BENCH" = true ]
|
if [ "$DO_BENCH" = true ]
|
||||||
|
|
|
@ -48,3 +48,6 @@ git diff-index --check --cached $against -- || exit 1
|
||||||
|
|
||||||
# Check that code lints cleanly.
|
# Check that code lints cleanly.
|
||||||
cargo clippy --features=rand-std,recovery,lowmemory,global-context --all-targets -- -D warnings || exit 1
|
cargo clippy --features=rand-std,recovery,lowmemory,global-context --all-targets -- -D warnings || exit 1
|
||||||
|
|
||||||
|
# Check that there are no formatting issues.
|
||||||
|
cargo +nightly fmt --check || exit 1
|
||||||
|
|
|
@ -1515,7 +1515,7 @@ mod test {
|
||||||
use core::str::FromStr;
|
use core::str::FromStr;
|
||||||
|
|
||||||
#[cfg(feature = "rand")]
|
#[cfg(feature = "rand")]
|
||||||
use rand::{self, RngCore, rngs::mock::StepRng};
|
use rand::{self, rngs::mock::StepRng, RngCore};
|
||||||
use serde_test::{Configure, Token};
|
use serde_test::{Configure, Token};
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use wasm_bindgen_test::wasm_bindgen_test as test;
|
use wasm_bindgen_test::wasm_bindgen_test as test;
|
||||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -530,19 +530,16 @@ pub(crate) fn random_32_bytes<R: rand::Rng + ?Sized>(rng: &mut R) -> [u8; 32] {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#[allow(unused_imports)] // When building with no default features.
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use wasm_bindgen_test::wasm_bindgen_test as test;
|
use wasm_bindgen_test::wasm_bindgen_test as test;
|
||||||
|
|
||||||
|
#[allow(unused_imports)] // When building with no default features.
|
||||||
|
use super::*;
|
||||||
|
use crate::{constants, ecdsa, from_hex, Error, Message};
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
use crate::{ffi, PublicKey, Secp256k1, SecretKey};
|
use crate::{ffi, PublicKey, Secp256k1, SecretKey};
|
||||||
use crate::{
|
|
||||||
constants, ecdsa, from_hex, Error, Message,
|
|
||||||
};
|
|
||||||
|
|
||||||
macro_rules! hex {
|
macro_rules! hex {
|
||||||
($hex:expr) => {{
|
($hex:expr) => {{
|
||||||
|
@ -889,9 +886,10 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "rand-std")]
|
#[cfg(feature = "rand-std")]
|
||||||
fn test_hex() {
|
fn test_hex() {
|
||||||
use super::to_hex;
|
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
|
|
||||||
|
use super::to_hex;
|
||||||
|
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
const AMOUNT: usize = 1024;
|
const AMOUNT: usize = 1024;
|
||||||
for i in 0..AMOUNT {
|
for i in 0..AMOUNT {
|
||||||
|
|
|
@ -17,22 +17,17 @@
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! impl_array_newtype {
|
macro_rules! impl_array_newtype {
|
||||||
($thing:ident, $ty:ty, $len:expr) => {
|
($thing:ident, $ty:ty, $len:expr) => {
|
||||||
|
|
||||||
// We cannot derive these traits because Rust 1.41.1 requires `std::array::LengthAtMost32`.
|
// We cannot derive these traits because Rust 1.41.1 requires `std::array::LengthAtMost32`.
|
||||||
|
|
||||||
impl PartialEq for $thing {
|
impl PartialEq for $thing {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &$thing) -> bool {
|
fn eq(&self, other: &$thing) -> bool { &self[..] == &other[..] }
|
||||||
&self[..] == &other[..]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Eq for $thing {}
|
impl Eq for $thing {}
|
||||||
|
|
||||||
impl core::hash::Hash for $thing {
|
impl core::hash::Hash for $thing {
|
||||||
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
fn hash<H: core::hash::Hasher>(&self, state: &mut H) { (&self[..]).hash(state) }
|
||||||
(&self[..]).hash(state)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialOrd for $thing {
|
impl PartialOrd for $thing {
|
||||||
|
@ -44,9 +39,7 @@ macro_rules! impl_array_newtype {
|
||||||
|
|
||||||
impl Ord for $thing {
|
impl Ord for $thing {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cmp(&self, other: &$thing) -> core::cmp::Ordering {
|
fn cmp(&self, other: &$thing) -> core::cmp::Ordering { self[..].cmp(&other[..]) }
|
||||||
self[..].cmp(&other[..])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<[$ty; $len]> for $thing {
|
impl AsRef<[$ty; $len]> for $thing {
|
||||||
|
@ -81,7 +74,7 @@ macro_rules! impl_array_newtype {
|
||||||
dat.as_mut_ptr()
|
dat.as_mut_ptr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! impl_pretty_debug {
|
macro_rules! impl_pretty_debug {
|
||||||
|
@ -139,5 +132,5 @@ macro_rules! impl_fast_comparisons {
|
||||||
self.0.eq_fast_unstable(&other.0)
|
self.0.eq_fast_unstable(&other.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,9 @@ use crate::ffi::{self, CPtr};
|
||||||
use crate::key::{KeyPair, XOnlyPublicKey};
|
use crate::key::{KeyPair, XOnlyPublicKey};
|
||||||
#[cfg(feature = "global-context")]
|
#[cfg(feature = "global-context")]
|
||||||
use crate::SECP256K1;
|
use crate::SECP256K1;
|
||||||
use crate::{constants, from_hex, impl_array_newtype, Error, Message, Secp256k1, Signing, Verification};
|
use crate::{
|
||||||
|
constants, from_hex, impl_array_newtype, Error, Message, Secp256k1, Signing, Verification,
|
||||||
|
};
|
||||||
|
|
||||||
/// Represents a Schnorr signature.
|
/// Represents a Schnorr signature.
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
|
|
Loading…
Reference in New Issue