   func testClientEventuallyConnects() throws {
     let transientFailure = self.expectation(description: "connection transientFailure")
     let connectionReady = self.expectation(description: "connection ready")
-    self.stateDelegate.transientFailureExpectation = transientFailure
-    self.stateDelegate.readyExpectation = connectionReady
+    self.stateDelegate.expectations[.transientFailure] = transientFailure
+    self.stateDelegate.expectations[.ready] = connectionReady
 
     // Start the client first.
     self.client = ClientConnection(configuration: self.makeClientConfiguration())
 
     self.wait(for: [transientFailure], timeout: 1.0)
-    self.stateDelegate.transientFailureExpectation = nil
+    self.stateDelegate.expectations[.transientFailure] = nil
     XCTAssertEqual(self.stateDelegate.clearStates(), [.connecting, .transientFailure])
 
     self.server = self.makeServer()


    // Replace the ready expectation (since it's already been fulfilled).
    let reconnectionReady = self.expectation(description: "(re)connection ready")
    self.stateDelegate.readyExpectation = reconnectionReady

    let echo = Echo_EchoServiceClient(connection: self.client)
    // This should succeed once we get a connection again.

    configuration.connectionBackoff = nil

    let connectionShutdown = self.expectation(description: "client shutdown")
    self.stateDelegate.expectations[.shutdown] = connectionShutdown
    self.client = ClientConnection(configuration: configuration)

    self.wait(for: [connectionShutdown], timeout: 1.0)
