refactor: split brokerage operations repository and cursor codec (WealthLedger/backend#167) (#190)
This commit was merged in pull request #190.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { decode, encode } from './local-operations-cursor.codec';
|
||||
|
||||
const secret = 'secret';
|
||||
const cursor = {
|
||||
accountId: 'account',
|
||||
at: '2026-01-01T00:00:00.000Z',
|
||||
binding: 'owner-filter-binding',
|
||||
id: 'operation',
|
||||
movingEnd: false,
|
||||
to: '2026-02-01T00:00:00.000Z',
|
||||
};
|
||||
|
||||
describe('local operations cursor', () => {
|
||||
it('roundtrips the opaque cursor, including its owner and filter binding', () => {
|
||||
expect(decode(encode(cursor, secret), secret)).toEqual(cursor);
|
||||
});
|
||||
|
||||
it('rejects a tampered cursor and a cursor signed with a different key', () => {
|
||||
const encoded = encode(cursor, secret);
|
||||
expect(() => decode(`${encoded}x`, secret)).toThrow();
|
||||
expect(() => decode(encoded, 'different-secret')).toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user