TEST_F(TopologyManagerTestFixture,
       ShouldUpdateServerDescriptionsTopologyDescriptionPtrWhenTopologyDescriptionIsInstalled) {
    auto checkServerTopologyDescriptionMatches = [](TopologyDescriptionPtr topologyDescription) {
        auto rawTopologyDescPtr = topologyDescription.get();
        for (auto server : topologyDescription->getServers()) {
            auto rawServerTopologyDescPtr = (*server->getTopologyDescription()).get();
            ASSERT(server->getTopologyDescription());
            ASSERT(rawServerTopologyDescPtr == rawTopologyDescPtr);
        }
    };

    auto config = SdamConfiguration(kThreeServers);
    TopologyManager topologyManager(config, clockSource);
    checkServerTopologyDescriptionMatches(topologyManager.getTopologyDescription());

    auto topologyDescription = topologyManager.getTopologyDescription();
    auto firstServer = *topologyDescription->getServers()[0];
    auto host = firstServer.getAddress();
    auto isMasterOutcome =
        IsMasterOutcome(host, kBsonRsPrimary, duration_cast<IsMasterRTT>(mongo::Milliseconds{40}));
    topologyManager.onServerDescription(isMasterOutcome);
    checkServerTopologyDescriptionMatches(topologyManager.getTopologyDescription());

    topologyManager.onServerRTTUpdated(host, Milliseconds{40});
    checkServerTopologyDescriptionMatches(topologyManager.getTopologyDescription());
}
TEST_F(TopologyManagerTestFixture,
       ShouldUpdateServerDescriptionsTopologyDescriptionPtrWhenTopologyDescriptionIsInstalled) {
    auto checkServerTopologyDescriptionMatches = [](TopologyDescriptionPtr topologyDescription) {
        auto rawTopologyDescPtr = topologyDescription.get();
        for (auto server : topologyDescription->getServers()) {
            auto rawServerTopologyDescPtr = (*server->getTopologyDescription()).get();
            ASSERT(server->getTopologyDescription());
            ASSERT(rawServerTopologyDescPtr == rawTopologyDescPtr);
        }
    };

    auto config = SdamConfiguration(kThreeServers);
    TopologyManager topologyManager(config, clockSource);
    checkServerTopologyDescriptionMatches(topologyManager.getTopologyDescription());

    auto topologyDescription = topologyManager.getTopologyDescription();
    auto firstServer = *topologyDescription->getServers()[0];
    auto host = firstServer.getAddress();
    auto isMasterOutcome =
        IsMasterOutcome(host, kBsonRsPrimary, duration_cast<IsMasterRTT>(mongo::Milliseconds{40}));
    topologyManager.onServerDescription(isMasterOutcome);
    checkServerTopologyDescriptionMatches(topologyManager.getTopologyDescription());

    topologyManager.onServerRTTUpdated(host, Milliseconds{40});
    checkServerTopologyDescriptionMatches(topologyManager.getTopologyDescription());
}