On Friday 07 November 2008 18:28, [EMAIL PROTECTED] wrote: > Author: j16sdiz > Date: 2008-11-07 18:28:00 +0000 (Fri, 07 Nov 2008) > New Revision: 23380 > > Added: > trunk/freenet/test/freenet/crypt/MockRandomSource.java > Modified: > trunk/freenet/test/freenet/support/BloomFilterTest.java > trunk/freenet/test/freenet/support/io/PaddedEphemerallyEncryptedBucketTest.java > trunk/freenet/test/freenet/support/io/TempBucketTest.java > trunk/freenet/test/freenet/support/io/TempFileBucketTest.java > Log: > use java.util.Random for unit test > > Added: trunk/freenet/test/freenet/crypt/MockRandomSource.java > =================================================================== > --- trunk/freenet/test/freenet/crypt/MockRandomSource.java > (rev 0) > +++ trunk/freenet/test/freenet/crypt/MockRandomSource.java 2008-11-07 18:28:00 UTC (rev 23380) > @@ -0,0 +1,35 @@ > +/* This code is part of Freenet. It is distributed under the GNU General > + * Public License, version 2 (or at your option any later version). See > + * http://www.gnu.org/ for further details of the GPL. */ > +package freenet.crypt; > + > +/** > + * A fake StrongPRNG that is just java.util.Random
You mean like DummyRandomSource? ;)
> + *
> + * @author sdiz
> + */
> +public class MockRandomSource extends RandomSource {
> + @Override
> + public int acceptEntropy(EntropySource source, long data, int
entropyGuess) {
> + return 0;
> + }
> +
> + @Override
> + public int acceptEntropyBytes(EntropySource myPacketDataSource, byte[]
buf, int offset, int length, double bias) {
> + return 0;
> + }
> +
> + @Override
> + public int acceptTimerEntropy(EntropySource timer) {
> + return 0;
> + }
> +
> + @Override
> + public int acceptTimerEntropy(EntropySource fnpTimingSource, double
> bias)
{
> + return 0;
> + }
> +
> + @Override
> + public void close() {
> + }
> +}
>
> Modified: trunk/freenet/test/freenet/support/BloomFilterTest.java
> ===================================================================
> --- trunk/freenet/test/freenet/support/BloomFilterTest.java 2008-11-07
17:19:49 UTC (rev 23379)
> +++ trunk/freenet/test/freenet/support/BloomFilterTest.java 2008-11-07
18:28:00 UTC (rev 23380)
> @@ -8,8 +8,6 @@
>
> import junit.framework.TestCase;
>
> -import org.spaceroots.mantissa.random.MersenneTwister;
> -
> public class BloomFilterTest extends TestCase {
> private static final int FILTER_SIZE = 4 * 1024; // MUST be > PASS,
> private static final int PASS = 2048;
> @@ -17,7 +15,7 @@
> private static final int PASS_POS = 256;
> private static final int PASS_FALSE = 8192;
>
> - private final Random rand = new MersenneTwister();
> + private final Random rand = new Random();
MersenneTwister is actually faster than Random.
>
> private void _testFilterPositive(BloomFilter filter) {
> byte[][] list = new byte[PASS_POS][];
>
pgpTzci2hI29y.pgp
Description: PGP signature
_______________________________________________ Devl mailing list [email protected] http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
