mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Removed SubscriptionUpdate and SubscriptionAck.
This commit is contained in:
@@ -22,16 +22,12 @@ import org.briarproject.api.messaging.MessagingConstants;
|
||||
import org.briarproject.api.messaging.PrivateMessage;
|
||||
import org.briarproject.api.messaging.PrivateMessageFactory;
|
||||
import org.briarproject.api.sync.Ack;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupFactory;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.briarproject.api.sync.Offer;
|
||||
import org.briarproject.api.sync.PacketWriter;
|
||||
import org.briarproject.api.sync.PacketWriterFactory;
|
||||
import org.briarproject.api.sync.Request;
|
||||
import org.briarproject.api.sync.SubscriptionUpdate;
|
||||
import org.briarproject.contact.ContactModule;
|
||||
import org.briarproject.crypto.CryptoModule;
|
||||
import org.briarproject.data.DataModule;
|
||||
@@ -52,9 +48,7 @@ import static org.briarproject.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENG
|
||||
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||
import static org.briarproject.api.identity.AuthorConstants.MAX_SIGNATURE_LENGTH;
|
||||
import static org.briarproject.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_BODY_LENGTH;
|
||||
import static org.briarproject.api.sync.SyncConstants.MAX_GROUP_DESCRIPTOR_LENGTH;
|
||||
import static org.briarproject.api.sync.SyncConstants.MAX_PACKET_PAYLOAD_LENGTH;
|
||||
import static org.briarproject.api.sync.SyncConstants.MAX_SUBSCRIPTIONS;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ConstantsTest extends BriarTestCase {
|
||||
@@ -62,7 +56,6 @@ public class ConstantsTest extends BriarTestCase {
|
||||
// TODO: Break this up into tests that are relevant for each package
|
||||
|
||||
private final CryptoComponent crypto;
|
||||
private final GroupFactory groupFactory;
|
||||
private final AuthorFactory authorFactory;
|
||||
private final PrivateMessageFactory privateMessageFactory;
|
||||
private final ForumPostFactory forumPostFactory;
|
||||
@@ -75,7 +68,6 @@ public class ConstantsTest extends BriarTestCase {
|
||||
new DataModule(), new EventModule(), new ForumModule(),
|
||||
new IdentityModule(), new MessagingModule(), new SyncModule());
|
||||
crypto = i.getInstance(CryptoComponent.class);
|
||||
groupFactory = i.getInstance(GroupFactory.class);
|
||||
authorFactory = i.getInstance(AuthorFactory.class);
|
||||
privateMessageFactory = i.getInstance(PrivateMessageFactory.class);
|
||||
forumPostFactory = i.getInstance(ForumPostFactory.class);
|
||||
@@ -188,27 +180,6 @@ public class ConstantsTest extends BriarTestCase {
|
||||
testMessageIdsFitIntoRequest(1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroupsFitIntoSubscriptionUpdate() throws Exception {
|
||||
// Create the maximum number of maximum-length groups
|
||||
Random random = new Random();
|
||||
ClientId clientId = new ClientId(TestUtils.getRandomId());
|
||||
Collection<Group> groups = new ArrayList<Group>();
|
||||
for (int i = 0; i < MAX_SUBSCRIPTIONS; i++) {
|
||||
byte[] descriptor = new byte[MAX_GROUP_DESCRIPTOR_LENGTH];
|
||||
random.nextBytes(descriptor);
|
||||
groups.add(groupFactory.createGroup(clientId, descriptor));
|
||||
}
|
||||
// Create a maximum-length subscription update
|
||||
SubscriptionUpdate u = new SubscriptionUpdate(groups, Long.MAX_VALUE);
|
||||
// Serialise the update
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
PacketWriter writer = packetWriterFactory.createPacketWriter(out);
|
||||
writer.writeSubscriptionUpdate(u);
|
||||
// Check the size of the serialised subscription update
|
||||
assertTrue(out.size() <= MAX_PACKET_PAYLOAD_LENGTH);
|
||||
}
|
||||
|
||||
private void testMessageIdsFitIntoAck(int length) throws Exception {
|
||||
// Create an ack with as many message IDs as possible
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(length);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
public void testFormatExceptionIfAckIsTooLarge() throws Exception {
|
||||
byte[] b = createAck(true);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, null, null, in);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, in);
|
||||
reader.readAck();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
public void testNoFormatExceptionIfAckIsMaximumSize() throws Exception {
|
||||
byte[] b = createAck(false);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, null, null, in);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, in);
|
||||
reader.readAck();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
public void testEmptyAck() throws Exception {
|
||||
byte[] b = createEmptyAck();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, null, null, in);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, in);
|
||||
reader.readAck();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
public void testFormatExceptionIfOfferIsTooLarge() throws Exception {
|
||||
byte[] b = createOffer(true);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, null, null, in);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, in);
|
||||
reader.readOffer();
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
public void testNoFormatExceptionIfOfferIsMaximumSize() throws Exception {
|
||||
byte[] b = createOffer(false);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, null, null, in);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, in);
|
||||
reader.readOffer();
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
public void testEmptyOffer() throws Exception {
|
||||
byte[] b = createEmptyOffer();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, null, null, in);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, in);
|
||||
reader.readOffer();
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
public void testFormatExceptionIfRequestIsTooLarge() throws Exception {
|
||||
byte[] b = createRequest(true);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, null, null, in);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, in);
|
||||
reader.readRequest();
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
public void testNoFormatExceptionIfRequestIsMaximumSize() throws Exception {
|
||||
byte[] b = createRequest(false);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, null, null, in);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, in);
|
||||
reader.readRequest();
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class PacketReaderImplTest extends BriarTestCase {
|
||||
public void testEmptyRequest() throws Exception {
|
||||
byte[] b = createEmptyRequest();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(b);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, null, null, in);
|
||||
PacketReaderImpl reader = new PacketReaderImpl(null, in);
|
||||
reader.readRequest();
|
||||
}
|
||||
|
||||
|
||||
@@ -52,12 +52,6 @@ public class SimplexOutgoingSessionTest extends BriarTestCase {
|
||||
context.checking(new Expectations() {{
|
||||
// Add listener
|
||||
oneOf(eventBus).addListener(session);
|
||||
// No subscription ack to send
|
||||
oneOf(db).generateSubscriptionAck(contactId);
|
||||
will(returnValue(null));
|
||||
// No subscription update to send
|
||||
oneOf(db).generateSubscriptionUpdate(contactId, maxLatency);
|
||||
will(returnValue(null));
|
||||
// No acks to send
|
||||
oneOf(packetWriter).getMaxMessagesForAck(with(any(long.class)));
|
||||
will(returnValue(MAX_MESSAGES_PER_ACK));
|
||||
@@ -86,12 +80,6 @@ public class SimplexOutgoingSessionTest extends BriarTestCase {
|
||||
context.checking(new Expectations() {{
|
||||
// Add listener
|
||||
oneOf(eventBus).addListener(session);
|
||||
// No subscription ack to send
|
||||
oneOf(db).generateSubscriptionAck(contactId);
|
||||
will(returnValue(null));
|
||||
// No subscription update to send
|
||||
oneOf(db).generateSubscriptionUpdate(contactId, maxLatency);
|
||||
will(returnValue(null));
|
||||
// One ack to send
|
||||
oneOf(packetWriter).getMaxMessagesForAck(with(any(long.class)));
|
||||
will(returnValue(MAX_MESSAGES_PER_ACK));
|
||||
|
||||
Reference in New Issue
Block a user