Skip to content

Fix CI #641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions contrib/test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/sh
#!/usr/bin/env bash

set -ex

REPO_DIR=$(git rev-parse --show-toplevel)
FEATURES="bitcoin-hashes global-context lowmemory rand recovery serde std alloc bitcoin-hashes-std rand-std"

cargo --version
Expand All @@ -16,11 +17,13 @@ fi
# Pin dependencies as required if we are using MSRV toolchain.
if cargo --version | grep "1\.48"; then
cargo update -p wasm-bindgen-test --precise 0.3.34
cargo update -p serde --precise 1.0.156
cargo update -p serde_test --precise 1.0.175
fi

# Test if panic in C code aborts the process (either with a real panic or with SIGILL)
cargo test -- --ignored --exact 'tests::test_panic_raw_ctx_should_terminate_abnormally' 2>&1 | tee /dev/stderr | grep "SIGILL\\|panicked at '\[libsecp256k1\]"
cargo test -- --ignored --exact 'tests::test_panic_raw_ctx_should_terminate_abnormally' 2>&1 \
| tee /dev/stderr \
| grep "SIGILL\\|\[libsecp256k1] illegal argument. !rustsecp256k1_v0_._._fe_is_zero(&ge->x)"

# Make all cargo invocations verbose
export CARGO_TERM_VERBOSE=true
Expand Down Expand Up @@ -106,6 +109,12 @@ if [ "$DO_ASAN" = true ]; then
CC='clang -fsanitize=memory -fno-omit-frame-pointer' \
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes -Cllvm-args=-msan-eager-checks=0' \
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu

pushd "$REPO_DIR/no_std_test" > /dev/null || exit 1
# See https://github.com/rust-bitcoin/rust-secp256k1/pull/641#issuecomment-1671598914
cargo update -p cc --precise 1.0.79
popd > /dev/null || exit 1

cargo run --release --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified Successfully"
cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully"
fi
Expand Down
1 change: 0 additions & 1 deletion no_std_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
//! * Requires linking with `libc` for calling `printf`.
//!

#![feature(lang_items)]
#![feature(start)]
#![feature(core_intrinsics)]
#![feature(panic_info_message)]
Expand Down
4 changes: 3 additions & 1 deletion src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,8 @@ impl serde::Serialize for KeyPair {
}

#[cfg(feature = "serde")]
#[allow(unused_variables)] // For `data` under some feature combinations (the unconditional panic below).
#[allow(unreachable_code)] // For `KeyPair::from_seckey_slice` after unconditional panic.
impl<'de> serde::Deserialize<'de> for KeyPair {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
if d.is_human_readable() {
Expand All @@ -1051,7 +1053,7 @@ impl<'de> serde::Deserialize<'de> for KeyPair {
let ctx = Secp256k1::signing_only();

#[cfg(not(any(feature = "global-context", feature = "alloc")))]
let ctx: Secp256k1<crate::SignOnlyPreallocated> = panic!("The previous implementation was panicking too, please enable the global-context feature of rust-secp256k1");
let ctx: Secp256k1<crate::SignOnlyPreallocated> = panic!("cannot deserialize key pair without a context (please enable either the global-context or alloc feature)");

#[allow(clippy::needless_borrow)]
KeyPair::from_seckey_slice(&ctx, data)
Expand Down