Limit long-running tests via #[ignore] instead of commenting them out.
This commit is contained in:
@@ -147,6 +147,137 @@ point_impl!(P256, I256, I512, U512, I576, U576);
|
||||
point_impl!(P384, I384, I768, U768, I832, U832);
|
||||
point_impl!(P521, I576, I1152, U1152, I1216, U1216);
|
||||
|
||||
#[cfg(test)]
|
||||
macro_rules! negate_test_body
|
||||
{
|
||||
($curve: ident, $lcurve: ident, $stype: ident, $utype: ident) => {
|
||||
let fname = build_test_path("ecc/negate",stringify!($curve));
|
||||
run_test(fname.to_string(), 4, |case| {
|
||||
let (negx, xbytes) = case.get("x").unwrap();
|
||||
let (negy, ybytes) = case.get("y").unwrap();
|
||||
let (nega, abytes) = case.get("a").unwrap();
|
||||
let (negb, bbytes) = case.get("b").unwrap();
|
||||
|
||||
let x = $stype::new(*negx, $utype::from_bytes(xbytes));
|
||||
let y = $stype::new(*negy, $utype::from_bytes(ybytes));
|
||||
let a = $stype::new(*nega, $utype::from_bytes(abytes));
|
||||
let b = $stype::new(*negb, $utype::from_bytes(bbytes));
|
||||
let point = Point::<$curve>{ x, y };
|
||||
let dbl = point.negate();
|
||||
assert_eq!(a, dbl.x, "x equivalence");
|
||||
assert_eq!(b, dbl.y, "y equivalence");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
macro_rules! double_test_body
|
||||
{
|
||||
($curve: ident, $lcurve: ident, $stype: ident, $utype: ident) => {
|
||||
let fname = build_test_path("ecc/double",stringify!($curve));
|
||||
run_test(fname.to_string(), 4, |case| {
|
||||
let (negx, xbytes) = case.get("x").unwrap();
|
||||
let (negy, ybytes) = case.get("y").unwrap();
|
||||
let (nega, abytes) = case.get("a").unwrap();
|
||||
let (negb, bbytes) = case.get("b").unwrap();
|
||||
|
||||
let x = $stype::new(*negx, $utype::from_bytes(xbytes));
|
||||
let y = $stype::new(*negy, $utype::from_bytes(ybytes));
|
||||
let a = $stype::new(*nega, $utype::from_bytes(abytes));
|
||||
let b = $stype::new(*negb, $utype::from_bytes(bbytes));
|
||||
let point = Point::<$curve>{ x, y };
|
||||
let dbl = point.double();
|
||||
assert_eq!(a, dbl.x, "x equivalence");
|
||||
assert_eq!(b, dbl.y, "y equivalence");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
macro_rules! add_test_body
|
||||
{
|
||||
($curve: ident, $lcurve: ident, $stype: ident, $utype: ident) => {
|
||||
let fname = build_test_path("ecc/add",stringify!($curve));
|
||||
run_test(fname.to_string(), 6, move |case| {
|
||||
let (negx, xbytes) = case.get("x").unwrap();
|
||||
let (negy, ybytes) = case.get("y").unwrap();
|
||||
let (negu, ubytes) = case.get("u").unwrap();
|
||||
let (negv, vbytes) = case.get("v").unwrap();
|
||||
let (nega, abytes) = case.get("a").unwrap();
|
||||
let (negb, bbytes) = case.get("b").unwrap();
|
||||
|
||||
let x = $stype::new(*negx, $utype::from_bytes(xbytes));
|
||||
let y = $stype::new(*negy, $utype::from_bytes(ybytes));
|
||||
let u = $stype::new(*negu, $utype::from_bytes(ubytes));
|
||||
let v = $stype::new(*negv, $utype::from_bytes(vbytes));
|
||||
let a = $stype::new(*nega, $utype::from_bytes(abytes));
|
||||
let b = $stype::new(*negb, $utype::from_bytes(bbytes));
|
||||
let point1 = Point::<$curve>{ x: x, y: y };
|
||||
let point2 = Point::<$curve>{ x: u, y: v };
|
||||
let res = point1.add(&point2);
|
||||
assert_eq!(a, res.x, "x equivalence");
|
||||
assert_eq!(b, res.y, "y equivalence");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
macro_rules! scale_test_body
|
||||
{
|
||||
($curve: ident, $lcurve: ident, $stype: ident, $utype: ident) => {
|
||||
let fname = build_test_path("ecc/scale",stringify!($curve));
|
||||
run_test(fname.to_string(), 5, |case| {
|
||||
let (negx, xbytes) = case.get("x").unwrap();
|
||||
let (negy, ybytes) = case.get("y").unwrap();
|
||||
let (negk, kbytes) = case.get("k").unwrap();
|
||||
let (nega, abytes) = case.get("a").unwrap();
|
||||
let (negb, bbytes) = case.get("b").unwrap();
|
||||
|
||||
let x = $stype::new(*negx, $utype::from_bytes(xbytes));
|
||||
let y = $stype::new(*negy, $utype::from_bytes(ybytes));
|
||||
let k = $stype::new(*negk, $utype::from_bytes(kbytes));
|
||||
let a = $stype::new(*nega, $utype::from_bytes(abytes));
|
||||
let b = $stype::new(*negb, $utype::from_bytes(bbytes));
|
||||
let point = Point::<$curve>{ x: x, y: y };
|
||||
let res = point.scale(&k);
|
||||
assert_eq!(a, res.x, "x equivalence");
|
||||
assert_eq!(b, res.y, "y equivalence");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
macro_rules! add_scale2_test_body
|
||||
{
|
||||
($curve: ident, $lcurve: ident, $stype: ident, $utype: ident) => {
|
||||
let fname = build_test_path("ecc/add_scale2",stringify!($curve));
|
||||
run_test(fname.to_string(), 8, |case| {
|
||||
let (negx, xbytes) = case.get("x").unwrap();
|
||||
let (negy, ybytes) = case.get("y").unwrap();
|
||||
let (negp, pbytes) = case.get("p").unwrap();
|
||||
let (negq, qbytes) = case.get("q").unwrap();
|
||||
let (negn, nbytes) = case.get("n").unwrap();
|
||||
let (negm, mbytes) = case.get("m").unwrap();
|
||||
let (negr, rbytes) = case.get("r").unwrap();
|
||||
let (negs, sbytes) = case.get("s").unwrap();
|
||||
|
||||
let x = $stype::new(*negx, $utype::from_bytes(xbytes));
|
||||
let y = $stype::new(*negy, $utype::from_bytes(ybytes));
|
||||
let p = $stype::new(*negp, $utype::from_bytes(pbytes));
|
||||
let q = $stype::new(*negq, $utype::from_bytes(qbytes));
|
||||
let n = $stype::new(*negn, $utype::from_bytes(nbytes));
|
||||
let m = $stype::new(*negm, $utype::from_bytes(mbytes));
|
||||
let r = $stype::new(*negr, $utype::from_bytes(rbytes));
|
||||
let s = $stype::new(*negs, $utype::from_bytes(sbytes));
|
||||
let p1 = Point::<$curve>{ x: x, y: y };
|
||||
let p2 = Point::<$curve>{ x: p, y: q };
|
||||
let res = Point::<$curve>::double_scalar_mult(&n, &p1, &m, &p2);
|
||||
assert_eq!(r, res.x, "x equivalence");
|
||||
assert_eq!(s, res.y, "y equivalence");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! point_tests
|
||||
{
|
||||
($curve: ident, $lcurve: ident, $stype: ident, $utype: ident) => {
|
||||
@@ -156,127 +287,42 @@ macro_rules! point_tests
|
||||
use testing::*;
|
||||
|
||||
#[test]
|
||||
fn negate() {
|
||||
let fname = build_test_path("ecc/negate",stringify!($curve));
|
||||
run_test(fname.to_string(), 4, |case| {
|
||||
let (negx, xbytes) = case.get("x").unwrap();
|
||||
let (negy, ybytes) = case.get("y").unwrap();
|
||||
let (nega, abytes) = case.get("a").unwrap();
|
||||
let (negb, bbytes) = case.get("b").unwrap();
|
||||
|
||||
let x = $stype::new(*negx, $utype::from_bytes(xbytes));
|
||||
let y = $stype::new(*negy, $utype::from_bytes(ybytes));
|
||||
let a = $stype::new(*nega, $utype::from_bytes(abytes));
|
||||
let b = $stype::new(*negb, $utype::from_bytes(bbytes));
|
||||
let point = Point::<$curve>{ x, y };
|
||||
let dbl = point.negate();
|
||||
assert_eq!(a, dbl.x, "x equivalence");
|
||||
assert_eq!(b, dbl.y, "y equivalence");
|
||||
});
|
||||
}
|
||||
fn negate() { negate_test_body!($curve, $lcurve, $stype, $utype); }
|
||||
#[test]
|
||||
fn double() { double_test_body!($curve, $lcurve, $stype, $utype); }
|
||||
#[test]
|
||||
fn add() { add_test_body!($curve, $lcurve, $stype, $utype); }
|
||||
#[test]
|
||||
fn scale() { scale_test_body!($curve, $lcurve, $stype, $utype); }
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn add_scale2() { add_scale2_test_body!($curve, $lcurve, $stype, $utype); }
|
||||
}
|
||||
};
|
||||
(ignore_expensive $curve: ident, $lcurve: ident, $stype: ident, $utype: ident) => {
|
||||
#[cfg(test)]
|
||||
mod $lcurve {
|
||||
use super::*;
|
||||
use testing::*;
|
||||
|
||||
#[test]
|
||||
fn double() {
|
||||
let fname = build_test_path("ecc/double",stringify!($curve));
|
||||
run_test(fname.to_string(), 4, |case| {
|
||||
let (negx, xbytes) = case.get("x").unwrap();
|
||||
let (negy, ybytes) = case.get("y").unwrap();
|
||||
let (nega, abytes) = case.get("a").unwrap();
|
||||
let (negb, bbytes) = case.get("b").unwrap();
|
||||
|
||||
let x = $stype::new(*negx, $utype::from_bytes(xbytes));
|
||||
let y = $stype::new(*negy, $utype::from_bytes(ybytes));
|
||||
let a = $stype::new(*nega, $utype::from_bytes(abytes));
|
||||
let b = $stype::new(*negb, $utype::from_bytes(bbytes));
|
||||
let point = Point::<$curve>{ x, y };
|
||||
let dbl = point.double();
|
||||
assert_eq!(a, dbl.x, "x equivalence");
|
||||
assert_eq!(b, dbl.y, "y equivalence");
|
||||
});
|
||||
}
|
||||
|
||||
fn negate() { negate_test_body!($curve, $lcurve, $stype, $utype); }
|
||||
#[test]
|
||||
fn add() {
|
||||
let fname = build_test_path("ecc/add",stringify!($curve));
|
||||
run_test(fname.to_string(), 6, move |case| {
|
||||
let (negx, xbytes) = case.get("x").unwrap();
|
||||
let (negy, ybytes) = case.get("y").unwrap();
|
||||
let (negu, ubytes) = case.get("u").unwrap();
|
||||
let (negv, vbytes) = case.get("v").unwrap();
|
||||
let (nega, abytes) = case.get("a").unwrap();
|
||||
let (negb, bbytes) = case.get("b").unwrap();
|
||||
|
||||
let x = $stype::new(*negx, $utype::from_bytes(xbytes));
|
||||
let y = $stype::new(*negy, $utype::from_bytes(ybytes));
|
||||
let u = $stype::new(*negu, $utype::from_bytes(ubytes));
|
||||
let v = $stype::new(*negv, $utype::from_bytes(vbytes));
|
||||
let a = $stype::new(*nega, $utype::from_bytes(abytes));
|
||||
let b = $stype::new(*negb, $utype::from_bytes(bbytes));
|
||||
let point1 = Point::<$curve>{ x: x, y: y };
|
||||
let point2 = Point::<$curve>{ x: u, y: v };
|
||||
let res = point1.add(&point2);
|
||||
assert_eq!(a, res.x, "x equivalence");
|
||||
assert_eq!(b, res.y, "y equivalence");
|
||||
});
|
||||
}
|
||||
|
||||
fn double() { double_test_body!($curve, $lcurve, $stype, $utype); }
|
||||
#[test]
|
||||
fn scale() {
|
||||
let fname = build_test_path("ecc/scale",stringify!($curve));
|
||||
run_test(fname.to_string(), 5, |case| {
|
||||
let (negx, xbytes) = case.get("x").unwrap();
|
||||
let (negy, ybytes) = case.get("y").unwrap();
|
||||
let (negk, kbytes) = case.get("k").unwrap();
|
||||
let (nega, abytes) = case.get("a").unwrap();
|
||||
let (negb, bbytes) = case.get("b").unwrap();
|
||||
|
||||
let x = $stype::new(*negx, $utype::from_bytes(xbytes));
|
||||
let y = $stype::new(*negy, $utype::from_bytes(ybytes));
|
||||
let k = $stype::new(*negk, $utype::from_bytes(kbytes));
|
||||
let a = $stype::new(*nega, $utype::from_bytes(abytes));
|
||||
let b = $stype::new(*negb, $utype::from_bytes(bbytes));
|
||||
let point = Point::<$curve>{ x: x, y: y };
|
||||
let res = point.scale(&k);
|
||||
assert_eq!(a, res.x, "x equivalence");
|
||||
assert_eq!(b, res.y, "y equivalence");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_scale2() {
|
||||
let fname = build_test_path("ecc/add_scale2",stringify!($curve));
|
||||
run_test(fname.to_string(), 8, |case| {
|
||||
let (negx, xbytes) = case.get("x").unwrap();
|
||||
let (negy, ybytes) = case.get("y").unwrap();
|
||||
let (negp, pbytes) = case.get("p").unwrap();
|
||||
let (negq, qbytes) = case.get("q").unwrap();
|
||||
let (negn, nbytes) = case.get("n").unwrap();
|
||||
let (negm, mbytes) = case.get("m").unwrap();
|
||||
let (negr, rbytes) = case.get("r").unwrap();
|
||||
let (negs, sbytes) = case.get("s").unwrap();
|
||||
|
||||
let x = $stype::new(*negx, $utype::from_bytes(xbytes));
|
||||
let y = $stype::new(*negy, $utype::from_bytes(ybytes));
|
||||
let p = $stype::new(*negp, $utype::from_bytes(pbytes));
|
||||
let q = $stype::new(*negq, $utype::from_bytes(qbytes));
|
||||
let n = $stype::new(*negn, $utype::from_bytes(nbytes));
|
||||
let m = $stype::new(*negm, $utype::from_bytes(mbytes));
|
||||
let r = $stype::new(*negr, $utype::from_bytes(rbytes));
|
||||
let s = $stype::new(*negs, $utype::from_bytes(sbytes));
|
||||
let p1 = Point::<$curve>{ x: x, y: y };
|
||||
let p2 = Point::<$curve>{ x: p, y: q };
|
||||
let res = Point::<$curve>::double_scalar_mult(&n, &p1, &m, &p2);
|
||||
assert_eq!(r, res.x, "x equivalence");
|
||||
assert_eq!(s, res.y, "y equivalence");
|
||||
});
|
||||
}
|
||||
|
||||
fn add() { add_test_body!($curve, $lcurve, $stype, $utype); }
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn scale() { scale_test_body!($curve, $lcurve, $stype, $utype); }
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn add_scale2() { add_scale2_test_body!($curve, $lcurve, $stype, $utype); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
point_tests!(P192, p192, I192, U192);
|
||||
point_tests!(P224, p224, I256, U256);
|
||||
point_tests!(P256, p256, I256, U256);
|
||||
point_tests!(P384, p384, I384, U384);
|
||||
point_tests!(P521, p521, I576, U576);
|
||||
point_tests!(ignore_expensive P224, p224, I256, U256);
|
||||
point_tests!(ignore_expensive P256, p256, I256, U256);
|
||||
point_tests!(ignore_expensive P384, p384, I384, U384);
|
||||
point_tests!(ignore_expensive P521, p521, I576, U576);
|
||||
Reference in New Issue
Block a user