use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by signalapp.
the class GroupStateMapperTest method updates_with_all_changes_missing.
@Test
public void updates_with_all_changes_missing() {
DecryptedGroup currentState = state(5);
ServerGroupLogEntry log6 = serverLogEntryWholeStateOnly(6);
ServerGroupLogEntry log7 = serverLogEntryWholeStateOnly(7);
ServerGroupLogEntry log8 = serverLogEntryWholeStateOnly(8);
AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, asList(log6, log7, log8)), LATEST);
assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(asList(localLogEntryNoEditor(6), localLogEntryNoEditor(7), localLogEntryNoEditor(8))));
assertNewState(new GlobalGroupState(log8.getGroup(), emptyList()), advanceGroupStateResult.getNewGlobalGroupState());
assertEquals(log8.getGroup(), advanceGroupStateResult.getNewGlobalGroupState().getLocalState());
}
use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by signalapp.
the class GroupStateMapperTest method no_actual_change.
@Test
public void no_actual_change() {
DecryptedGroup currentState = state(0);
ServerGroupLogEntry log1 = serverLogEntry(1);
ServerGroupLogEntry log2 = new ServerGroupLogEntry(DecryptedGroup.newBuilder(log1.getGroup()).setRevision(2).build(), DecryptedGroupChange.newBuilder().setRevision(2).setEditor(UuidUtil.toByteString(KNOWN_EDITOR)).setNewTitle(DecryptedString.newBuilder().setValue(log1.getGroup().getTitle())).build());
AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, asList(log1, log2)), 2);
assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(asList(asLocal(log1), new LocalGroupLogEntry(log2.getGroup(), DecryptedGroupChange.newBuilder().setRevision(2).setEditor(UuidUtil.toByteString(KNOWN_EDITOR)).build()))));
assertTrue(advanceGroupStateResult.getNewGlobalGroupState().getServerHistory().isEmpty());
assertEquals(log2.getGroup(), advanceGroupStateResult.getNewGlobalGroupState().getLocalState());
}
use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by signalapp.
the class GroupStateMapperTest method known_group_two_states_to_update.
@Test
public void known_group_two_states_to_update() {
DecryptedGroup currentState = state(0);
ServerGroupLogEntry log1 = serverLogEntry(1);
ServerGroupLogEntry log2 = serverLogEntry(2);
AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, asList(log1, log2)), 2);
assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(asList(asLocal(log1), asLocal(log2))));
assertTrue(advanceGroupStateResult.getNewGlobalGroupState().getServerHistory().isEmpty());
assertEquals(log2.getGroup(), advanceGroupStateResult.getNewGlobalGroupState().getLocalState());
}
use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by signalapp.
the class GroupStateMapperTest method clears_changes_duplicated_in_the_placeholder.
@Test
public void clears_changes_duplicated_in_the_placeholder() {
UUID newMemberUuid = UUID.randomUUID();
DecryptedMember newMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(newMemberUuid)).build();
DecryptedMember existingMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(UUID.randomUUID())).build();
DecryptedGroup currentState = DecryptedGroup.newBuilder().setRevision(GroupStateMapper.PLACEHOLDER_REVISION).setTitle("Group Revision " + 8).addMembers(newMember).build();
ServerGroupLogEntry log8 = new ServerGroupLogEntry(DecryptedGroup.newBuilder().setRevision(8).addMembers(newMember).addMembers(existingMember).setTitle("Group Revision " + 8).build(), DecryptedGroupChange.newBuilder().setRevision(8).setEditor(UuidUtil.toByteString(newMemberUuid)).addNewMembers(newMember).build());
AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, singletonList(log8)), LATEST);
assertNotNull(log8.getGroup());
assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(emptyList()));
assertNewState(new GlobalGroupState(log8.getGroup(), emptyList()), advanceGroupStateResult.getNewGlobalGroupState());
assertEquals(log8.getGroup(), advanceGroupStateResult.getNewGlobalGroupState().getLocalState());
}
use of org.signal.storageservice.protos.groups.local.DecryptedGroup in project Signal-Android by signalapp.
the class GroupStateMapperTest method known_group_three_states_to_update_update_latest.
@Test
public void known_group_three_states_to_update_update_latest() {
DecryptedGroup currentState = state(0);
ServerGroupLogEntry log1 = serverLogEntry(1);
ServerGroupLogEntry log2 = serverLogEntry(2);
ServerGroupLogEntry log3 = serverLogEntry(3);
AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, asList(log1, log2, log3)), LATEST);
assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(asList(asLocal(log1), asLocal(log2), asLocal(log3))));
assertNewState(new GlobalGroupState(log3.getGroup(), emptyList()), advanceGroupStateResult.getNewGlobalGroupState());
assertEquals(log3.getGroup(), advanceGroupStateResult.getNewGlobalGroupState().getLocalState());
}
Aggregations