Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# RemitLend

123

[![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
[![Frontend: Next.js](https://img.shields.io/badge/Frontend-Next.js-black?logo=next.js)](https://nextjs.org/)
[![Backend: Express](https://img.shields.io/badge/Backend-Express.js-white?logo=express)](https://expressjs.com/)
Expand Down
24 changes: 1 addition & 23 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions backend/src/__tests__/adminGovernanceController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
delete process.env.GOVERNANCE_CURRENT_ADMIN;
delete process.env.MULTISIG_GOVERNANCE_CONTRACT_ID;
delete process.env.GOVERNANCE_THRESHOLD;
delete process.env.GOVERNANCE_SIGNERS;
});

it('filters signers so signers from older pending proposals are not mixed in', async () => {
const req = {} as Request;
const res = createMockResponse();

// Database returns rows from multiple proposals (ordered by proposal_id DESC)
mockQuery.mockResolvedValueOnce({
rows: [
{
Expand All @@ -66,7 +66,7 @@
approved: false,
},
{
proposal_id: 'prop-1', // Older proposal
proposal_id: 'prop-1',
proposed_admin: 'GOLD_ADMIN_1',
approval_count: 2,
threshold: 2,
Expand All @@ -83,26 +83,29 @@
await flushAsync();

expect(res.json).toHaveBeenCalledTimes(1);

const responseData = (res.json as jest.Mock).mock.calls[0]?.[0] as Record<string, any>;

Check warning on line 87 in backend/src/__tests__/adminGovernanceController.test.ts

View workflow job for this annotation

GitHub Actions / backend

Unexpected any. Specify a different type

expect(responseData.pendingProposal).toBeDefined();
expect(responseData.pendingProposal.id).toBe('prop-2');
expect(responseData.pendingProposal.proposedAdmin).toBe('GNEW_ADMIN_2');

// Crucial check: only prop-2 signers should be included, NOT prop-1 signer
const signers = responseData.pendingProposal.signers;

expect(signers).toHaveLength(2);
expect(signers).toEqual([
{ address: 'GSIGNER_PROP2_APPROVED', approved: true },
{ address: 'GSIGNER_PROP2_PENDING', approved: false },
]);

expect(signers.some((s: { address: string }) => s.address === 'GSIGNER_PROP1_ONLY')).toBe(
false,
);
});

it('returns fallback signers from env when no pending proposal exists', async () => {
process.env.GOVERNANCE_SIGNERS = 'GSIGNER_1, GSIGNER_2';

const req = {} as Request;
const res = createMockResponse();

Expand Down
7 changes: 4 additions & 3 deletions backend/src/__tests__/remittanceFilters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ jest.unstable_mockModule('../services/notificationService.js', () => ({
}));

jest.unstable_mockModule('../utils/stellarEnvelope.js', () => ({
parseAndValidateSignedEnvelope: jest
.fn()
.mockReturnValue({ source: 'GCWEPACYJLN7S3ZUXSVMXZBFKYXSHRGZ6O326HDDPDKBKZPXD45XNHC3', signatureCount: 1 }),
parseAndValidateSignedEnvelope: jest.fn().mockReturnValue({
source: 'GCWEPACYJLN7S3ZUXSVMXZBFKYXSHRGZ6O326HDDPDKBKZPXD45XNHC3',
signatureCount: 1,
}),
}));

const mockQuery = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ describe('getAuditLogs keyset pagination and totals (#1808)', () => {
it('omits the count query unless withTotal is set', async () => {
await getAuditLogs({ limit: 2 });

const countCalls = mockQuery.mock.calls.filter(([text]) =>
String(text).includes('COUNT(*)'),
);
const countCalls = mockQuery.mock.calls.filter(([text]) => String(text).includes('COUNT(*)'));
expect(countCalls).toHaveLength(0);
});

Expand All @@ -122,9 +120,7 @@ describe('getAuditLogs keyset pagination and totals (#1808)', () => {
limit: 2,
});

const countCall = mockQuery.mock.calls.find(([text]) =>
String(text).includes('COUNT(*)'),
);
const countCall = mockQuery.mock.calls.find(([text]) => String(text).includes('COUNT(*)'));
const countSql = String(countCall?.[0]);
const countValues = (countCall?.[1] as unknown[]) ?? [];

Expand Down
3 changes: 1 addition & 2 deletions backend/src/services/auditLogService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export function encodeCursor(row: Record<string, unknown> | undefined): string |
const id = row.id;
const createdAt = row.created_at;
if (id === undefined || id === null || !createdAt) return null;
const createdAtIso =
createdAt instanceof Date ? createdAt.toISOString() : String(createdAt);
const createdAtIso = createdAt instanceof Date ? createdAt.toISOString() : String(createdAt);
return `${createdAtIso}${CURSOR_SEPARATOR}${String(id)}`;
}

Expand Down
21 changes: 8 additions & 13 deletions backend/src/tests/idempotency.namespace.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Request, Response, NextFunction } from 'express';
import { idempotencyMiddleware, computeFingerprint, namespacedKey } from '../middleware/idempotency.js';
import {
idempotencyMiddleware,
computeFingerprint,
namespacedKey,
} from '../middleware/idempotency.js';
import { cacheService } from '../services/cacheService.js';
import { jest } from '@jest/globals';

Expand Down Expand Up @@ -33,8 +37,7 @@ describe('idempotencyMiddleware key namespacing (#1809)', () => {
return request;
};

const cacheKeysRead = () =>
asMock(cacheService.get).mock.calls.map(([key]) => String(key));
const cacheKeysRead = () => asMock(cacheService.get).mock.calls.map(([key]) => String(key));

beforeEach(() => {
req = buildRequest(ALICE);
Expand Down Expand Up @@ -75,11 +78,7 @@ describe('idempotencyMiddleware key namespacing (#1809)', () => {

jest.clearAllMocks();
asMock(cacheService.setNotExists).mockResolvedValue(true);
await idempotencyMiddleware(
buildRequest(BOB) as Request,
res as Response,
next,
);
await idempotencyMiddleware(buildRequest(BOB) as Request, res as Response, next);
const bobKey = cacheKeysRead()[0];

expect(aliceKey).not.toBe(bobKey);
Expand Down Expand Up @@ -173,11 +172,7 @@ describe('idempotencyMiddleware key namespacing (#1809)', () => {

jest.clearAllMocks();
asMock(cacheService.setNotExists).mockResolvedValue(true);
await idempotencyMiddleware(
buildRequest(undefined) as Request,
res as Response,
next,
);
await idempotencyMiddleware(buildRequest(undefined) as Request, res as Response, next);

expect(cacheKeysRead()[0]).toBe(first);
expect(first).toContain('anon');
Expand Down
Loading