@@ -102,12 +102,12 @@ struct OSCUDPServer_Tests {
102102 }
103103 }
104104
105- let possibleValuePacks : [ OSCValues ] = [
105+ var possibleValuePacks : [ OSCValues ] { [
106106 [ ] ,
107107 [ UUID ( ) . uuidString] ,
108108 [ Int . random ( in: 10_000 ... 10_000_000 ) ] ,
109109 [ Int . random ( in: 10_000 ... 10_000_000 ) , UUID ( ) . uuidString, 456.78 , true ]
110- ]
110+ ] }
111111
112112 let sourceMessages : [ OSCMessage ] = Array ( 1 ... 1000 ) . map { value in
113113 OSCMessage ( " /some/address/ \( UUID ( ) . uuidString) " , values: possibleValuePacks. randomElement ( ) !)
@@ -120,7 +120,7 @@ struct OSCUDPServer_Tests {
120120 }
121121 }
122122
123- try await wait ( require: { await receiver. messages. count == 1000 } , timeout: 5 .0)
123+ try await wait ( require: { await receiver. messages. count == 1000 } , timeout: 10 .0)
124124
125125 await #expect( receiver. messages == sourceMessages)
126126 }
@@ -130,13 +130,15 @@ struct OSCUDPServer_Tests {
130130 func stressTestOnline( ) async throws {
131131 let isFlakey = !isSystemTimingStable( )
132132
133- let server = OSCUDPServer ( port: 8888 , timeTagMode: . ignore, queue: nil , receiveHandler: nil )
133+ // selects a random available port
134+ let server = OSCUDPServer ( port: nil , timeTagMode: . ignore, queue: nil , receiveHandler: nil )
134135 try await Task . sleep ( seconds: isFlakey ? 5.0 : 0.1 )
135136
136137 try server. start ( )
137138 try await Task . sleep ( seconds: isFlakey ? 5.0 : 0.5 )
138139
139- print ( " Using server listen port \( server. localPort) " )
140+ let port = server. localPort
141+ print ( " Using server listen port \( port) " )
140142
141143 final actor Receiver {
142144 var messages : [ OSCMessage ] = [ ]
@@ -153,12 +155,12 @@ struct OSCUDPServer_Tests {
153155 }
154156 }
155157
156- let possibleValuePacks : [ OSCValues ] = [
158+ var possibleValuePacks : [ OSCValues ] { [
157159 [ ] ,
158160 [ UUID ( ) . uuidString] ,
159161 [ Int . random ( in: 10_000 ... 10_000_000 ) ] ,
160162 [ Int . random ( in: 10_000 ... 10_000_000 ) , UUID ( ) . uuidString, 456.78 , true ]
161- ]
163+ ] }
162164
163165 let sourceMessages : [ OSCMessage ] = Array ( 1 ... 1000 ) . map { value in
164166 OSCMessage ( " /some/address/ \( UUID ( ) . uuidString) " , values: possibleValuePacks. randomElement ( ) !)
@@ -171,12 +173,12 @@ struct OSCUDPServer_Tests {
171173 let srcLocSendToServer: SourceLocation = #_sourceLocation
172174 DispatchQueue . global ( ) . async {
173175 for message in sourceMessages {
174- do { try client. send ( message, to: " localhost " , port: 8888 ) }
176+ do { try client. send ( message, to: " localhost " , port: port ) }
175177 catch { Issue . record ( error, sourceLocation: srcLocSendToServer) }
176178 }
177179 }
178180
179- await wait ( expect: { await receiver. messages. count == 1000 } , timeout: isFlakey ? 20.0 : 5 .0)
181+ await wait ( expect: { await receiver. messages. count == 1000 } , timeout: isFlakey ? 20.0 : 10 .0)
180182 try await #require( receiver. messages. count == 1000 )
181183
182184 await #expect( receiver. messages == sourceMessages)
0 commit comments