[core] fix wrong order of message status flags in conversation headers

This commit is contained in:
Torsten Grote
2018-11-15 14:39:05 -02:00
parent f4b06e1fb3
commit 3053e3cfa7
23 changed files with 117 additions and 42 deletions

View File

@@ -13,10 +13,10 @@ import javax.annotation.Nullable;
public class BlogInvitationRequest extends InvitationRequest<Blog> { public class BlogInvitationRequest extends InvitationRequest<Blog> {
public BlogInvitationRequest(MessageId id, GroupId groupId, long time, public BlogInvitationRequest(MessageId id, GroupId groupId, long time,
boolean local, boolean sent, boolean seen, boolean read, boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, Blog blog, @Nullable String text, SessionId sessionId, Blog blog, @Nullable String text,
boolean available, boolean canBeOpened) { boolean available, boolean canBeOpened) {
super(id, groupId, time, local, sent, seen, read, sessionId, blog, super(id, groupId, time, local, read, sent, seen, sessionId, blog,
text, available, canBeOpened); text, available, canBeOpened);
} }

View File

@@ -11,9 +11,9 @@ import org.briarproject.briar.api.sharing.InvitationResponse;
public class BlogInvitationResponse extends InvitationResponse { public class BlogInvitationResponse extends InvitationResponse {
public BlogInvitationResponse(MessageId id, GroupId groupId, long time, public BlogInvitationResponse(MessageId id, GroupId groupId, long time,
boolean local, boolean sent, boolean seen, boolean read, boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, boolean accept, GroupId shareableId) { SessionId sessionId, boolean accept, GroupId shareableId) {
super(id, groupId, time, local, sent, seen, read, sessionId, super(id, groupId, time, local, read, sent, seen, sessionId,
accept, shareableId); accept, shareableId);
} }

View File

@@ -21,10 +21,10 @@ public abstract class ConversationRequest<N extends Nameable>
private final boolean answered; private final boolean answered;
public ConversationRequest(MessageId messageId, GroupId groupId, long time, public ConversationRequest(MessageId messageId, GroupId groupId, long time,
boolean local, boolean sent, boolean seen, boolean read, boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, N nameable, @Nullable String text, SessionId sessionId, N nameable, @Nullable String text,
boolean answered) { boolean answered) {
super(messageId, groupId, time, local, sent, seen, read); super(messageId, groupId, time, local, read, sent, seen);
this.sessionId = sessionId; this.sessionId = sessionId;
this.nameable = nameable; this.nameable = nameable;
this.text = text; this.text = text;

View File

@@ -15,9 +15,9 @@ public abstract class ConversationResponse extends ConversationMessageHeader {
private final boolean accepted; private final boolean accepted;
public ConversationResponse(MessageId id, GroupId groupId, long time, public ConversationResponse(MessageId id, GroupId groupId, long time,
boolean local, boolean sent, boolean seen, boolean read, boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, boolean accepted) { SessionId sessionId, boolean accepted) {
super(id, groupId, time, local, sent, seen, read); super(id, groupId, time, local, read, sent, seen);
this.sessionId = sessionId; this.sessionId = sessionId;
this.accepted = accepted; this.accepted = accepted;
} }

View File

@@ -15,10 +15,10 @@ import javax.annotation.concurrent.Immutable;
public class ForumInvitationRequest extends InvitationRequest<Forum> { public class ForumInvitationRequest extends InvitationRequest<Forum> {
public ForumInvitationRequest(MessageId id, GroupId groupId, long time, public ForumInvitationRequest(MessageId id, GroupId groupId, long time,
boolean local, boolean sent, boolean seen, boolean read, boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, Forum forum, @Nullable String text, SessionId sessionId, Forum forum, @Nullable String text,
boolean available, boolean canBeOpened) { boolean available, boolean canBeOpened) {
super(id, groupId, time, local, sent, seen, read, sessionId, forum, super(id, groupId, time, local, read, sent, seen, sessionId, forum,
text, available, canBeOpened); text, available, canBeOpened);
} }

View File

@@ -14,9 +14,9 @@ import javax.annotation.concurrent.Immutable;
public class ForumInvitationResponse extends InvitationResponse { public class ForumInvitationResponse extends InvitationResponse {
public ForumInvitationResponse(MessageId id, GroupId groupId, long time, public ForumInvitationResponse(MessageId id, GroupId groupId, long time,
boolean local, boolean sent, boolean seen, boolean read, boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, boolean accept, GroupId shareableId) { SessionId sessionId, boolean accept, GroupId shareableId) {
super(id, groupId, time, local, sent, seen, read, sessionId, super(id, groupId, time, local, read, sent, seen, sessionId,
accept, shareableId); accept, shareableId);
} }

View File

@@ -19,10 +19,10 @@ public class IntroductionRequest extends ConversationRequest<Author> {
private final AuthorInfo authorInfo; private final AuthorInfo authorInfo;
public IntroductionRequest(MessageId messageId, GroupId groupId, public IntroductionRequest(MessageId messageId, GroupId groupId,
long time, boolean local, boolean sent, boolean seen, boolean read, long time, boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, Author author, @Nullable String text, SessionId sessionId, Author author, @Nullable String text,
boolean answered, AuthorInfo authorInfo) { boolean answered, AuthorInfo authorInfo) {
super(messageId, groupId, time, local, sent, seen, read, sessionId, super(messageId, groupId, time, local, read, sent, seen, sessionId,
author, text, answered); author, text, answered);
this.authorInfo = authorInfo; this.authorInfo = authorInfo;
} }

View File

@@ -22,10 +22,10 @@ public class IntroductionResponse extends ConversationResponse {
private final Role ourRole; private final Role ourRole;
public IntroductionResponse(MessageId messageId, GroupId groupId, long time, public IntroductionResponse(MessageId messageId, GroupId groupId, long time,
boolean local, boolean sent, boolean seen, boolean read, boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, boolean accepted, Author author, SessionId sessionId, boolean accepted, Author author,
AuthorInfo introducedAuthorInfo, Role role) { AuthorInfo introducedAuthorInfo, Role role) {
super(messageId, groupId, time, local, sent, seen, read, sessionId, super(messageId, groupId, time, local, read, sent, seen, sessionId,
accepted); accepted);
this.introducedAuthor = author; this.introducedAuthor = author;
this.introducedAuthorInfo = introducedAuthorInfo; this.introducedAuthorInfo = introducedAuthorInfo;

View File

@@ -16,10 +16,10 @@ import javax.annotation.concurrent.Immutable;
public class GroupInvitationRequest extends InvitationRequest<PrivateGroup> { public class GroupInvitationRequest extends InvitationRequest<PrivateGroup> {
public GroupInvitationRequest(MessageId id, GroupId groupId, long time, public GroupInvitationRequest(MessageId id, GroupId groupId, long time,
boolean local, boolean sent, boolean seen, boolean read, boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, PrivateGroup shareable, SessionId sessionId, PrivateGroup shareable,
@Nullable String text, boolean available, boolean canBeOpened) { @Nullable String text, boolean available, boolean canBeOpened) {
super(id, groupId, time, local, sent, seen, read, sessionId, shareable, super(id, groupId, time, local, read, sent, seen, sessionId, shareable,
text, available, canBeOpened); text, available, canBeOpened);
} }

View File

@@ -14,9 +14,9 @@ import javax.annotation.concurrent.Immutable;
public class GroupInvitationResponse extends InvitationResponse { public class GroupInvitationResponse extends InvitationResponse {
public GroupInvitationResponse(MessageId id, GroupId groupId, long time, public GroupInvitationResponse(MessageId id, GroupId groupId, long time,
boolean local, boolean sent, boolean seen, boolean read, boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, boolean accept, GroupId shareableId) { SessionId sessionId, boolean accept, GroupId shareableId) {
super(id, groupId, time, local, sent, seen, read, sessionId, super(id, groupId, time, local, read, sent, seen, sessionId,
accept, shareableId); accept, shareableId);
} }

View File

@@ -13,10 +13,10 @@ public abstract class InvitationRequest<S extends Shareable> extends
private final boolean canBeOpened; private final boolean canBeOpened;
public InvitationRequest(MessageId messageId, GroupId groupId, long time, public InvitationRequest(MessageId messageId, GroupId groupId, long time,
boolean local, boolean sent, boolean seen, boolean read, boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, S object, @Nullable String text, SessionId sessionId, S object, @Nullable String text,
boolean available, boolean canBeOpened) { boolean available, boolean canBeOpened) {
super(messageId, groupId, time, local, sent, seen, read, sessionId, super(messageId, groupId, time, local, read, sent, seen, sessionId,
object, text, !available); object, text, !available);
this.canBeOpened = canBeOpened; this.canBeOpened = canBeOpened;
} }

View File

@@ -10,9 +10,9 @@ public abstract class InvitationResponse extends ConversationResponse {
private final GroupId shareableId; private final GroupId shareableId;
public InvitationResponse(MessageId id, GroupId groupId, long time, public InvitationResponse(MessageId id, GroupId groupId, long time,
boolean local, boolean sent, boolean seen, boolean read, boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, boolean accepted, GroupId shareableId) { SessionId sessionId, boolean accepted, GroupId shareableId) {
super(id, groupId, time, local, sent, seen, read, sessionId, accepted); super(id, groupId, time, local, read, sent, seen, sessionId, accepted);
this.shareableId = shareableId; this.shareableId = shareableId;
} }

View File

@@ -453,7 +453,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
authorInfos.put(author.getId(), authorInfo); authorInfos.put(author.getId(), authorInfo);
} }
return new IntroductionRequest(m, contactGroupId, meta.getTimestamp(), return new IntroductionRequest(m, contactGroupId, meta.getTimestamp(),
meta.isLocal(), status.isSent(), status.isSeen(), meta.isRead(), meta.isLocal(), meta.isRead(), status.isSent(), status.isSeen(),
sessionId, author, text, !meta.isAvailableToAnswer(), sessionId, author, text, !meta.isAvailableToAnswer(),
authorInfo); authorInfo);
} }
@@ -487,7 +487,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
authorInfos.put(author.getId(), authorInfo); authorInfos.put(author.getId(), authorInfo);
} }
return new IntroductionResponse(m, contactGroupId, meta.getTimestamp(), return new IntroductionResponse(m, contactGroupId, meta.getTimestamp(),
meta.isLocal(), status.isSent(), status.isSeen(), meta.isRead(), meta.isLocal(), meta.isRead(), status.isSent(), status.isSeen(),
sessionId, accept, author, authorInfo, role); sessionId, accept, author, authorInfo, role);
} }

View File

@@ -414,8 +414,8 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
boolean canBeOpened = meta.wasAccepted() && boolean canBeOpened = meta.wasAccepted() &&
db.containsGroup(txn, invite.getPrivateGroupId()); db.containsGroup(txn, invite.getPrivateGroupId());
return new GroupInvitationRequest(m, contactGroupId, return new GroupInvitationRequest(m, contactGroupId,
meta.getTimestamp(), meta.isLocal(), status.isSent(), meta.getTimestamp(), meta.isLocal(), meta.isRead(),
status.isSeen(), meta.isRead(), sessionId, pg, status.isSent(), status.isSeen(), sessionId, pg,
invite.getText(), meta.isAvailableToAnswer(), canBeOpened); invite.getText(), meta.isAvailableToAnswer(), canBeOpened);
} }
@@ -424,10 +424,9 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
MessageStatus status, boolean accept) { MessageStatus status, boolean accept) {
SessionId sessionId = getSessionId(meta.getPrivateGroupId()); SessionId sessionId = getSessionId(meta.getPrivateGroupId());
return new GroupInvitationResponse(m, contactGroupId, return new GroupInvitationResponse(m, contactGroupId,
meta.getTimestamp(), meta.isLocal(), status.isSent(), meta.getTimestamp(), meta.isLocal(), meta.isRead(),
status.isSeen(), meta.isRead(), sessionId, accept, status.isSent(), status.isSeen(), sessionId, accept,
meta.getPrivateGroupId() meta.getPrivateGroupId());
);
} }
@Override @Override

View File

@@ -329,7 +329,7 @@ class InviteeProtocolEngine extends AbstractProtocolEngine<InviteeSession> {
PrivateGroup pg) { PrivateGroup pg) {
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes()); SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
return new GroupInvitationRequest(m.getId(), m.getContactGroupId(), return new GroupInvitationRequest(m.getId(), m.getContactGroupId(),
m.getTimestamp(), false, false, true, false, sessionId, pg, m.getTimestamp(), false, false, false, false, sessionId, pg,
m.getText(), true, false); m.getText(), true, false);
} }

View File

@@ -23,7 +23,7 @@ public class BlogInvitationFactoryImpl
ContactId c, boolean available, boolean canBeOpened) { ContactId c, boolean available, boolean canBeOpened) {
SessionId sessionId = new SessionId(m.getShareableId().getBytes()); SessionId sessionId = new SessionId(m.getShareableId().getBytes());
return new BlogInvitationRequest(m.getId(), m.getContactGroupId(), return new BlogInvitationRequest(m.getId(), m.getContactGroupId(),
m.getTimestamp(), local, sent, seen, read, sessionId, m.getTimestamp(), local, read, sent, seen, sessionId,
m.getShareable(), m.getText(), available, canBeOpened); m.getShareable(), m.getText(), available, canBeOpened);
} }
@@ -32,8 +32,8 @@ public class BlogInvitationFactoryImpl
GroupId contactGroupId, long time, boolean local, boolean sent, GroupId contactGroupId, long time, boolean local, boolean sent,
boolean seen, boolean read, boolean accept, GroupId shareableId) { boolean seen, boolean read, boolean accept, GroupId shareableId) {
SessionId sessionId = new SessionId(shareableId.getBytes()); SessionId sessionId = new SessionId(shareableId.getBytes());
return new BlogInvitationResponse(id, contactGroupId, time, local, sent, return new BlogInvitationResponse(id, contactGroupId, time, local, read,
seen, read, sessionId, accept, shareableId); sent, seen, sessionId, accept, shareableId);
} }
} }

