Report UNKNOWN state for cross-group dependencies.

This causes the validator to treat the dependent message in the same way regardless of whether there is a subscription to the dependency's group.
This commit is contained in:
akwizgran
2018-03-14 11:25:24 +00:00
parent 5fe68e6f82
commit a0c88da1ac
2 changed files with 3 additions and 4 deletions

View File

@@ -57,7 +57,6 @@ import static org.briarproject.bramble.api.sync.Group.Visibility.INVISIBLE;
import static org.briarproject.bramble.api.sync.Group.Visibility.SHARED; import static org.briarproject.bramble.api.sync.Group.Visibility.SHARED;
import static org.briarproject.bramble.api.sync.Group.Visibility.VISIBLE; import static org.briarproject.bramble.api.sync.Group.Visibility.VISIBLE;
import static org.briarproject.bramble.api.sync.ValidationManager.State.DELIVERED; import static org.briarproject.bramble.api.sync.ValidationManager.State.DELIVERED;
import static org.briarproject.bramble.api.sync.ValidationManager.State.INVALID;
import static org.briarproject.bramble.api.sync.ValidationManager.State.PENDING; import static org.briarproject.bramble.api.sync.ValidationManager.State.PENDING;
import static org.briarproject.bramble.api.sync.ValidationManager.State.UNKNOWN; import static org.briarproject.bramble.api.sync.ValidationManager.State.UNKNOWN;
import static org.briarproject.bramble.db.DatabaseConstants.DB_SETTINGS_NAMESPACE; import static org.briarproject.bramble.db.DatabaseConstants.DB_SETTINGS_NAMESPACE;
@@ -1681,7 +1680,7 @@ abstract class JdbcDatabase implements Database<Connection> {
GroupId dependentGroupId = new GroupId(rs.getBytes(3)); GroupId dependentGroupId = new GroupId(rs.getBytes(3));
GroupId dependencyGroupId = new GroupId(rs.getBytes(4)); GroupId dependencyGroupId = new GroupId(rs.getBytes(4));
if (!dependentGroupId.equals(dependencyGroupId)) if (!dependentGroupId.equals(dependencyGroupId))
state = INVALID; // Dependency in another group state = UNKNOWN; // Dependency in another group
} }
dependencies.put(dependency, state); dependencies.put(dependency, state);
} }

View File

@@ -1332,8 +1332,8 @@ public abstract class JdbcDatabaseTest extends BrambleTestCase {
Map<MessageId, State> dependencies; Map<MessageId, State> dependencies;
dependencies = db.getMessageDependencies(txn, messageId); dependencies = db.getMessageDependencies(txn, messageId);
// The cross-group dependency should have state INVALID // The cross-group dependency should have state UNKNOWN
assertEquals(INVALID, dependencies.get(messageId1)); assertEquals(UNKNOWN, dependencies.get(messageId1));
// The missing dependency should have state UNKNOWN // The missing dependency should have state UNKNOWN
assertEquals(UNKNOWN, dependencies.get(messageId2)); assertEquals(UNKNOWN, dependencies.get(messageId2));