@@ -8,10 +8,7 @@ import { startMatrixQaFaultProxy } from "../substrate/fault-proxy.js";
88import type { MatrixQaCliSession } from "./scenario-runtime-cli.js" ;
99import { runMatrixQaE2eeCliEncryptionSetupBootstrapFailureScenario } from "./scenario-runtime-e2ee-cli-account.js" ;
1010import { MATRIX_QA_ROOM_KEY_BACKUP_VERSION_ENDPOINT } from "./scenario-runtime-e2ee-shared.js" ;
11- import {
12- assertMatrixQaTestPortClosed ,
13- createMatrixQaE2eeTestContext ,
14- } from "./scenario-runtime-e2ee.test-helpers.js" ;
11+ import { createMatrixQaE2eeTestContext } from "./scenario-runtime-e2ee.test-helpers.js" ;
1512
1613const mocks = vi . hoisted ( ( ) => ( { createRuntime : vi . fn ( ) } ) ) ;
1714vi . mock ( "./scenario-runtime-e2ee-cli-runtime.js" , ( ) => ( {
@@ -65,6 +62,8 @@ describe("Matrix CLI bootstrap failure evidence and ownership", () => {
6562 stop : async ( ) => {
6663 await beforeProxyStop ?.( ) ;
6764 stopping = proxy . stop ( ) . then ( ( ) => {
65+ // The real stop joins this server's close event. Its released port may
66+ // already belong to another worker when the scenario settles.
6867 closed = true ;
6968 } ) ;
7069 await stopping ;
@@ -128,7 +127,7 @@ describe("Matrix CLI bootstrap failure evidence and ownership", () => {
128127 async ( { methods } ) => {
129128 configureCli ( methods ) ;
130129 await expect ( run ( ) ) . rejects . toThrow ( "did not attempt faulted room-key backup creation" ) ;
131- await assertMatrixQaTestPortClosed ( proxy . baseUrl ) ;
130+ expect ( closed ) . toBe ( true ) ;
132131 expect ( dispose ) . toHaveBeenCalledOnce ( ) ;
133132 } ,
134133 ) ;
@@ -138,19 +137,19 @@ describe("Matrix CLI bootstrap failure evidence and ownership", () => {
138137 await expect ( run ( ) ) . resolves . toMatchObject ( {
139138 artifacts : { bootstrapSuccess : false , faultHitCount : 2 } ,
140139 } ) ;
141- await assertMatrixQaTestPortClosed ( proxy . baseUrl ) ;
140+ expect ( closed ) . toBe ( true ) ;
142141 closed = false ;
143142 configureCli ( [ "POST" ] , "unrelated failure" ) ;
144143 await expect ( run ( ) ) . rejects . toThrow ( "unexpected reason" ) ;
145- await assertMatrixQaTestPortClosed ( proxy . baseUrl ) ;
144+ expect ( closed ) . toBe ( true ) ;
146145 } ) ;
147146
148147 it . each ( [ new Error ( "runtime construction failed" ) , undefined , "construction rejected" ] ) (
149148 "closes the already-acquired proxy and preserves construction rejection %s" ,
150149 async ( failure ) => {
151150 mocks . createRuntime . mockRejectedValueOnce ( failure ) ;
152151 await expect ( run ( ) ) . rejects . toBe ( failure ) ;
153- await assertMatrixQaTestPortClosed ( proxy . baseUrl ) ;
152+ expect ( closed ) . toBe ( true ) ;
154153 } ,
155154 ) ;
156155
@@ -163,7 +162,7 @@ describe("Matrix CLI bootstrap failure evidence and ownership", () => {
163162 cause : failure ,
164163 errors : [ failure , proxyCleanupFailure ] ,
165164 } ) ;
166- await assertMatrixQaTestPortClosed ( proxy . baseUrl ) ;
165+ expect ( closed ) . toBe ( true ) ;
167166 } ,
168167 ) ;
169168
@@ -173,7 +172,7 @@ describe("Matrix CLI bootstrap failure evidence and ownership", () => {
173172 configureCli ( [ "POST" ] ) ;
174173 dispose . mockRejectedValueOnce ( failure ) ;
175174 await expect ( run ( ) ) . rejects . toBe ( failure ) ;
176- await assertMatrixQaTestPortClosed ( proxy . baseUrl ) ;
175+ expect ( closed ) . toBe ( true ) ;
177176 } ,
178177 ) ;
179178
@@ -186,7 +185,7 @@ describe("Matrix CLI bootstrap failure evidence and ownership", () => {
186185 cause : disposalFailure ,
187186 errors : [ disposalFailure , proxyCleanupFailure ] ,
188187 } ) ;
189- await assertMatrixQaTestPortClosed ( proxy . baseUrl ) ;
188+ expect ( closed ) . toBe ( true ) ;
190189 } ) ;
191190
192191 it ( "joins proxy cleanup before returning a CLI disposal failure" , async ( ) => {
@@ -212,6 +211,6 @@ describe("Matrix CLI bootstrap failure evidence and ownership", () => {
212211 release . resolve ( ) ;
213212 expect ( await operation ) . toBe ( disposalFailure ) ;
214213 }
215- await assertMatrixQaTestPortClosed ( proxy . baseUrl ) ;
214+ expect ( closed ) . toBe ( true ) ;
216215 } ) ;
217216} ) ;
0 commit comments