perf: expand gateway capacity and prevent receipt replay
This commit is contained in:
@@ -11,7 +11,8 @@ describe('GatewayCallbackController', () => {
|
||||
const prisma = { $queryRaw: jest.fn(), getPoolState: jest.fn().mockReturnValue({ max: 16, total: 2, idle: 1, waiting: 0 }) };
|
||||
const controller = new GatewayCallbackController(sendChain as never, protocolLogs as never, prisma as never);
|
||||
|
||||
beforeEach(() => jest.clearAllMocks());
|
||||
beforeEach(() => { jest.clearAllMocks(); process.env.PROTOCOL_LOG_CALLBACK_TRACKING_ENABLED = 'true'; });
|
||||
afterAll(() => { delete process.env.PROTOCOL_LOG_CALLBACK_TRACKING_ENABLED; });
|
||||
|
||||
it('keeps Submit result persistence on the callback process without duplicating protocol logs', async () => {
|
||||
sendChain.handleSubmitResult.mockResolvedValue({ accepted: true });
|
||||
@@ -40,4 +41,20 @@ describe('GatewayCallbackController', () => {
|
||||
protocol: 'cmpp', direction: 'client_to_platform', eventType: 'submit', status: 'success',
|
||||
})).toThrow(BadRequestException);
|
||||
});
|
||||
|
||||
it('returns an independent result for every event in a callback batch', async () => {
|
||||
sendChain.handleSubmitResult.mockResolvedValue({ accepted: true });
|
||||
sendChain.handleUplink.mockResolvedValue({ accepted: true });
|
||||
await expect(controller.batch({
|
||||
batchId: 'CB-1', gatewayInstanceId: 'gateway-1', events: [
|
||||
{ eventId: 'EV-1', type: 'submit_result', payload: { messageId: 'MSG-1', channelId: 'channel-1', submitStatus: 'accepted' } },
|
||||
{ eventId: 'EV-2', type: 'uplink', payload: { messageId: 'MSG-1', channelId: 'channel-1', content: '1' } },
|
||||
{ eventId: 'EV-3', type: 'unsupported', payload: {} },
|
||||
],
|
||||
})).resolves.toEqual({ batchId: 'CB-1', results: [
|
||||
{ eventId: 'EV-1', accepted: true },
|
||||
{ eventId: 'EV-2', accepted: true },
|
||||
{ eventId: 'EV-3', accepted: false, retryable: false, errorCode: 'INVALID_EVENT' },
|
||||
] });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user