View File

@@ -23,7 +23,7 @@ public class ForumInvitationFactoryImpl
ContactId c, boolean available, boolean canBeOpened) { ContactId c, boolean available, boolean canBeOpened) {
SessionId sessionId = new SessionId(m.getShareableId().getBytes()); SessionId sessionId = new SessionId(m.getShareableId().getBytes());
return new ForumInvitationRequest(m.getId(), m.getContactGroupId(), return new ForumInvitationRequest(m.getId(), m.getContactGroupId(),
m.getTimestamp(), local, sent, seen, read, sessionId, m.getTimestamp(), local, read, sent, seen, sessionId,
m.getShareable(), m.getText(), available, canBeOpened); m.getShareable(), m.getText(), available, canBeOpened);
} }
@@ -33,7 +33,7 @@ public class ForumInvitationFactoryImpl
boolean seen, boolean read, boolean accept, GroupId shareableId) { boolean seen, boolean read, boolean accept, GroupId shareableId) {
SessionId sessionId = new SessionId(shareableId.getBytes()); SessionId sessionId = new SessionId(shareableId.getBytes());
return new ForumInvitationResponse(id, contactGroupId, time, local, return new ForumInvitationResponse(id, contactGroupId, time, local,
sent, seen, read, sessionId, accept, shareableId); read, sent, seen, sessionId, accept, shareableId);
} }
} }

