Merge pull request #258 from thomaseizinger/better-wasm-tests
Run more tests in wasm
This commit is contained in:
commit
b31bf2f611
|
@ -173,6 +173,9 @@ mod tests {
|
||||||
use super::SharedSecret;
|
use super::SharedSecret;
|
||||||
use super::super::Secp256k1;
|
use super::super::Secp256k1;
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
use wasm_bindgen_test::wasm_bindgen_test as test;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ecdh() {
|
fn ecdh() {
|
||||||
let s = Secp256k1::signing_only();
|
let s = Secp256k1::signing_only();
|
||||||
|
|
|
@ -429,6 +429,9 @@ mod test {
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
use wasm_bindgen_test::wasm_bindgen_test as test;
|
||||||
|
|
||||||
macro_rules! hex {
|
macro_rules! hex {
|
||||||
($hex:expr) => ({
|
($hex:expr) => ({
|
||||||
let mut result = vec![0; $hex.len() / 2];
|
let mut result = vec![0; $hex.len() / 2];
|
||||||
|
|
32
src/lib.rs
32
src/lib.rs
|
@ -133,6 +133,7 @@ pub use secp256k1_sys as ffi;
|
||||||
#[cfg(all(test, feature = "serde"))] extern crate serde_test;
|
#[cfg(all(test, feature = "serde"))] extern crate serde_test;
|
||||||
#[cfg(any(test, feature = "rand"))] use rand::Rng;
|
#[cfg(any(test, feature = "rand"))] use rand::Rng;
|
||||||
#[cfg(any(test, feature = "std"))] extern crate core;
|
#[cfg(any(test, feature = "std"))] extern crate core;
|
||||||
|
#[cfg(all(test, target_arch = "wasm32"))] extern crate wasm_bindgen_test;
|
||||||
|
|
||||||
use core::{fmt, ptr, str};
|
use core::{fmt, ptr, str};
|
||||||
|
|
||||||
|
@ -770,6 +771,9 @@ mod tests {
|
||||||
use ffi::{self, types::AlignedType};
|
use ffi::{self, types::AlignedType};
|
||||||
use context::*;
|
use context::*;
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
use wasm_bindgen_test::wasm_bindgen_test as test;
|
||||||
|
|
||||||
macro_rules! hex {
|
macro_rules! hex {
|
||||||
($hex:expr) => ({
|
($hex:expr) => ({
|
||||||
let mut result = vec![0; $hex.len() / 2];
|
let mut result = vec![0; $hex.len() / 2];
|
||||||
|
@ -840,6 +844,7 @@ mod tests {
|
||||||
drop(ctx_vrfy);
|
drop(ctx_vrfy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn test_panic_raw_ctx() {
|
fn test_panic_raw_ctx() {
|
||||||
|
@ -1134,33 +1139,6 @@ mod tests {
|
||||||
assert!(SECP256K1.verify(&msg, &sig, &pk).is_ok());
|
assert!(SECP256K1.verify(&msg, &sig, &pk).is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
// For WASM, just run through our general tests in this file all at once.
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
extern crate wasm_bindgen_test;
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
use self::wasm_bindgen_test::*;
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
#[wasm_bindgen_test]
|
|
||||||
fn stuff() {
|
|
||||||
test_manual_create_destroy();
|
|
||||||
test_raw_ctx();
|
|
||||||
// Note that, sadly, WASM doesn't currently properly unwind panics, so use of the library
|
|
||||||
// via unsafe primitives may cause abort() instead of catch-able panics.
|
|
||||||
/*assert!(std::panic::catch_unwind(|| {
|
|
||||||
test_panic_raw_ctx();
|
|
||||||
}).is_err());*/
|
|
||||||
test_preallocation();
|
|
||||||
capabilities();
|
|
||||||
signature_serialize_roundtrip();
|
|
||||||
signature_display();
|
|
||||||
signature_lax_der();
|
|
||||||
sign_and_verify();
|
|
||||||
sign_and_verify_extreme();
|
|
||||||
sign_and_verify_fail();
|
|
||||||
test_bad_slice();
|
|
||||||
test_low_s();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "bitcoin_hashes")]
|
#[cfg(feature = "bitcoin_hashes")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_from_hash() {
|
fn test_from_hash() {
|
||||||
|
|
|
@ -199,6 +199,9 @@ mod tests {
|
||||||
use super::super::{Secp256k1, Message};
|
use super::super::{Secp256k1, Message};
|
||||||
use super::super::Error::{IncorrectSignature, InvalidSignature};
|
use super::super::Error::{IncorrectSignature, InvalidSignature};
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
use wasm_bindgen_test::wasm_bindgen_test as test;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn capabilities() {
|
fn capabilities() {
|
||||||
let sign = Secp256k1::signing_only();
|
let sign = Secp256k1::signing_only();
|
||||||
|
|
|
@ -500,6 +500,9 @@ mod tests {
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
use wasm_bindgen_test::wasm_bindgen_test as test;
|
||||||
|
|
||||||
macro_rules! hex_32 {
|
macro_rules! hex_32 {
|
||||||
($hex:expr) => {{
|
($hex:expr) => {{
|
||||||
let mut result = [0; 32];
|
let mut result = [0; 32];
|
||||||
|
|
Loading…
Reference in New Issue