Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/app-worker-unit-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nostream": patch
---

Add comprehensive unit tests for remaining app-level workers (AppWorker, App, StaticMirroringWorker) with 65+ test cases covering lifecycle, configuration, error handling, and dependency injection
8 changes: 4 additions & 4 deletions src/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export class App implements IRunnable {
░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░░ ░ ░ ░ ▒ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░`)
const width = 74
const torHiddenServicePort = process.env.HIDDEN_SERVICE_PORT ? Number(process.env.HIDDEN_SERVICE_PORT) : 80
const port = process.env.RELAY_PORT ? Number(process.env.RELAY_PORT) : 8008
const torHiddenServicePort = this.process.env.HIDDEN_SERVICE_PORT ? Number(this.process.env.HIDDEN_SERVICE_PORT) : 80
const port = this.process.env.RELAY_PORT ? Number(this.process.env.RELAY_PORT) : 8008

const logCentered = (input: string, width: number) => {
const start = (width - input.length) >> 1
Expand All @@ -72,8 +72,8 @@ export class App implements IRunnable {
this.process.exit(1)
}

const workerCount = process.env.WORKER_COUNT
? Number(process.env.WORKER_COUNT)
const workerCount = this.process.env.WORKER_COUNT
? Number(this.process.env.WORKER_COUNT)
: this.settings().workers?.count || cpus().length
Comment on lines +75 to 77

const createWorker = (env: Record<string, string>) => {
Expand Down
9 changes: 6 additions & 3 deletions src/app/static-mirroring-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ export class StaticMirroringWorker implements IRunnable {

logger.info('mirroring', currentSettings.mirroring)

this.config = path(['mirroring', 'static', process.env.MIRROR_INDEX], currentSettings) as Mirror
this.config = path(['mirroring', 'static', this.process.env.MIRROR_INDEX], currentSettings) as Mirror
if (!this.config) {
throw new Error(`Mirror configuration not found for index ${this.process.env.MIRROR_INDEX}`)
}

Comment on lines +58 to 62
let since = Math.floor(Date.now() / 1000) - 60 * 10

Expand Down Expand Up @@ -172,7 +175,7 @@ export class StaticMirroringWorker implements IRunnable {

const eventLimits = this.settings().limits?.event ?? {}

const eventLimitOverrides = this.config.limits?.event ?? {}
const eventLimitOverrides = this.config?.limits?.event ?? {}

const limits = mergeDeepRight(eventLimits, eventLimitOverrides) as EventLimits

Expand Down Expand Up @@ -278,7 +281,7 @@ export class StaticMirroringWorker implements IRunnable {
protected async isUserAdmitted(event: Event): Promise<boolean> {
const currentSettings = this.settings()

if (this.config.skipAdmissionCheck === true) {
if (this.config?.skipAdmissionCheck === true) {
return true
}

Expand Down
Loading
Loading