View File

@@ -25,6 +25,7 @@ import org.briarproject.bramble.test.TestDatabaseModule;
import org.briarproject.briar.api.client.ProtocolStateException; import org.briarproject.briar.api.client.ProtocolStateException;
import org.briarproject.briar.api.client.SessionId; import org.briarproject.briar.api.client.SessionId;
import org.briarproject.briar.api.conversation.ConversationMessageHeader; import org.briarproject.briar.api.conversation.ConversationMessageHeader;
import org.briarproject.briar.api.conversation.ConversationResponse;
import org.briarproject.briar.api.introduction.IntroductionManager; import org.briarproject.briar.api.introduction.IntroductionManager;
import org.briarproject.briar.api.introduction.IntroductionRequest; import org.briarproject.briar.api.introduction.IntroductionRequest;
import org.briarproject.briar.api.introduction.IntroductionResponse; import org.briarproject.briar.api.introduction.IntroductionResponse;
@@ -138,6 +139,18 @@ public class IntroductionIntegrationTest
assertGroupCount(messageTracker0, g1.getId(), 1, 0); assertGroupCount(messageTracker0, g1.getId(), 1, 0);
assertGroupCount(messageTracker0, g2.getId(), 1, 0); assertGroupCount(messageTracker0, g2.getId(), 1, 0);
// check that request message states are correct
Collection<ConversationMessageHeader> messages =
db0.transactionWithResult(true, txn -> introductionManager0
.getMessageHeaders(txn, contactId1From0));
assertEquals(1, messages.size());
assertMessageState(messages.iterator().next(), true, false, false);
messages =
db0.transactionWithResult(true, txn -> introductionManager0
.getMessageHeaders(txn, contactId2From0));
assertEquals(1, messages.size());
assertMessageState(messages.iterator().next(), true, false, false);
// sync first REQUEST message // sync first REQUEST message
sync0To1(1, true); sync0To1(1, true);
eventWaiter.await(TIMEOUT, 1); eventWaiter.await(TIMEOUT, 1);
@@ -146,6 +159,17 @@ public class IntroductionIntegrationTest
listener1.getRequest().getName()); listener1.getRequest().getName());
assertGroupCount(messageTracker1, g1.getId(), 2, 1); assertGroupCount(messageTracker1, g1.getId(), 2, 1);
// check that accept message state is correct
messages =
db1.transactionWithResult(true, txn -> introductionManager1
.getMessageHeaders(txn, contactId0From1));
assertEquals(2, messages.size());
for (ConversationMessageHeader h : messages) {
if (h instanceof ConversationResponse) {
assertMessageState(h, true, false, false);
}
}
// sync second REQUEST message // sync second REQUEST message
sync0To2(1, true); sync0To2(1, true);
eventWaiter.await(TIMEOUT, 1); eventWaiter.await(TIMEOUT, 1);

