The MockStream class used in network_interface_asio_test works by pausing itself as certain key Events occur (like reading, writing, connecting) to allow the test thread to investigate the state of the connection. The MockStream contains a set of states that show where it has paused itself (kBlockedBeforeConnect, kBlockedBeforeRead, kBlockedAfterWrite, kCanceled). We have made an assumption that the state of the stream will not change while it is paused. However, it is perfectly valid for the NIA to call cancel() on the MockStream while we have it paused. Currently, if this happens, we may invariant.
The methods that operate on MockStream while it is paused (pushRead(), popWrite()) should account for possible cancellation by the NIA.