From 9104bd73048dffb4bcbb2d42f11ac1b5a24d7f40 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Fri, 14 Nov 2014 16:44:04 +0000 Subject: [PATCH] Tests: Copy the new EdDSA test vectors to where the classloader can find them. Throw a better error message if not found. --- core/java/build.xml | 12 +++++++++++- .../crypto/eddsa/math/PrecomputationTestVectors.java | 7 +++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/core/java/build.xml b/core/java/build.xml index a14377de7f..df743ddc16 100644 --- a/core/java/build.xml +++ b/core/java/build.xml @@ -125,6 +125,13 @@ </classpath> <compilerarg line="${javac.compilerargs}" /> </javac> + <!-- EdDSA test vectors --> + <copy todir="./build/obj"> + <fileset dir="./test/junit/"> + <include name="net/i2p/crypto/eddsa/math/baseDblPrecmp"/> + <include name="net/i2p/crypto/eddsa/math/basePrecmp"/> + </fileset> + </copy> </target> <!-- jars with tests --> <target name="jarScalaTest" depends="scalatest.compileTest"> @@ -144,7 +151,10 @@ <jar destfile="./build/i2pscalatest.jar" basedir="./build/obj_scala_jar" includes="**/*.class" /> </target> <target name="jarTest" depends="junit.compileTest"> - <jar destfile="./build/i2ptest.jar" basedir="./build/obj" includes="**/*.class" /> + <!-- warning - The junit.test target below doesn't actually include i2ptest.jar in the classpath, + only the build/obj directory. + --> + <jar destfile="./build/i2ptest.jar" basedir="./build/obj" includes="**/*.class **/baseDblPrecmp **/basePrecmp" /> </target> <!-- preparation of code coverage tool of choice --> <target name="prepareClover" depends="compile" if="with.clover"> diff --git a/core/java/test/junit/net/i2p/crypto/eddsa/math/PrecomputationTestVectors.java b/core/java/test/junit/net/i2p/crypto/eddsa/math/PrecomputationTestVectors.java index 7a49eeb89c..5ab9d99efa 100644 --- a/core/java/test/junit/net/i2p/crypto/eddsa/math/PrecomputationTestVectors.java +++ b/core/java/test/junit/net/i2p/crypto/eddsa/math/PrecomputationTestVectors.java @@ -2,6 +2,7 @@ package net.i2p.crypto.eddsa.math; import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import net.i2p.crypto.eddsa.Utils; @@ -22,8 +23,10 @@ public class PrecomputationTestVectors { BufferedReader file = null; int row = 0, col = 0; try { - file = new BufferedReader(new InputStreamReader( - PrecomputationTestVectors.class.getResourceAsStream(fileName))); + InputStream is = PrecomputationTestVectors.class.getResourceAsStream(fileName); + if (is == null) + throw new IOException("Resource not found: " + fileName); + file = new BufferedReader(new InputStreamReader(is)); String line; while ((line = file.readLine()) != null) { if (line.equals(" },")) -- GitLab