Increment unprocessed attempts when fetching
This commit is contained in:
parent
6d576ed901
commit
d6b58d23d6
6 changed files with 77 additions and 41 deletions
|
@ -1499,7 +1499,8 @@ describe('SignalProtocolStore', () => {
|
|||
assert.equal(await store.loadSession(id), testSession);
|
||||
assert.equal(await store.getSenderKey(id, distributionId), testSenderKey);
|
||||
|
||||
const allUnprocessed = await store.getAllUnprocessed();
|
||||
const allUnprocessed =
|
||||
await store.getAllUnprocessedAndIncrementAttempts();
|
||||
assert.deepEqual(
|
||||
allUnprocessed.map(({ envelope }) => envelope),
|
||||
['second']
|
||||
|
@ -1551,7 +1552,7 @@ describe('SignalProtocolStore', () => {
|
|||
|
||||
assert.equal(await store.loadSession(id), testSession);
|
||||
assert.equal(await store.getSenderKey(id, distributionId), testSenderKey);
|
||||
assert.deepEqual(await store.getAllUnprocessed(), []);
|
||||
assert.deepEqual(await store.getAllUnprocessedAndIncrementAttempts(), []);
|
||||
});
|
||||
|
||||
it('can be re-entered', async () => {
|
||||
|
@ -1647,7 +1648,7 @@ describe('SignalProtocolStore', () => {
|
|||
|
||||
beforeEach(async () => {
|
||||
await store.removeAllUnprocessed();
|
||||
const items = await store.getAllUnprocessed();
|
||||
const items = await store.getAllUnprocessedAndIncrementAttempts();
|
||||
assert.strictEqual(items.length, 0);
|
||||
});
|
||||
|
||||
|
@ -1687,7 +1688,7 @@ describe('SignalProtocolStore', () => {
|
|||
}),
|
||||
]);
|
||||
|
||||
const items = await store.getAllUnprocessed();
|
||||
const items = await store.getAllUnprocessedAndIncrementAttempts();
|
||||
assert.strictEqual(items.length, 3);
|
||||
|
||||
// they are in the proper order because the collection comparator is 'timestamp'
|
||||
|
@ -1708,10 +1709,11 @@ describe('SignalProtocolStore', () => {
|
|||
});
|
||||
await store.updateUnprocessedWithData(id, { decrypted: 'updated' });
|
||||
|
||||
const items = await store.getAllUnprocessed();
|
||||
const items = await store.getAllUnprocessedAndIncrementAttempts();
|
||||
assert.strictEqual(items.length, 1);
|
||||
assert.strictEqual(items[0].decrypted, 'updated');
|
||||
assert.strictEqual(items[0].timestamp, NOW + 1);
|
||||
assert.strictEqual(items[0].attempts, 1);
|
||||
});
|
||||
|
||||
it('removeUnprocessed successfully deletes item', async () => {
|
||||
|
@ -1726,7 +1728,21 @@ describe('SignalProtocolStore', () => {
|
|||
});
|
||||
await store.removeUnprocessed(id);
|
||||
|
||||
const items = await store.getAllUnprocessed();
|
||||
const items = await store.getAllUnprocessedAndIncrementAttempts();
|
||||
assert.strictEqual(items.length, 0);
|
||||
});
|
||||
|
||||
it('getAllUnprocessedAndIncrementAttempts deletes items', async () => {
|
||||
await store.addUnprocessed({
|
||||
id: '1-one',
|
||||
envelope: 'first',
|
||||
timestamp: NOW + 1,
|
||||
receivedAtCounter: 0,
|
||||
version: 2,
|
||||
attempts: 3,
|
||||
});
|
||||
|
||||
const items = await store.getAllUnprocessedAndIncrementAttempts();
|
||||
assert.strictEqual(items.length, 0);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue