-
Notifications
You must be signed in to change notification settings - Fork 127
Closed
Labels
good first issueGood for newcomersGood for newcomers
Description
When we added NWWaitingHandler
in #588 we didn’t add a unit test for the NWWaitingHandler
. This is because we need to make an enhancement to NIOTransportServices
to make the WaitingForConnectivity
event initialiser public. This is tracked as a separate issue in apple/swift-nio-transport-services#147 and must be resolved first.
The unit test can be implemented by using an EmbeddedChannel
and sending an NIOTSNetworkEvents.WaitingForConnectivity
through fireUserInboundEventTriggered(_:)
. An example usage of EmbeddedChannel
and fireUserInboundEventTriggered(_:)
can be found here:
let tlsEventsHandler = TLSEventsHandler(deadline: nil) | |
XCTAssertNil(tlsEventsHandler.tlsEstablishedFuture) | |
let embedded = EmbeddedChannel(handlers: [tlsEventsHandler]) | |
XCTAssertNotNil(tlsEventsHandler.tlsEstablishedFuture) | |
XCTAssertNoThrow(try embedded.connect(to: .makeAddressResolvingHost("localhost", port: 0)).wait()) | |
embedded.pipeline.fireUserInboundEventTriggered(TLSUserEvent.handshakeCompleted(negotiatedProtocol: "abcd1234")) | |
XCTAssertEqual(try XCTUnwrap(tlsEventsHandler.tlsEstablishedFuture).wait(), "abcd1234") |
This should be straight forward and a good first starter issue. If you have more questions please don't hesitate to ask here.
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers