diff --git a/.travis.yml b/.travis.yml index 1fd3c43..5a712bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,25 @@ language: rust +matrix: + include: + - rust: stable + - rust: beta + - rust: nightly + install: - git clone https://github.com/bitcoin/secp256k1.git - cd secp256k1 - ./autogen.sh && ./configure && make && sudo make install - sudo ldconfig /usr/local/lib + - cd .. + - | + pip install 'travis-cargo<0.2' --user && + export PATH=$HOME/.local/bin:$PATH + +script: + - | + travis-cargo build && + travis-cargo test && + travis-cargo bench && + travis-cargo --only stable doc diff --git a/Cargo.toml b/Cargo.toml index aabbdfe..fadea7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,9 @@ readme = "README.md" name = "secp256k1" path = "src/lib.rs" +[features] +unstable = [] + [dependencies] arrayvec = "0.3" rand = "0.3" diff --git a/src/ffi.rs b/src/ffi.rs index f151db3..c24cb33 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -34,7 +34,7 @@ pub type NonceFn = unsafe extern "C" fn(nonce32: *mut c_uchar, attempt: c_uint, data: *const c_void); -#[repr(C)] struct ContextInner; +#[repr(C)] struct ContextInner(c_int); /// A Secp256k1 context, containing various precomputed values and such /// needed to do elliptic curve computations. If you create one of these diff --git a/src/lib.rs b/src/lib.rs index db4db2a..825d785 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,9 +25,6 @@ #![crate_type = "dylib"] #![crate_name = "secp256k1"] -// Keep this until 1.0 I guess; it's needed for `black_box` at least -#![cfg_attr(test, feature(test))] - // Coding conventions #![deny(non_upper_case_globals)] #![deny(non_camel_case_types)] @@ -35,10 +32,12 @@ #![deny(unused_mut)] #![warn(missing_docs)] +#![cfg_attr(all(test, feature = "unstable"), feature(test))] +#[cfg(all(test, feature = "unstable"))] extern crate test; + extern crate arrayvec; extern crate rustc_serialize as serialize; extern crate serde; -#[cfg(test)] extern crate test; extern crate libc; extern crate rand; @@ -369,8 +368,6 @@ impl Secp256k1 { mod tests { use rand::{Rng, thread_rng}; - use test::{Bencher, black_box}; - use key::{SecretKey, PublicKey}; use super::constants; use super::{Secp256k1, Signature, Message, RecoveryId, ContextFlag}; @@ -614,6 +611,14 @@ mod tests { 25, 26, 27, 28, 29, 30, 31, 255]); assert_eq!(&format!("{:?}", msg), "Message(0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff)"); } +} + +#[cfg(all(test, feature = "unstable"))] +mod benches { + use rand::{Rng, thread_rng}; + use test::{Bencher, black_box}; + + use super::{Secp256k1, Message}; #[bench] pub fn generate(bh: &mut Bencher) {