diff --git a/test/freenet/node/NewPacketFormatTest.java b/test/freenet/node/NewPacketFormatTest.java index 6bf4d34c42..a2ca6d5983 100644 --- a/test/freenet/node/NewPacketFormatTest.java +++ b/test/freenet/node/NewPacketFormatTest.java @@ -15,6 +15,7 @@ import org.junit.Test; import freenet.crypt.BlockCipher; +import freenet.crypt.DummyRandomSource; import freenet.crypt.ciphers.Rijndael; import freenet.io.comm.DMT; import freenet.io.comm.FreenetInetAddress; @@ -33,7 +34,7 @@ public void setUp() { @Test public void testEmptyCreation() throws BlockedTooLongException { NewPacketFormat npf = new NewPacketFormat(null, 0, 0); - PeerMessageQueue pmq = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue pmq = new PeerMessageQueue(new DummyRandomSource(1234)); SessionKey s = new SessionKey(null, null, null, null, null, null, null, null, new NewPacketFormatKeyContext(0, 0), 1); NPFPacket p = npf.createPacket(1400, pmq, s, false); @@ -44,7 +45,7 @@ public void testEmptyCreation() throws BlockedTooLongException { public void testAckOnlyCreation() throws BlockedTooLongException, InterruptedException { BasePeerNode pn = new NullBasePeerNode(); NewPacketFormat npf = new NewPacketFormat(pn, 0, 0); - PeerMessageQueue pmq = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue pmq = new PeerMessageQueue(new DummyRandomSource(1234)); SessionKey s = new SessionKey(null, null, null, null, null, null, null, null, new NewPacketFormatKeyContext(0, 0), 1); NPFPacket p = null; @@ -65,10 +66,10 @@ public void testAckOnlyCreation() throws BlockedTooLongException, InterruptedExc public void testLostLastAck() throws BlockedTooLongException, InterruptedException { NullBasePeerNode senderNode = new NullBasePeerNode(); NewPacketFormat sender = new NewPacketFormat(senderNode, 0, 0); - PeerMessageQueue senderQueue = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue senderQueue = new PeerMessageQueue(new DummyRandomSource(1234)); NullBasePeerNode receiverNode = new NullBasePeerNode(); NewPacketFormat receiver = new NewPacketFormat(receiverNode, 0, 0); - PeerMessageQueue receiverQueue = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue receiverQueue = new PeerMessageQueue(new DummyRandomSource(1234)); SessionKey senderKey = new SessionKey(null, null, null, null, null, null, null, null, new NewPacketFormatKeyContext(0, 0), 1); senderNode.currentKey = senderKey; SessionKey receiverKey = new SessionKey(null, null, null, null, null, null, null, null, new NewPacketFormatKeyContext(0, 0), 1); @@ -116,7 +117,7 @@ public void testLostLastAck() throws BlockedTooLongException, InterruptedExcepti public void testOutOfOrderDelivery() throws BlockedTooLongException { NullBasePeerNode senderNode = new NullBasePeerNode(); NewPacketFormat sender = new NewPacketFormat(senderNode, 0, 0); - PeerMessageQueue senderQueue = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue senderQueue = new PeerMessageQueue(new DummyRandomSource(1234)); NullBasePeerNode receiverNode = new NullBasePeerNode(); NewPacketFormat receiver = new NewPacketFormat(receiverNode, 0, 0); SessionKey senderKey = new SessionKey(null, null, null, null, null, null, null, null, new NewPacketFormatKeyContext(0, 0), 1); @@ -142,7 +143,7 @@ public void testOutOfOrderDelivery() throws BlockedTooLongException { public void testReceiveUnknownMessageLength() throws BlockedTooLongException { NullBasePeerNode senderNode = new NullBasePeerNode(); NewPacketFormat sender = new NewPacketFormat(senderNode, 0, 0); - PeerMessageQueue senderQueue = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue senderQueue = new PeerMessageQueue(new DummyRandomSource(1234)); NullBasePeerNode receiverNode = new NullBasePeerNode(); NewPacketFormat receiver = new NewPacketFormat(receiverNode, 0, 0); SessionKey senderKey = new SessionKey(null, null, null, null, null, null, null, null, new NewPacketFormatKeyContext(0, 0), 1); @@ -166,7 +167,7 @@ public void testReceiveUnknownMessageLength() throws BlockedTooLongException { public void testResendAlreadyCompleted() throws BlockedTooLongException, InterruptedException { NullBasePeerNode senderNode = new NullBasePeerNode(); NewPacketFormat sender = new NewPacketFormat(senderNode, 0, 0); - PeerMessageQueue senderQueue = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue senderQueue = new PeerMessageQueue(new DummyRandomSource(1234)); NullBasePeerNode receiverNode = new NullBasePeerNode(); NewPacketFormat receiver = new NewPacketFormat(receiverNode, 0, 0); SessionKey senderKey = new SessionKey(null, null, null, null, null, null, null, null, new NewPacketFormatKeyContext(0, 0), 1); @@ -219,7 +220,7 @@ public SessionKey getCurrentKeyTracker() { }; NewPacketFormat sender = new NewPacketFormat(senderNode, 0, 0); - PeerMessageQueue senderQueue = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue senderQueue = new PeerMessageQueue(new DummyRandomSource(1234)); NullBasePeerNode receiverNode = new NullBasePeerNode() { @Override @@ -284,7 +285,7 @@ public SessionKey getCurrentKeyTracker() { }; NewPacketFormat sender = new NewPacketFormat(senderNode, 0, 0); - PeerMessageQueue senderQueue = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue senderQueue = new PeerMessageQueue(new DummyRandomSource(1234)); senderQueue.queueAndEstimateSize(new MessageItem(new byte[128], null, false, null, (short) 0, false, true), 1024); @@ -319,7 +320,7 @@ public void handleMessage(Message msg) { }; NewPacketFormat sender = new NewPacketFormat(senderNode, 0, 0); - PeerMessageQueue senderQueue = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue senderQueue = new PeerMessageQueue(new DummyRandomSource(1234)); NullBasePeerNode receiverNode = new NullBasePeerNode() { @Override @@ -434,7 +435,7 @@ public void testEncryption() receiverNPF = new NewPacketFormat(receiverNode, receiverStartSeq, senderStartSeq); - PeerMessageQueue senderQueue = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue senderQueue = new PeerMessageQueue(new DummyRandomSource(1234)); byte[] message = new byte[1024]; random.nextBytes(message); diff --git a/test/freenet/node/PeerMessageQueueTest.java b/test/freenet/node/PeerMessageQueueTest.java index c434b09f6f..eccbc2701f 100644 --- a/test/freenet/node/PeerMessageQueueTest.java +++ b/test/freenet/node/PeerMessageQueueTest.java @@ -7,16 +7,18 @@ import org.junit.Test; +import freenet.crypt.DummyRandomSource; + public class PeerMessageQueueTest { @Test public void testUrgentTimeEmpty() { - PeerMessageQueue pmq = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue pmq = new PeerMessageQueue(new DummyRandomSource(1234)); assertEquals(Long.MAX_VALUE, pmq.getNextUrgentTime(Long.MAX_VALUE, System.currentTimeMillis())); } @Test public void testUrgentTime() { - PeerMessageQueue pmq = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue pmq = new PeerMessageQueue(new DummyRandomSource(1234)); //Constructor might take some time, so grab a range long start = System.currentTimeMillis(); @@ -37,7 +39,7 @@ public void testUrgentTime() { * it. */ @Test public void testUrgentTimeQueuedWrong() { - PeerMessageQueue pmq = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue pmq = new PeerMessageQueue(new DummyRandomSource(1234)); //Constructor might take some time, so grab a range long start = System.currentTimeMillis(); @@ -67,7 +69,7 @@ public void testUrgentTimeQueuedWrong() { @Test public void testGrabQueuedMessageItem() { - PeerMessageQueue pmq = new PeerMessageQueue(new MersenneTwister(new byte[16])); + PeerMessageQueue pmq = new PeerMessageQueue(new DummyRandomSource(1234)); MessageItem itemUrgent = new MessageItem(new byte[1024], null, false, null, (short) 0, false, false);