Use key set ID to increment stream counter.

This commit is contained in:
akwizgran
2018-03-28 11:52:14 +01:00
parent 6787d29f11
commit 798b871cc9
8 changed files with 25 additions and 41 deletions

View File

@@ -285,11 +285,11 @@ public class DatabaseComponentImplTest extends BrambleMockTestCase {
throws Exception {
context.checking(new Expectations() {{
// Check whether the contact is in the DB (which it's not)
exactly(18).of(database).startTransaction();
exactly(17).of(database).startTransaction();
will(returnValue(txn));
exactly(18).of(database).containsContact(txn, contactId);
exactly(17).of(database).containsContact(txn, contactId);
will(returnValue(false));
exactly(18).of(database).abortTransaction(txn);
exactly(17).of(database).abortTransaction(txn);
}});
DatabaseComponent db = createDatabaseComponent(database, eventBus,
shutdown);
@@ -384,16 +384,6 @@ public class DatabaseComponentImplTest extends BrambleMockTestCase {
db.endTransaction(transaction);
}
transaction = db.startTransaction(false);
try {
db.incrementStreamCounter(transaction, contactId, transportId, 0);
fail();
} catch (NoSuchContactException expected) {
// Expected
} finally {
db.endTransaction(transaction);
}
transaction = db.startTransaction(false);
try {
db.getGroupVisibility(transaction, contactId, groupId);
@@ -781,7 +771,7 @@ public class DatabaseComponentImplTest extends BrambleMockTestCase {
// Check whether the transport is in the DB (which it's not)
exactly(6).of(database).startTransaction();
will(returnValue(txn));
exactly(2).of(database).containsContact(txn, contactId);
oneOf(database).containsContact(txn, contactId);
will(returnValue(true));
exactly(6).of(database).containsTransport(txn, transportId);
will(returnValue(false));
@@ -822,7 +812,7 @@ public class DatabaseComponentImplTest extends BrambleMockTestCase {
transaction = db.startTransaction(false);
try {
db.incrementStreamCounter(transaction, contactId, transportId, 0);
db.incrementStreamCounter(transaction, transportId, keySetId);
fail();
} catch (NoSuchTransportException expected) {
// Expected

View File

@@ -825,8 +825,8 @@ public abstract class JdbcDatabaseTest extends BrambleTestCase {
singletonList(new KeySet(keySetId, contactId, keys)));
// Increment the stream counter twice and retrieve the transport keys
db.incrementStreamCounter(txn, contactId, transportId, rotationPeriod);
db.incrementStreamCounter(txn, contactId, transportId, rotationPeriod);
db.incrementStreamCounter(txn, transportId, keySetId);
db.incrementStreamCounter(txn, transportId, keySetId);
Collection<KeySet> newKeys = db.getTransportKeys(txn, transportId);
assertEquals(1, newKeys.size());
KeySet ks = newKeys.iterator().next();

View File

@@ -227,7 +227,7 @@ public class TransportKeyManagerImplTest extends BrambleMockTestCase {
context.checking(new Expectations() {{
// Increment the stream counter
oneOf(db).incrementStreamCounter(txn, contactId, transportId, 1000);
oneOf(db).incrementStreamCounter(txn, transportId, keySetId);
}});
TransportKeyManager transportKeyManager = new TransportKeyManagerImpl(
@@ -441,7 +441,7 @@ public class TransportKeyManagerImplTest extends BrambleMockTestCase {
// Activate the keys
oneOf(db).setTransportKeysActive(txn, transportId, keySetId);
// Increment the stream counter
oneOf(db).incrementStreamCounter(txn, contactId, transportId, 1000);
oneOf(db).incrementStreamCounter(txn, transportId, keySetId);
}});
TransportKeyManager transportKeyManager = new TransportKeyManagerImpl(