mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Don't throw a DbException if a contact sends duplicate batches.
This commit is contained in:
@@ -404,6 +404,33 @@ public class H2DatabaseTest extends TestCase {
|
||||
db.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDuplicateBatchesReceived() throws DbException {
|
||||
Database<Connection> db = open(false);
|
||||
Connection txn = db.startTransaction();
|
||||
|
||||
// Add a contact and receive the same batch twice
|
||||
assertEquals(contactId, db.addContact(txn, null));
|
||||
db.addBatchToAck(txn, contactId, batchId);
|
||||
db.addBatchToAck(txn, contactId, batchId);
|
||||
db.commitTransaction(txn);
|
||||
|
||||
// The batch ID should only be returned once
|
||||
Collection<BatchId> acks = db.getBatchesToAck(txn, contactId);
|
||||
assertEquals(1, acks.size());
|
||||
assertTrue(acks.contains(batchId));
|
||||
|
||||
// Remove the batch ID
|
||||
db.removeBatchesToAck(txn, contactId, acks);
|
||||
|
||||
// The batch ID should have been removed
|
||||
acks = db.getBatchesToAck(txn, contactId);
|
||||
assertEquals(0, acks.size());
|
||||
|
||||
db.commitTransaction(txn);
|
||||
db.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveAckedBatch() throws DbException {
|
||||
Database<Connection> db = open(false);
|
||||
|
||||
Reference in New Issue
Block a user