perf: expand gateway capacity and prevent receipt replay

This commit is contained in:
hectorzhao
2026-08-25 16:08:30 +08:00
parent 761c123b65
commit 9292352be1
48 changed files with 2001 additions and 144 deletions
+13 -1
View File
@@ -3355,6 +3355,14 @@ describe('SendChainService', () => {
'delivery-once',
]);
expect(service['postGatewayControl']).toHaveBeenCalledTimes(1);
expect(service['postGatewayControl']).toHaveBeenCalledWith(
'/downstream/receipt',
expect.objectContaining({ deliveryId: 'delivery-once', claimId: expect.stringMatching(/^api-direct:/) }),
);
expect(prisma.cmppDownstreamDelivery.updateMany).toHaveBeenCalledWith(expect.objectContaining({
where: { id: 'delivery-once', status: 'pending' },
data: expect.objectContaining({ status: 'dispatching', connectionId: expect.stringMatching(/^api-direct:/) }),
}));
expect(prisma.cmppDownstreamDelivery.create).toHaveBeenCalledTimes(3);
});
@@ -3895,8 +3903,12 @@ describe('SendChainService', () => {
});
prisma.cmppDownstreamDelivery.findMany.mockResolvedValue([]);
await expect(service.listPendingDownstreamDeliveries({ account: '100001', limit: 100 }))
prisma.$queryRaw.mockResolvedValueOnce([]);
await expect(service.listPendingDownstreamDeliveries({ account: '100001', limit: 100, claimId: 'gateway-a:100001:1' }))
.resolves.toEqual([]);
const claimSql = prisma.$queryRaw.mock.calls[0][0].strings.join(' ');
expect(claimSql).toContain('FOR UPDATE SKIP LOCKED');
expect(claimSql).toContain("status = 'dispatching'");
});
it('persists each upstream SubmitResp segment before the aggregate result arrives', async () => {