From 7bee2a268793126920c7acf220bfdc46dd83f780 Mon Sep 17 00:00:00 2001 From: Lentil Hoffman Date: Thu, 19 Jun 2025 16:44:13 -0500 Subject: [PATCH] refactor: simplify node startup and improve test reliability - Remove waitForReady option from RhizomeNode.start() and always wait for readiness - Update test files to use simplified start() method - Clean up debug logging in lossless view - Rename docker orchestrator test file to remove version suffix --- __tests__/run/002-two-nodes.ts | 2 +- ...strator-v2.ts => 005-docker-orchestrator.ts} | 0 src/node.ts | 17 +++++------------ src/orchestration/test-orchestrator/index.ts | 2 +- src/views/lossless.ts | 1 - 5 files changed, 7 insertions(+), 15 deletions(-) rename __tests__/run/{005-docker-orchestrator-v2.ts => 005-docker-orchestrator.ts} (100%) diff --git a/__tests__/run/002-two-nodes.ts b/__tests__/run/002-two-nodes.ts index 26c8777..390ebf1 100644 --- a/__tests__/run/002-two-nodes.ts +++ b/__tests__/run/002-two-nodes.ts @@ -17,7 +17,7 @@ describe('Run', () => { apps[0].config.seedPeers.push(apps[1].myRequestAddr); apps[1].config.seedPeers.push(apps[0].myRequestAddr); - await Promise.all(apps.map((app) => app.start({ waitForReady: false }))); + await Promise.all(apps.map((app) => app.start())); }); afterAll(async () => { diff --git a/__tests__/run/005-docker-orchestrator-v2.ts b/__tests__/run/005-docker-orchestrator.ts similarity index 100% rename from __tests__/run/005-docker-orchestrator-v2.ts rename to __tests__/run/005-docker-orchestrator.ts diff --git a/src/node.ts b/src/node.ts index 398e812..9d5859e 100644 --- a/src/node.ts +++ b/src/node.ts @@ -83,16 +83,13 @@ export class RhizomeNode { /** * Start the node components - * @param options.startupOptions Options for node startup - * @param options.waitForReady Whether to wait for all components to be fully ready (default: false) * @param options.syncOnStart Whether to sync with peers on startup (default: false) - * @returns Promise that resolves when the node is started (and ready if waitForReady is true) + * @returns Promise that resolves when the node is fully started and ready */ async start({ - waitForReady = false, syncOnStart = false - }: { waitForReady?: boolean; syncOnStart?: boolean } = {}): Promise { - debug(`[${this.config.peerId}]`, `Starting node${waitForReady ? ' (waiting for ready)' : ''}...`); + }: { syncOnStart?: boolean } = {}): Promise { + debug(`[${this.config.peerId}]`, 'Starting node (waiting for ready)...'); // Connect our lossless view to the delta stream this.deltaStream.subscribeDeltas(async (delta) => { @@ -115,11 +112,7 @@ export class RhizomeNode { // Start HTTP server if enabled if (this.config.httpEnable && this.httpServer) { - if (waitForReady) { - await this.httpServer.startAndWait(); - } else { - this.httpServer.start(); - } + await this.httpServer.startAndWait(); } // Initialize network components @@ -132,7 +125,7 @@ export class RhizomeNode { await new Promise((resolve) => setTimeout(resolve, 1000)); } - debug(`[${this.config.peerId}]`, `Node started${waitForReady ? ' and ready' : ''}`); + debug(`[${this.config.peerId}]`, 'Node started and ready'); } async stop() { diff --git a/src/orchestration/test-orchestrator/index.ts b/src/orchestration/test-orchestrator/index.ts index 45317bf..38f5280 100644 --- a/src/orchestration/test-orchestrator/index.ts +++ b/src/orchestration/test-orchestrator/index.ts @@ -61,7 +61,7 @@ export class TestOrchestrator extends BaseOrchestrator { // Start the node and wait for all components to be ready debug(`[${nodeId}] Starting node and waiting for it to be fully ready...`); try { - await node.start({ waitForReady: true }); + await node.start(); debug(`[${nodeId}] Node is fully started and ready`); } catch (error) { debug(`[${nodeId}] Error starting node:`, error); diff --git a/src/views/lossless.ts b/src/views/lossless.ts index 6b1fb02..1bf01b3 100644 --- a/src/views/lossless.ts +++ b/src/views/lossless.ts @@ -172,7 +172,6 @@ export class Lossless { viewSpecific(entityId: DomainEntityID, deltaIds: DeltaID[], deltaFilter?: DeltaFilter): LosslessViewOne | undefined { const combinedFilter = (delta: Delta) => { if (!deltaIds.includes(delta.id)) { - debug(`[${this.rhizomeNode.config.peerId}]`, `Excluding delta ${delta.id} because it's not in the requested list of deltas`); return false; } if (!deltaFilter) return true;