Order unprocessed envelopes by receivedAtCounter

This commit is contained in:
Fedor Indutny 2022-06-10 09:09:21 -07:00 committed by GitHub
parent 924c271b13
commit 6aeddb9301
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 14 deletions

View file

@ -1658,7 +1658,7 @@ describe('SignalProtocolStore', () => {
id: '0-dropped',
envelope: 'old envelope',
timestamp: NOW - 2 * durations.MONTH,
receivedAtCounter: 0,
receivedAtCounter: -1,
version: 2,
attempts: 0,
}),
@ -1666,7 +1666,7 @@ describe('SignalProtocolStore', () => {
id: '2-two',
envelope: 'second',
timestamp: NOW + 2,
receivedAtCounter: 0,
receivedAtCounter: 1,
version: 2,
attempts: 0,
}),
@ -1674,7 +1674,7 @@ describe('SignalProtocolStore', () => {
id: '3-three',
envelope: 'third',
timestamp: NOW + 3,
receivedAtCounter: 0,
receivedAtCounter: 2,
version: 2,
attempts: 0,
}),
@ -1691,7 +1691,8 @@ describe('SignalProtocolStore', () => {
const items = await store.getAllUnprocessedAndIncrementAttempts();
assert.strictEqual(items.length, 3);
// they are in the proper order because the collection comparator is 'timestamp'
// they are in the proper order because the collection comparator is
// 'receivedAtCounter'
assert.strictEqual(items[0].envelope, 'first');
assert.strictEqual(items[1].envelope, 'second');
assert.strictEqual(items[2].envelope, 'third');