Do not track previously tracked failures

This commit is contained in:
Luke Barnard 2018-06-15 14:48:20 +01:00
parent 4a8442901d
commit ac0416af96
2 changed files with 49 additions and 2 deletions

View file

@ -125,4 +125,28 @@ describe.only('DecryptionFailureTracker', function() {
done();
});
it('should not track a failure for an event that was tracked previously', (done) => {
const decryptedEvent = createFailedDecryptionEvent();
const failures = [];
const tracker = new DecryptionFailureTracker((failure) => failures.push(failure));
// Indicate decryption
tracker.eventDecrypted(decryptedEvent);
// Pretend "now" is Infinity
tracker.checkFailures(Infinity);
tracker.trackFailure();
// Indicate a second decryption, after having tracked the failure
tracker.eventDecrypted(decryptedEvent);
tracker.trackFailure();
expect(failures.length).toBe(1, 'should only track a single failure per event');
done();
});
});