diff --git a/contrib/test.sh b/contrib/test.sh index e76c193..379059e 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -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 @@ -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 @@ -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 diff --git a/no_std_test/src/main.rs b/no_std_test/src/main.rs index d98276c..2e2a3bd 100644 --- a/no_std_test/src/main.rs +++ b/no_std_test/src/main.rs @@ -27,7 +27,6 @@ //! * Requires linking with `libc` for calling `printf`. //! -#![feature(lang_items)] #![feature(start)] #![feature(core_intrinsics)] #![feature(panic_info_message)] diff --git a/src/key.rs b/src/key.rs index 0eb747e..ecec179 100644 --- a/src/key.rs +++ b/src/key.rs @@ -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: D) -> Result { if d.is_human_readable() { @@ -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 = panic!("The previous implementation was panicking too, please enable the global-context feature of rust-secp256k1"); + let ctx: Secp256k1 = 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)