Skip to content
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

Fix ci #705

Merged
merged 8 commits into from
Jul 5, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ jobs:
- name: install cross
run: cargo install cross
- name: run cross test
run: cross test --target ${{ matrix.arch }}
run: cross test --target ${{ matrix.arch }} --verbose
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
uses: dtolnay/rust-toolchain@nightly
- name: Install src
run: rustup component add rust-src
- name: Install xargo
run: cargo install xargo
- name: Running test script
env:
DO_FMT: true
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ bincode = "1.3.3"
wasm-bindgen-test = "0.3"
getrandom = { version = "0.2", features = ["js"] }

[lints.rust]
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(bench)', 'cfg(secp256k1_fuzz)', 'cfg(rust_secp_no_symbol_renaming)'] }

[[example]]
name = "sign_verify_recovery"
Expand Down
2 changes: 2 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.x86_64-pc-windows-gnu]
image = "ghcr.io/cross-rs/x86_64-pc-windows-gnu:main"
6 changes: 4 additions & 2 deletions contrib/_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ if [ "$DO_ASAN" = true ]; then
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

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"
cd no_std_test
xargo run --release --target=x86_64-unknown-linux-gnu | grep -q "Verified Successfully"
xargo run --release --target=x86_64-unknown-linux-gnu --features=alloc | grep -q "Verified alloc Successfully"
cd -
fi

# Run formatter if told to.
Expand Down
1 change: 1 addition & 0 deletions no_std_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "no_std_test"
version = "0.1.0"
authors = ["Elichai Turkel <elichai.turkel@gmail.com>"]
edition = "2021"

[features]
alloc = ["secp256k1/alloc", "wee_alloc"]
Expand Down
2 changes: 2 additions & 0 deletions no_std_test/Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[dependencies]
alloc = {}
19 changes: 10 additions & 9 deletions no_std_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
//!

#![feature(start)]
#![feature(core_intrinsics)]
#![feature(panic_info_message)]
#![feature(alloc_error_handler)]
#![no_std]
extern crate libc;
Expand All @@ -48,8 +46,7 @@ extern crate wee_alloc;
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

use core::fmt::{self, write, Write};
use core::intrinsics;
use core::fmt::{self, Write};
use core::panic::PanicInfo;

use secp256k1::ecdh::{self, SharedSecret};
Expand All @@ -62,6 +59,10 @@ use serde_cbor::de;
use serde_cbor::ser::SliceWrite;
use serde_cbor::Serializer;

fn abort() -> ! {
unsafe { libc::abort() }
}

struct FakeRng;
impl RngCore for FakeRng {
fn next_u32(&mut self) -> u32 {
Expand Down Expand Up @@ -158,7 +159,7 @@ impl Write for Print {
if curr + s.len() > MAX_PRINT {
unsafe {
libc::printf("overflow\n\0".as_ptr() as _);
intrinsics::abort();
abort();
}
}
self.loc += s.len();
Expand All @@ -170,15 +171,15 @@ impl Write for Print {
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
unsafe { libc::printf("shi1\n\0".as_ptr() as _) };
let msg = info.message().unwrap();
let msg = info.message();
let mut buf = Print::new();
write(&mut buf, *msg).unwrap();
write!(&mut buf, "{}", msg).unwrap();
buf.print();
intrinsics::abort()
abort()
}

#[alloc_error_handler]
fn alloc_error(_layout: Layout) -> ! {
unsafe { libc::printf("alloc shi1\n\0".as_ptr() as _) };
intrinsics::abort()
abort()
}
3 changes: 3 additions & 0 deletions secp256k1-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ recovery = []
lowmemory = []
std = ["alloc"]
alloc = []

[lints.rust]
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(bench)', 'cfg(secp256k1_fuzz)', 'cfg(rust_secp_no_symbol_renaming)'] }
3 changes: 1 addition & 2 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,9 @@ impl PublicKey {
/// # }
/// ```
pub fn combine_keys(keys: &[&PublicKey]) -> Result<PublicKey, Error> {
use core::i32::MAX;
use core::mem::transmute;

if keys.is_empty() || keys.len() > MAX as usize {
if keys.is_empty() || keys.len() > i32::MAX as usize {
return Err(InvalidPublicKeySum);
}

Expand Down
Loading