Rename message length method.

This commit is contained in:
akwizgran
2018-08-24 16:55:35 +01:00
parent cb3026959a
commit 0bc07cd0c1
5 changed files with 7 additions and 7 deletions

View File

@@ -50,7 +50,7 @@ public class Message {
/** /**
* Returns the length of the raw message in bytes. * Returns the length of the raw message in bytes.
*/ */
public int getLength() { public int getRawLength() {
return raw.length; return raw.length;
} }

View File

@@ -741,7 +741,7 @@ abstract class JdbcDatabase implements Database<Connection> {
boolean offered = removeOfferedMessage(txn, c, m.getId()); boolean offered = removeOfferedMessage(txn, c, m.getId());
boolean seen = offered || (sender != null && c.equals(sender)); boolean seen = offered || (sender != null && c.equals(sender));
addStatus(txn, m.getId(), c, m.getGroupId(), m.getTimestamp(), addStatus(txn, m.getId(), c, m.getGroupId(), m.getTimestamp(),
m.getLength(), state, e.getValue(), messageShared, m.getRawLength(), state, e.getValue(), messageShared,
false, seen); false, seen);
} }
// Update denormalised column in messageDependencies if dependency // Update denormalised column in messageDependencies if dependency

View File

@@ -355,11 +355,11 @@ public abstract class JdbcDatabaseTest extends BrambleTestCase {
// The message is sendable, but too large to send // The message is sendable, but too large to send
Collection<MessageId> ids = db.getMessagesToSend(txn, contactId, Collection<MessageId> ids = db.getMessagesToSend(txn, contactId,
message.getLength() - 1); message.getRawLength() - 1);
assertTrue(ids.isEmpty()); assertTrue(ids.isEmpty());
// The message is just the right size to send // The message is just the right size to send
ids = db.getMessagesToSend(txn, contactId, message.getLength()); ids = db.getMessagesToSend(txn, contactId, message.getRawLength());
assertEquals(singletonList(messageId), ids); assertEquals(singletonList(messageId), ids);
db.commitTransaction(txn); db.commitTransaction(txn);

View File

@@ -169,7 +169,7 @@ public class SyncIntegrationTest extends BrambleTestCase {
assertArrayEquals(m1.getGroupId().getBytes(), assertArrayEquals(m1.getGroupId().getBytes(),
m2.getGroupId().getBytes()); m2.getGroupId().getBytes());
assertEquals(m1.getTimestamp(), m2.getTimestamp()); assertEquals(m1.getTimestamp(), m2.getTimestamp());
assertEquals(m1.getLength(), m2.getLength()); assertEquals(m1.getRawLength(), m2.getRawLength());
assertArrayEquals(m1.getRaw(), m2.getRaw()); assertArrayEquals(m1.getRaw(), m2.getRaw());
} }
} }

View File

@@ -60,7 +60,7 @@ public class MessageSizeIntegrationTest extends BriarTestCase {
PrivateMessage message = privateMessageFactory.createPrivateMessage( PrivateMessage message = privateMessageFactory.createPrivateMessage(
groupId, timestamp, body); groupId, timestamp, body);
// Check the size of the serialised message // Check the size of the serialised message
int length = message.getMessage().getLength(); int length = message.getMessage().getRawLength();
assertTrue(length > UniqueId.LENGTH + 8 assertTrue(length > UniqueId.LENGTH + 8
+ MAX_PRIVATE_MESSAGE_BODY_LENGTH); + MAX_PRIVATE_MESSAGE_BODY_LENGTH);
assertTrue(length <= MAX_RECORD_PAYLOAD_BYTES); assertTrue(length <= MAX_RECORD_PAYLOAD_BYTES);
@@ -83,7 +83,7 @@ public class MessageSizeIntegrationTest extends BriarTestCase {
ForumPost post = forumPostFactory.createPost(groupId, ForumPost post = forumPostFactory.createPost(groupId,
timestamp, parent, author, body); timestamp, parent, author, body);
// Check the size of the serialised message // Check the size of the serialised message
int length = post.getMessage().getLength(); int length = post.getMessage().getRawLength();
assertTrue(length > UniqueId.LENGTH + 8 + UniqueId.LENGTH + 4 assertTrue(length > UniqueId.LENGTH + 8 + UniqueId.LENGTH + 4
+ MAX_AUTHOR_NAME_LENGTH + MAX_PUBLIC_KEY_LENGTH + MAX_AUTHOR_NAME_LENGTH + MAX_PUBLIC_KEY_LENGTH
+ MAX_FORUM_POST_BODY_LENGTH); + MAX_FORUM_POST_BODY_LENGTH);