View File

@@ -163,14 +163,21 @@ public class GroupInvitationIntegrationTest
long timestamp = clock.currentTimeMillis(); long timestamp = clock.currentTimeMillis();
sendInvitation(timestamp, null); sendInvitation(timestamp, null);
// check that invitation message state is correct
Collection<ConversationMessageHeader> messages =
db0.transactionWithResult(true, txn -> groupInvitationManager0
.getMessageHeaders(txn, contactId1From0));
assertEquals(1, messages.size());
assertMessageState(messages.iterator().next(), true, false, false);
sync0To1(1, true); sync0To1(1, true);
assertFalse(groupInvitationManager1.getInvitations().isEmpty()); assertFalse(groupInvitationManager1.getInvitations().isEmpty());
groupInvitationManager1 groupInvitationManager1
.respondToInvitation(contactId0From1, privateGroup0, true); .respondToInvitation(contactId0From1, privateGroup0, true);
Collection<ConversationMessageHeader> messages = messages = db1.transactionWithResult(true,
db1.transactionWithResult(true, txn -> groupInvitationManager1 txn -> groupInvitationManager1
.getMessageHeaders(txn, contactId0From1)); .getMessageHeaders(txn, contactId0From1));
assertEquals(2, messages.size()); assertEquals(2, messages.size());
boolean foundResponse = false; boolean foundResponse = false;
@@ -178,6 +185,7 @@ public class GroupInvitationIntegrationTest
if (m instanceof GroupInvitationResponse) { if (m instanceof GroupInvitationResponse) {
foundResponse = true; foundResponse = true;
GroupInvitationResponse response = (GroupInvitationResponse) m; GroupInvitationResponse response = (GroupInvitationResponse) m;
assertMessageState(response, true, false, false);
assertEquals(privateGroup0.getId(), response.getShareableId()); assertEquals(privateGroup0.getId(), response.getShareableId());
assertTrue(response.wasAccepted()); assertTrue(response.wasAccepted());
} else { } else {

View File

@@ -19,6 +19,7 @@ import org.briarproject.briar.api.blog.BlogSharingManager;
import org.briarproject.briar.api.blog.event.BlogInvitationRequestReceivedEvent; import org.briarproject.briar.api.blog.event.BlogInvitationRequestReceivedEvent;
import org.briarproject.briar.api.blog.event.BlogInvitationResponseReceivedEvent; import org.briarproject.briar.api.blog.event.BlogInvitationResponseReceivedEvent;
import org.briarproject.briar.api.conversation.ConversationMessageHeader; import org.briarproject.briar.api.conversation.ConversationMessageHeader;
import org.briarproject.briar.api.conversation.ConversationResponse;
import org.briarproject.briar.test.BriarIntegrationTest; import org.briarproject.briar.test.BriarIntegrationTest;
import org.briarproject.briar.test.BriarIntegrationTestComponent; import org.briarproject.briar.test.BriarIntegrationTestComponent;
import org.briarproject.briar.test.DaggerBriarIntegrationTestComponent; import org.briarproject.briar.test.DaggerBriarIntegrationTestComponent;
@@ -128,12 +129,29 @@ public class BlogSharingIntegrationTest
MAJOR_VERSION, contact1From0).getId(); MAJOR_VERSION, contact1From0).getId();
assertGroupCount(messageTracker0, g, 1, 0); assertGroupCount(messageTracker0, g, 1, 0);
// check that request message state is correct
Collection<ConversationMessageHeader> messages =
db0.transactionWithResult(true, txn -> blogSharingManager0
.getMessageHeaders(txn, contactId1From0));
assertEquals(1, messages.size());
assertMessageState(messages.iterator().next(), true, false, false);
// sync first request message // sync first request message
sync0To1(1, true); sync0To1(1, true);
eventWaiter.await(TIMEOUT, 1); eventWaiter.await(TIMEOUT, 1);
assertTrue(listener1.requestReceived); assertTrue(listener1.requestReceived);
assertGroupCount(messageTracker1, g, 2, 1); assertGroupCount(messageTracker1, g, 2, 1);
// check that accept message state is correct
messages = db1.transactionWithResult(true, txn -> blogSharingManager1
.getMessageHeaders(txn, contactId0From1));
assertEquals(2, messages.size());
for (ConversationMessageHeader h : messages) {
if (h instanceof ConversationResponse) {
assertMessageState(h, true, false, false);
}
}
// sync response back // sync response back
sync1To0(1, true); sync1To0(1, true);
eventWaiter.await(TIMEOUT, 1); eventWaiter.await(TIMEOUT, 1);

