mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Merge branch '1384-expiry-time' into 'master'
Fix off-by-one error in expiry calculation Closes #1384 See merge request briar/briar!923
This commit is contained in:
@@ -1882,7 +1882,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
+ " AND groupShared = TRUE AND messageShared = TRUE"
|
||||
+ " AND deleted = FALSE"
|
||||
+ " AND seen = FALSE AND requested = FALSE"
|
||||
+ " AND (expiry < ? OR eta > ?)"
|
||||
+ " AND (expiry <= ? OR eta > ?)"
|
||||
+ " ORDER BY timestamp LIMIT ?";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setInt(1, c.getInt());
|
||||
@@ -1941,7 +1941,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
+ " AND groupShared = TRUE AND messageShared = TRUE"
|
||||
+ " AND deleted = FALSE"
|
||||
+ " AND seen = FALSE"
|
||||
+ " AND (expiry < ? OR eta > ?)"
|
||||
+ " AND (expiry <= ? OR eta > ?)"
|
||||
+ " ORDER BY timestamp";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setInt(1, c.getInt());
|
||||
@@ -2072,7 +2072,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
+ " AND groupShared = TRUE AND messageShared = TRUE"
|
||||
+ " AND deleted = FALSE"
|
||||
+ " AND seen = FALSE AND requested = TRUE"
|
||||
+ " AND (expiry < ? OR eta > ?)"
|
||||
+ " AND (expiry <= ? OR eta > ?)"
|
||||
+ " ORDER BY timestamp";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setInt(1, c.getInt());
|
||||
|
||||
@@ -1818,8 +1818,8 @@ public abstract class JdbcDatabaseTest extends BrambleTestCase {
|
||||
@Test
|
||||
public void testMessageRetransmission() throws Exception {
|
||||
long now = System.currentTimeMillis();
|
||||
long steps[] = {now, now, now + MAX_LATENCY * 2,
|
||||
now + MAX_LATENCY * 2 + 1};
|
||||
long steps[] = {now, now, now + MAX_LATENCY * 2 - 1,
|
||||
now + MAX_LATENCY * 2};
|
||||
Database<Connection> db =
|
||||
open(false, new TestMessageFactory(), new ArrayClock(steps));
|
||||
Connection txn = db.startTransaction();
|
||||
@@ -1845,12 +1845,12 @@ public abstract class JdbcDatabaseTest extends BrambleTestCase {
|
||||
// The message should expire after 2 * MAX_LATENCY
|
||||
assertEquals(now + MAX_LATENCY * 2, db.getNextSendTime(txn, contactId));
|
||||
|
||||
// Time: now + MAX_LATENCY * 2
|
||||
// Time: now + MAX_LATENCY * 2 - 1
|
||||
// The message should not yet be sendable
|
||||
ids = db.getMessagesToSend(txn, contactId, ONE_MEGABYTE, MAX_LATENCY);
|
||||
assertTrue(ids.isEmpty());
|
||||
|
||||
// Time: now + MAX_LATENCY * 2 + 1
|
||||
// Time: now + MAX_LATENCY * 2
|
||||
// The message should have expired and should now be sendable
|
||||
ids = db.getMessagesToSend(txn, contactId, ONE_MEGABYTE, MAX_LATENCY);
|
||||
assertEquals(singletonList(messageId), ids);
|
||||
|
||||
Reference in New Issue
Block a user