When replying to a message, don't use an earlier timestamp.

This produces a saner user experience when devices have differing
clocks.
This commit is contained in:
akwizgran
2013-12-11 16:25:00 +00:00
parent ba9ea9da1c
commit 1d4213e9c6
10 changed files with 46 additions and 27 deletions

View File

@@ -71,6 +71,7 @@ public class ProtocolIntegrationTest extends BriarTestCase {
private final Message message, message1;
private final String authorName = "Alice";
private final String contentType = "text/plain";
private final long timestamp = System.currentTimeMillis();
private final String messageBody = "Hello world";
private final Collection<MessageId> messageIds;
private final TransportId transportId;
@@ -104,9 +105,9 @@ public class ProtocolIntegrationTest extends BriarTestCase {
// Create two messages to the group: one anonymous, one pseudonymous
MessageFactory messageFactory = i.getInstance(MessageFactory.class);
message = messageFactory.createAnonymousMessage(null, group,
contentType, messageBody.getBytes("UTF-8"));
contentType, timestamp, messageBody.getBytes("UTF-8"));
message1 = messageFactory.createPseudonymousMessage(null, group,
author, authorKeyPair.getPrivate(), contentType,
author, authorKeyPair.getPrivate(), contentType, timestamp,
messageBody.getBytes("UTF-8"));
messageIds = Arrays.asList(message.getId(), message1.getId());
// Create some transport properties

View File

@@ -131,9 +131,10 @@ public class ConstantsTest extends BriarTestCase {
PrivateKey privateKey = crypto.generateSignatureKeyPair().getPrivate();
String contentType =
TestUtils.createRandomString(MAX_CONTENT_TYPE_LENGTH);
long timestamp = Long.MAX_VALUE;
byte[] body = new byte[MAX_BODY_LENGTH];
Message message = messageFactory.createPseudonymousMessage(parent,
group, author, privateKey, contentType, body);
group, author, privateKey, contentType, timestamp, body);
// Check the size of the serialised message
int length = message.getSerialised().length;
assertTrue(length > UniqueId.LENGTH + MAX_GROUP_NAME_LENGTH

View File

@@ -123,10 +123,11 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
km.endpointAdded(ep, LATENCY, initialSecret.clone());
// Send Bob a message
String contentType = "text/plain";
long timestamp = System.currentTimeMillis();
byte[] body = "Hi Bob!".getBytes("UTF-8");
MessageFactory messageFactory = alice.getInstance(MessageFactory.class);
Message message = messageFactory.createPrivateMessage(null, contentType,
body);
timestamp, body);
db.addLocalPrivateMessage(message, contactId);
// Create an outgoing simplex connection
ByteArrayOutputStream out = new ByteArrayOutputStream();