View File

@@ -13,6 +13,7 @@ import org.briarproject.bramble.api.sync.Message;
import org.briarproject.bramble.api.sync.MessageId; import org.briarproject.bramble.api.sync.MessageId;
import org.briarproject.bramble.test.TestDatabaseModule; import org.briarproject.bramble.test.TestDatabaseModule;
import org.briarproject.briar.api.conversation.ConversationMessageHeader; import org.briarproject.briar.api.conversation.ConversationMessageHeader;
import org.briarproject.briar.api.conversation.ConversationResponse;
import org.briarproject.briar.api.forum.Forum; import org.briarproject.briar.api.forum.Forum;
import org.briarproject.briar.api.forum.ForumInvitationRequest; import org.briarproject.briar.api.forum.ForumInvitationRequest;
import org.briarproject.briar.api.forum.ForumInvitationResponse; import org.briarproject.briar.api.forum.ForumInvitationResponse;
@@ -114,11 +115,28 @@ public class ForumSharingIntegrationTest
.sendInvitation(forum0.getId(), contactId1From0, "Hi!", .sendInvitation(forum0.getId(), contactId1From0, "Hi!",
clock.currentTimeMillis()); clock.currentTimeMillis());
// check that request message state is correct
Collection<ConversationMessageHeader> messages =
db0.transactionWithResult(true, txn -> forumSharingManager0
.getMessageHeaders(txn, contactId1From0));
assertEquals(1, messages.size());
assertMessageState(messages.iterator().next(), true, false, false);
// sync first request message // sync first request message
sync0To1(1, true); sync0To1(1, true);
eventWaiter.await(TIMEOUT, 1); eventWaiter.await(TIMEOUT, 1);
assertTrue(listener1.requestReceived); assertTrue(listener1.requestReceived);
// check that accept message state is correct
messages = db1.transactionWithResult(true, txn -> forumSharingManager1
.getMessageHeaders(txn, contactId0From1));
assertEquals(2, messages.size());
for (ConversationMessageHeader h : messages) {
if (h instanceof ConversationResponse) {
assertMessageState(h, true, false, false);
}
}
// sync response back // sync response back
sync1To0(1, true); sync1To0(1, true);
eventWaiter.await(TIMEOUT, 1); eventWaiter.await(TIMEOUT, 1);

