Fix timestamp capping for storage service
This commit is contained in:
parent
96f731270f
commit
24391af642
5 changed files with 141 additions and 7 deletions
80
ts/test-node/sql/migration_1310_test.ts
Normal file
80
ts/test-node/sql/migration_1310_test.ts
Normal file
|
@ -0,0 +1,80 @@
|
|||
// Copyright 2025 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { type WritableDB } from '../../sql/Interface';
|
||||
import { createDB, updateToVersion, insertData, getTableData } from './helpers';
|
||||
|
||||
describe('SQL/updateToSchemaVersion1310', () => {
|
||||
let db: WritableDB;
|
||||
|
||||
afterEach(() => {
|
||||
db.close();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
db = createDB();
|
||||
updateToVersion(db, 1300);
|
||||
});
|
||||
|
||||
it('leaves absent muteExpiresAt untouched', () => {
|
||||
const convos = [
|
||||
{
|
||||
id: 'convo',
|
||||
expireTimerVersion: 1,
|
||||
json: {},
|
||||
},
|
||||
];
|
||||
insertData(db, 'conversations', convos);
|
||||
updateToVersion(db, 1310);
|
||||
|
||||
assert.deepStrictEqual(getTableData(db, 'conversations'), convos);
|
||||
});
|
||||
|
||||
it('leaves regular muteExpiresAt untouched', () => {
|
||||
const convos = [
|
||||
{
|
||||
id: 'convo',
|
||||
expireTimerVersion: 1,
|
||||
json: {
|
||||
muteExpiresAt: 123,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'convo-2',
|
||||
expireTimerVersion: 1,
|
||||
json: {
|
||||
muteExpiresAt: 8640000000000000 - 1,
|
||||
},
|
||||
},
|
||||
];
|
||||
insertData(db, 'conversations', convos);
|
||||
updateToVersion(db, 1310);
|
||||
|
||||
assert.deepStrictEqual(getTableData(db, 'conversations'), convos);
|
||||
});
|
||||
|
||||
it('promotes MAX_SAFE_DATE to MAX_SAFE_INTEGER', () => {
|
||||
insertData(db, 'conversations', [
|
||||
{
|
||||
id: 'convo',
|
||||
expireTimerVersion: 1,
|
||||
json: {
|
||||
muteExpiresAt: 8640000000000000,
|
||||
},
|
||||
},
|
||||
]);
|
||||
updateToVersion(db, 1310);
|
||||
|
||||
assert.deepStrictEqual(getTableData(db, 'conversations'), [
|
||||
{
|
||||
id: 'convo',
|
||||
expireTimerVersion: 1,
|
||||
json: {
|
||||
muteExpiresAt: Number.MAX_SAFE_INTEGER,
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue