From 527d372ac012484ffd6221b0bf62495057cefec3 Mon Sep 17 00:00:00 2001 From: Yggdrasil Date: Wed, 14 Oct 2026 02:44:42 -0400 Subject: [PATCH 1/3] test(config): spec for configuration.ts env-parsing Covers the defaults, integer parsing, strict-boolean parsing, and the MAINTENANCE_POOL_CONTRACT_ID -> ESCROW_CONTRACT_ID fallback. Resolves #601 --- src/config/configuration.spec.ts | 57 ++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/config/configuration.spec.ts diff --git a/src/config/configuration.spec.ts b/src/config/configuration.spec.ts new file mode 100644 index 00000000..02ec0cab --- /dev/null +++ b/src/config/configuration.spec.ts @@ -0,0 +1,57 @@ +import configuration from './configuration'; + +describe('configuration (#601)', () => { + const ORIG = process.env; + beforeEach(() => { + process.env = { ...ORIG }; + }); + afterAll(() => { + process.env = ORIG; + }); + + it('uses dev defaults when env is unset', () => { + delete process.env.PORT; + const cfg = configuration(); + expect(cfg.env).toBe('development'); + expect(cfg.jwt.secret).toBe('insecure-dev-secret'); + expect(cfg.stellar.network).toBe('testnet'); + }); + + it('parses integer env vars', () => { + process.env.PORT = '9000'; + process.env.ESCROW_DEADLINE_SECONDS = '3600'; + const cfg = configuration(); + expect(cfg.port).toBe(9000); + expect(cfg.stellar.escrowDeadlineSeconds).toBe(3600); + }); + + it('parses boolean env vars strictly (=== "true")', () => { + process.env.DATABASE_SYNCHRONIZE = 'true'; + process.env.DATABASE_LOGGING = 'false'; + const cfg = configuration(); + expect(cfg.database.synchronize).toBe(true); + expect(cfg.database.logging).toBe(false); + }); + + it('falls back MAINTENANCE_POOL_CONTRACT_ID to ESCROW_CONTRACT_ID', () => { + delete process.env.MAINTENANCE_POOL_CONTRACT_ID; + process.env.ESCROW_CONTRACT_ID = 'escrow-abc'; + expect(configuration().stellar.maintenancePoolContractId).toBe( + 'escrow-abc', + ); + }); + + it('prefers MAINTENANCE_POOL_CONTRACT_ID over the escrow fallback', () => { + process.env.MAINTENANCE_POOL_CONTRACT_ID = 'pool-xyz'; + process.env.ESCROW_CONTRACT_ID = 'escrow-abc'; + expect(configuration().stellar.maintenancePoolContractId).toBe('pool-xyz'); + }); + + it('reads the per-asset contract ids', () => { + process.env.USDC_TOKEN_CONTRACT_ID = 'usdc-1'; + process.env.XLM_TOKEN_CONTRACT_ID = 'xlm-1'; + const cfg = configuration(); + expect(cfg.stellar.assetContractIds.USDC).toBe('usdc-1'); + expect(cfg.stellar.assetContractIds.XLM).toBe('xlm-1'); + }); +}); From 3b309db32f34c4b747877100d2f9bed82382730c Mon Sep 17 00:00:00 2001 From: yggdrasilworld Date: Sun, 18 Oct 2026 21:31:27 -0400 Subject: [PATCH 2/3] test(config): delete NODE_ENV too when asserting dev defaults Jest sets NODE_ENV=test; the spec restored it via the ORIG spread so configuration() returned 'test', not the 'development' default. --- src/config/configuration.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/config/configuration.spec.ts b/src/config/configuration.spec.ts index 02ec0cab..d5e459fd 100644 --- a/src/config/configuration.spec.ts +++ b/src/config/configuration.spec.ts @@ -10,6 +10,7 @@ describe('configuration (#601)', () => { }); it('uses dev defaults when env is unset', () => { + delete process.env.NODE_ENV; delete process.env.PORT; const cfg = configuration(); expect(cfg.env).toBe('development'); From 58d74d16b53ec7a2343f901f5a4fd1f61fcd7641 Mon Sep 17 00:00:00 2001 From: yggdrasilworld Date: Sun, 18 Oct 2026 21:50:20 -0400 Subject: [PATCH 3/3] fix: repair merge glue that left the branch uncompilable The shared base carried half-written merge artifacts: an orphaned invokeOnLockedEscrow block in escrow.service.ts, duplicated returns plus a dead parsePagination in sponsors.controller.ts, and missing describe/it closers in github-webhooks.service.spec.ts. Aligned each with the intended form so the branch typechecks and its specs load. --- src/escrow/escrow.service.ts | 10 ++-------- src/github/github-webhooks.service.spec.ts | 3 +++ src/sponsors/sponsors.controller.ts | 21 --------------------- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/src/escrow/escrow.service.ts b/src/escrow/escrow.service.ts index 6d2dd289..c252993f 100644 --- a/src/escrow/escrow.service.ts +++ b/src/escrow/escrow.service.ts @@ -584,20 +584,14 @@ export class EscrowService { recipients: Array<[string, number]>, manager?: EntityManager, ): Promise { - return this.invokeOnLockedEscrow(escrow, operation, () => - this.soroban.invoke( - 'release', - // `release(issue_id: u64, recipients)` — u64-typed on-chain (#301). - [u64(this.onChainKeyFor(escrow)), recipients], - this.contractOpts(escrow), - ), return this.invokeOnLockedEscrow( escrow, operation, () => this.soroban.invoke( 'release', - [this.onChainKeyFor(escrow), recipients], + // `release(issue_id: u64, recipients)` — u64-typed on-chain (#301). + [u64(this.onChainKeyFor(escrow)), recipients], this.contractOpts(escrow), ), manager, diff --git a/src/github/github-webhooks.service.spec.ts b/src/github/github-webhooks.service.spec.ts index 45bb6fe8..a35ac3be 100644 --- a/src/github/github-webhooks.service.spec.ts +++ b/src/github/github-webhooks.service.spec.ts @@ -869,6 +869,9 @@ describe('GithubWebhooksService', () => { expect(bountiesService.markInReview).not.toHaveBeenCalled(); expect(bountiesService.markMergedAndRelease).not.toHaveBeenCalled(); + }); + }); + // #308: a redelivered X-GitHub-Delivery used to hit the unique constraint // on webhook_events.deliveryId and escape handleEvent as a 500, so every // redelivery of that event failed forever. diff --git a/src/sponsors/sponsors.controller.ts b/src/sponsors/sponsors.controller.ts index b7a48cca..c097bf1e 100644 --- a/src/sponsors/sponsors.controller.ts +++ b/src/sponsors/sponsors.controller.ts @@ -26,25 +26,6 @@ function validatePage(limit?: number, offset?: number) { throw new BadRequestException('offset must be >= 0'); } return { limit, offset }; -/** - * Parse optional limit/offset query params, rejecting NaN, negatives, - * non-integers, and limits above MAX_PAGE_LIMIT with a 400 (#280). - */ -function parsePagination(limit?: string, offset?: string) { - const parse = (name: string, raw: string | undefined, min: number, max: number) => { - if (raw === undefined || raw === '') return undefined; - const n = Number(raw); - if (!Number.isInteger(n) || n < min || n > max) { - throw new BadRequestException( - `${name} must be an integer between ${min} and ${max}`, - ); - } - return n; - }; - return { - limit: parse('limit', limit, 1, MAX_PAGE_LIMIT), - offset: parse('offset', offset, 0, Number.MAX_SAFE_INTEGER), - }; } @ApiTags('sponsors') @@ -73,7 +54,6 @@ export class SponsorsController { ) { this.assertOwnsSponsor(user, id); return this.sponsorsService.dashboard(id, validatePage(limit, offset)); - return this.sponsorsService.dashboard(id, parsePagination(limit, offset)); } @ApiBearerAuth() @@ -91,6 +71,5 @@ export class SponsorsController { id, validatePage(limit, offset), ); - return this.sponsorsService.milestoneProgress(id, parsePagination(limit, offset)); } }