View File

@@ -40,6 +40,7 @@ import org.briarproject.bramble.versioning.VersioningModule;
import org.briarproject.briar.api.blog.BlogFactory; import org.briarproject.briar.api.blog.BlogFactory;
import org.briarproject.briar.api.blog.BlogPostFactory; import org.briarproject.briar.api.blog.BlogPostFactory;
import org.briarproject.briar.api.client.MessageTracker; import org.briarproject.briar.api.client.MessageTracker;
import org.briarproject.briar.api.conversation.ConversationMessageHeader;
import org.briarproject.briar.api.forum.ForumPostFactory; import org.briarproject.briar.api.forum.ForumPostFactory;
import org.briarproject.briar.api.privategroup.GroupMessageFactory; import org.briarproject.briar.api.privategroup.GroupMessageFactory;
import org.briarproject.briar.api.privategroup.PrivateGroupFactory; import org.briarproject.briar.api.privategroup.PrivateGroupFactory;
@@ -330,6 +331,13 @@ public abstract class BriarIntegrationTest<C extends BriarIntegrationTestCompone
} }
} }
protected void assertMessageState(ConversationMessageHeader h, boolean read,
boolean sent, boolean seen) {
assertEquals("read", read, h.isRead());
assertEquals("sent", sent, h.isSent());
assertEquals("seen", seen, h.isSeen());
}
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
stopLifecycles(); stopLifecycles();

View File

@@ -77,7 +77,7 @@ internal class MessagingControllerImplTest : ControllerTest() {
@Test @Test
fun listIntroductionRequest() { fun listIntroductionRequest() {
val request = IntroductionRequest( val request = IntroductionRequest(
message.id, group.id, timestamp, true, true, false, true, sessionId, author, text, message.id, group.id, timestamp, true, true, true, false, sessionId, author, text,
false, AuthorInfo(UNVERIFIED) false, AuthorInfo(UNVERIFIED)
) )
@@ -217,7 +217,7 @@ internal class MessagingControllerImplTest : ControllerTest() {
@Test @Test
fun testIntroductionRequestWithNullText() { fun testIntroductionRequestWithNullText() {
val request = IntroductionRequest( val request = IntroductionRequest(
message.id, group.id, timestamp, true, true, false, true, sessionId, author, null, message.id, group.id, timestamp, true, true, true, false, sessionId, author, null,
false, AuthorInfo(VERIFIED) false, AuthorInfo(VERIFIED)
) )
val json = """ val json = """