@Test public void testStatusFloodMessageTest() { StatusFloodMessage<P2PNodeTest> m = new StatusFloodMessage<>(1, 1, 1, 0, 0); network.sendPeers(m, n0); network.run(1); Assert.assertEquals(network.allNodes.size(), count(m)); StatusFloodMessage<P2PNodeTest> mv2 = new StatusFloodMessage<>(1, 2, 1, 0, 0); network.sendPeers(mv2, n0); Assert.assertEquals(mv2, n0.getMsgReceived(m.msgId()).iterator().next()); Assert.assertEquals(m, n1.getMsgReceived(m.msgId()).iterator().next()); network.run(1); Assert.assertEquals(network.allNodes.size(), count(mv2)); Assert.assertEquals(mv2, n0.getMsgReceived(m.msgId()).iterator().next()); Assert.assertEquals(mv2, n1.getMsgReceived(m.msgId()).iterator().next()); StatusFloodMessage<P2PNodeTest> m2 = new StatusFloodMessage<>(2, 1, 1, 0, 0); network.sendPeers(m2, n0); network.run(1); Assert.assertEquals(network.allNodes.size(), count(m2)); Assert.assertEquals(network.allNodes.size(), count(m)); Assert.assertEquals(mv2, n0.getMsgReceived(m.msgId()).iterator().next()); Assert.assertEquals(mv2, n1.getMsgReceived(m.msgId()).iterator().next()); Assert.assertEquals(m2, n0.getMsgReceived(m2.msgId()).iterator().next()); Assert.assertEquals(m2, n1.getMsgReceived(m2.msgId()).iterator().next()); }
public void sendPeers(FloodMessage<TN> msg, TN from) { msg.addToReceived(from); List<TN> dest = new ArrayList<>(from.peers); Collections.shuffle(dest, rd); send(msg, time + 1 + msg.localDelay, from, dest, msg.delayBetweenPeers); }
P2PNetwork extends Network<TN> { public void sendPeers(FloodMessage<TN> msg, TN from) { msg.addToReceived(from); List<TN> dest = new ArrayList<>(from.peers); Collections.shuffle(dest, rd); send(msg, time + 1 + msg.localDelay, from, dest, msg.delayBetweenPeers); } }
P2PNetwork extends Network<TN> { public void sendPeers(FloodMessage<TN> msg, TN from) { msg.addToReceived(from); List<TN> dest = new ArrayList<>(from.peers); Collections.shuffle(dest, rd); send(msg, time + 1 + msg.localDelay, from, dest, msg.delayBetweenPeers); } P2PNetwork(int connectionCount, boolean minimum); }
P2PNetwork extends Network<TN> { public void sendPeers(FloodMessage<TN> msg, TN from) { msg.addToReceived(from); List<TN> dest = new ArrayList<>(from.peers); Collections.shuffle(dest, rd); send(msg, time + 1 + msg.localDelay, from, dest, msg.delayBetweenPeers); } P2PNetwork(int connectionCount, boolean minimum); void setPeers(); void disconnect(TN p); void createLink(TN p1, TN p2); void removeLink(TN p1, TN p2); int avgPeers(); void sendPeers(FloodMessage<TN> msg, TN from); }
P2PNetwork extends Network<TN> { public void sendPeers(FloodMessage<TN> msg, TN from) { msg.addToReceived(from); List<TN> dest = new ArrayList<>(from.peers); Collections.shuffle(dest, rd); send(msg, time + 1 + msg.localDelay, from, dest, msg.delayBetweenPeers); } P2PNetwork(int connectionCount, boolean minimum); void setPeers(); void disconnect(TN p); void createLink(TN p1, TN p2); void removeLink(TN p1, TN p2); int avgPeers(); void sendPeers(FloodMessage<TN> msg, TN from);  }