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: udp_mux_test.rs
    path of file: ./repos/webrtc/ice/src/udp_mux
    
    the code of the file until where you have to start completion: use std::convert::TryInto;
use std::io;
use std::time::Duration;

use rand::{thread_rng, Rng};
use sha1::{Digest, Sha1};
use stun::message::{Message, BINDING_REQUEST};
use tokio::net::UdpSocket;
use tokio::time::{sleep, timeout};

use super::*;
use crate::error::Result;

#[derive(Debug, Copy, Clone)]
enum Network {
    Ipv4,
    Ipv6,
}

impl Network {
    /// Bind the UDP socket for the "remote".
    async fn bind(self) -> io::Result<UdpSocket> {
        match self {
            Network::Ipv4 => UdpSocket::bind("0.0.0.0:0").await,
            Network::Ipv6 => UdpSocket::bind("[::]:0").await,
        }
    }

    /// Connect ip from the "remote".
    fn connect_ip(self, port: u16) -> String {
        match self {
            Network::Ipv4 => format!("127.0.0.1:{port}"),
            Network::Ipv6 => format!("[::1]:{port}"),
        }
    }
}

const TIMEOUT: Duration = Duration::from_secs(60);

#[tokio::test]
async fn test_udp_mux() -> Result<()> {
    use std::io::Write;
    env_logger::Builder::from_default_env()
        .format(|buf, record| {
            writeln!(
                buf,
                "{}:{} [{}] {} - {}",
                record.file().unwrap_or("unknown"),
                record.line().unwrap_or(0),
                record.level(),
                chrono::Local::now().format("%H:%M:%S.%6f"),
                record.args()
            )
        })
        .init();

    // TODO: Support IPv6 dual stack. This works Linux and macOS, but not Windows.
    #[cfg(all(unix, target_pointer_width = "64"))]
    let udp_socket = UdpSocket::bind((std::net::Ipv6Addr::UNSPECIFIED, 0)).await?;

    #[cfg(any(not(unix), not(target_pointer_width = "64")))]
    let udp_socket = UdpSocket::bind((std::net::Ipv4Addr::UNSPECIFIED, 0)).await?;

    let addr = udp_socket.local_addr()?;
    log::info!("Listening on {}", addr);

    let udp_mux = UDPMuxDefault::new(UDPMuxParams::new(udp_socket));
    let udp_mux_dyn = Arc::clone(&udp_mux) as Arc<dyn UDPMux + Send + Sync>;

    let udp_mux_dyn_1 = Arc::clone(&udp_mux_dyn);
    let h1 = tokio::spawn(async move {
        timeout(
            TIMEOUT,
            test_mux_connection(Arc::clone(&udp_mux_dyn_1), "ufrag1", addr, Network::Ipv4),
        )
        .await
    });

    let udp_mux_dyn_2 = Arc::clone(&udp_mux_dyn);
    let h2 = tokio::spawn(async move {
        timeout(
            TIMEOUT,
            test_mux_connection(Arc::clone(&udp_mux_dyn_2), "ufrag2", addr, Network::Ipv4),
        )
        .await
    });

    let all
    
async fn test_udp_mux() -> Result<()> {
    use std::io::Write;
    env_logger::Builder::from_default_env()
        .format(|buf, record| {
            writeln!(
                buf,
                "{}:{} [{}] {} - {}",
                record.file().unwrap_or("unknown"),
                record.line().unwrap_or(0),
                record.level(),
                chrono::Local::now().format("%H:%M:%S.%6f"),
                record.args()
            )
        })
        .init();

    // TODO: Support IPv6 dual stack. This works Linux and macOS, but not Windows.
    #[cfg(all(unix, target_pointer_width = "64"))]
    let udp_socket = UdpSocket::bind((std::net::Ipv6Addr::UNSPECIFIED, 0)).await?;

    #[cfg(any(not(unix), not(target_pointer_width = "64")))]
    let udp_socket = UdpSocket::bind((std::net::Ipv4Addr::UNSPECIFIED, 0)).await?;

    let addr = udp_socket.local_addr()?;
    log::info!("Listening on {}", addr);

    let udp_mux = UDPMuxDefault::new(UDPMuxParams::new(udp_socket));
    let udp_mux_dyn = Arc::clone(&udp_mux) as Arc<dyn UDPMux + Send + Sync>;

    let udp_mux_dyn_1 = Arc::clone(&udp_mux_dyn);
    let h1 = tokio::spawn(async move {
        timeout(
            TIMEOUT,
            test_mux_connection(Arc::clone(&udp_mux_dyn_1), "ufrag1", addr, Network::Ipv4),
        )
        .await
    });

    let udp_mux_dyn_2 = Arc::clone(&udp_mux_dyn);
    let h2 = tokio::spawn(async move {
        timeout(
            TIMEOUT,
            test_mux_connection(Arc::clone(&udp_mux_dyn_2), "ufrag2", addr, Network::Ipv4),
        )
        .await
    });

    let all_results;

    #[cfg(all(unix, target_pointer_width = "64"))]
    {
        // TODO: Support IPv6 dual stack. This works Linux and macOS, but not Windows.
        let udp_mux_dyn_3 = Arc::clone(&udp_mux_dyn);
        let h3 = tokio::spawn(async move {
            timeout(
                TIMEOUT,
                test_mux_connection(Arc::clone(&udp_mux_dyn_3), "ufrag3", addr, Network::Ipv6),
            )
            .await
        });

        let (r1, r2, r3) = tokio::join!(h1, h2, h3);
        all_results = [r1, r2, r3];
    }

    #[cfg(any(not(unix), not(target_pointer_width = "64")))]
    {
        let (r1, r2) = tokio::join!(h1, h2);
        all_results = [r1, r2];
    }

    for timeout_result in &all_results {
        // Timeout error
        match timeout_result {
            Err(timeout_err) => {
                panic!("Mux test timedout: {timeout_err:?}");
            }

            // Join error
            Ok(join_result) => match join_result {
                Err(err) => {
                    panic!("Mux test failed with join error: {err:?}");
                }
                // Actual error
                Ok(mux_result) => {
                    if let Err(err) = mux_result {
                        panic!("Mux test failed with error: {err:?}");
                    }
                }
            },
        }
    }

    let timeout = all_results.iter().find_map(|r| r.as_ref().err());
    assert!(
        timeout.is_none(),
        "At least one of the muxed tasks timedout {all_results:?}"
    );

    let res = udp_mux.close().await;
    assert!(res.is_ok());
    let res = udp_mux.get_conn("failurefrag").await;

    assert!(
        res.is_err(),
        "Getting connections after UDPMuxDefault is closed should fail"
    );

    Ok(())
}