You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: tests.rs
    path of file: ./repos/nearcore/chain/network/src/peer_manager/connection
    
    the code of the file until where you have to start completion: use crate::network_protocol::testonly as data;
use crate::peer::peer_actor::ClosingReason;
use crate::peer_manager;
use crate::peer_manager::connection;
use crate::private_actix::RegisterPeerError;
use crate::tcp;
use crate::testonly::make_rng;
use near_async::time;
use near_o11y::testonly::init_test_logger;
use std::sync::Arc;

#[tokio::test]
async fn connection_tie_break() {
    init_test_logger();
    let mut rng = make_rng(33955575545);
    let rng = &mut rng;
    let mut clock = time::FakeClock::default();
    let cha
    
async fn connection_tie_break() {
    init_test_logger();
    let mut rng = make_rng(33955575545);
    let rng = &mut rng;
    let mut clock = time::FakeClock::default();
    let chain = Arc::new(data::Chain::make(&mut clock, rng, 10));

    let mut cfgs: Vec<_> = (0..3).map(|_| chain.make_config(rng)).collect();
    cfgs.sort_by_key(|c| c.node_id());

    let pm = peer_manager::testonly::start(
        clock.clock(),
        near_store::db::TestDB::new(),
        cfgs[1].clone(),
        chain.clone(),
    )
    .await;

    // pm.id is lower
    let outbound_conn = pm.start_outbound(chain.clone(), cfgs[2].clone(), tcp::Tier::T2).await;
    let inbound_conn = pm.start_inbound(chain.clone(), cfgs[2].clone()).await;
    // inbound should be rejected, outbound accepted.
    assert_eq!(
        ClosingReason::RejectedByPeerManager(RegisterPeerError::PoolError(
            connection::PoolError::AlreadyStartedConnecting
        )),
        inbound_conn.manager_fail_handshake(&clock.clock()).await,
    );
    outbound_conn.handshake(&clock.clock()).await;

    // pm.id is higher
    let outbound_conn = pm.start_outbound(chain.clone(), cfgs[0].clone(), tcp::Tier::T2).await;
    let inbound_conn = pm.start_inbound(chain.clone(), cfgs[0].clone()).await;
    // inbound should be accepted, outbound rejected by PM.
    let inbound = inbound_conn.handshake(&clock.clock()).await;
    assert_eq!(
        ClosingReason::RejectedByPeerManager(RegisterPeerError::PoolError(
            connection::PoolError::AlreadyConnected
        )),
        outbound_conn.manager_fail_handshake(&clock.clock()).await,
    );
    drop(inbound);
}