Removed hard limit on unprocessed messages in cache

This commit is contained in:
Alvaro 2023-02-02 12:39:07 -07:00 committed by GitHub
parent 1381e8df5d
commit e51f582bfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 130 additions and 44 deletions

View file

@ -1273,7 +1273,10 @@ describe('SignalProtocolStore', () => {
assert.equal(await store.getSenderKey(id, distributionId), testSenderKey);
const allUnprocessed =
await store.getAllUnprocessedAndIncrementAttempts();
await store.getUnprocessedByIdsAndIncrementAttempts(
await store.getAllUnprocessedIds()
);
assert.deepEqual(
allUnprocessed.map(({ envelope }) => envelope),
['second']
@ -1327,7 +1330,12 @@ describe('SignalProtocolStore', () => {
assert.equal(await store.loadSession(id), testSession);
assert.equal(await store.getSenderKey(id, distributionId), testSenderKey);
assert.deepEqual(await store.getAllUnprocessedAndIncrementAttempts(), []);
assert.deepEqual(
await store.getUnprocessedByIdsAndIncrementAttempts(
await store.getAllUnprocessedIds()
),
[]
);
});
it('can be re-entered', async () => {
@ -1423,7 +1431,9 @@ describe('SignalProtocolStore', () => {
beforeEach(async () => {
await store.removeAllUnprocessed();
const items = await store.getAllUnprocessedAndIncrementAttempts();
const items = await store.getUnprocessedByIdsAndIncrementAttempts(
await store.getAllUnprocessedIds()
);
assert.strictEqual(items.length, 0);
});
@ -1471,7 +1481,9 @@ describe('SignalProtocolStore', () => {
}),
]);
const items = await store.getAllUnprocessedAndIncrementAttempts();
const items = await store.getUnprocessedByIdsAndIncrementAttempts(
await store.getAllUnprocessedIds()
);
assert.strictEqual(items.length, 3);
// they are in the proper order because the collection comparator is
@ -1495,7 +1507,9 @@ describe('SignalProtocolStore', () => {
});
await store.updateUnprocessedWithData(id, { decrypted: 'updated' });
const items = await store.getAllUnprocessedAndIncrementAttempts();
const items = await store.getUnprocessedByIdsAndIncrementAttempts(
await store.getAllUnprocessedIds()
);
assert.strictEqual(items.length, 1);
assert.strictEqual(items[0].decrypted, 'updated');
assert.strictEqual(items[0].timestamp, NOW + 1);
@ -1517,7 +1531,9 @@ describe('SignalProtocolStore', () => {
});
await store.removeUnprocessed(id);
const items = await store.getAllUnprocessedAndIncrementAttempts();
const items = await store.getUnprocessedByIdsAndIncrementAttempts(
await store.getAllUnprocessedIds()
);
assert.strictEqual(items.length, 0);
});
@ -1533,7 +1549,9 @@ describe('SignalProtocolStore', () => {
urgent: true,
});
const items = await store.getAllUnprocessedAndIncrementAttempts();
const items = await store.getUnprocessedByIdsAndIncrementAttempts(
await store.getAllUnprocessedIds()
);
assert.strictEqual(items.length, 0);
});
});