Introduce versioning clock to timer system
This commit is contained in:
parent
bb1d957e49
commit
2fb50df0af
34 changed files with 703 additions and 28 deletions
|
@ -68,7 +68,7 @@ describe('pnp/merge', function (this: Mocha.Suite) {
|
|||
|
||||
serviceE164: undefined,
|
||||
identityKey: aciIdentityKey,
|
||||
givenName: pniContact.profileName,
|
||||
givenName: 'ACI Contact',
|
||||
});
|
||||
|
||||
// Put both contacts in left pane
|
||||
|
@ -454,4 +454,88 @@ describe('pnp/merge', function (this: Mocha.Suite) {
|
|||
assert.strictEqual(await messages.count(), 0, 'message count');
|
||||
}
|
||||
});
|
||||
|
||||
it('preserves expireTimerVersion after merge', async () => {
|
||||
const { phone, desktop } = bootstrap;
|
||||
|
||||
for (const key of ['aci' as const, 'pni' as const]) {
|
||||
debug(`Send a ${key} sync message`);
|
||||
const timestamp = bootstrap.getTimestamp();
|
||||
const destinationServiceId = pniContact.device[key];
|
||||
const destination = key === 'pni' ? pniContact.device.number : undefined;
|
||||
const content = {
|
||||
syncMessage: {
|
||||
sent: {
|
||||
destinationServiceId,
|
||||
destination,
|
||||
timestamp: Long.fromNumber(timestamp),
|
||||
message: {
|
||||
timestamp: Long.fromNumber(timestamp),
|
||||
flags: Proto.DataMessage.Flags.EXPIRATION_TIMER_UPDATE,
|
||||
expireTimer: key === 'pni' ? 90 * 24 * 3600 : 60 * 24 * 3600,
|
||||
expireTimerVersion: key === 'pni' ? 3 : 4,
|
||||
},
|
||||
unidentifiedStatus: [
|
||||
{
|
||||
destinationServiceId,
|
||||
destination,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
const sendOptions = {
|
||||
timestamp,
|
||||
};
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await phone.sendRaw(desktop, content, sendOptions);
|
||||
}
|
||||
|
||||
debug(
|
||||
'removing both contacts from storage service, adding one combined contact'
|
||||
);
|
||||
{
|
||||
const state = await phone.expectStorageState('consistency check');
|
||||
await phone.setStorageState(
|
||||
state.mergeContact(pniContact, {
|
||||
identityState: Proto.ContactRecord.IdentityState.DEFAULT,
|
||||
whitelisted: true,
|
||||
identityKey: pniContact.publicKey.serialize(),
|
||||
profileKey: pniContact.profileKey.serialize(),
|
||||
pniSignatureVerified: true,
|
||||
})
|
||||
);
|
||||
await phone.sendFetchStorage({
|
||||
timestamp: bootstrap.getTimestamp(),
|
||||
});
|
||||
await app.waitForManifestVersion(state.version);
|
||||
}
|
||||
|
||||
const window = await app.getWindow();
|
||||
const leftPane = window.locator('#LeftPane');
|
||||
|
||||
debug('opening conversation with the merged contact');
|
||||
await leftPane
|
||||
.locator(
|
||||
`[data-testid="${pniContact.device.aci}"] >> ` +
|
||||
`"${pniContact.profileName}"`
|
||||
)
|
||||
.click();
|
||||
|
||||
await window.locator('.module-conversation-hero').waitFor();
|
||||
|
||||
debug('Send message to merged contact');
|
||||
{
|
||||
const compositionInput = await app.waitForEnabledComposer();
|
||||
|
||||
await typeIntoInput(compositionInput, 'Hello merged');
|
||||
await compositionInput.press('Enter');
|
||||
}
|
||||
|
||||
debug('Getting message to merged contact');
|
||||
const { body, dataMessage } = await pniContact.waitForMessage();
|
||||
assert.strictEqual(body, 'Hello merged');
|
||||
assert.strictEqual(dataMessage.expireTimer, 60 * 24 * 3600);
|
||||
assert.strictEqual(dataMessage.expireTimerVersion, 4);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue