ant-quic 0.22.2

QUIC transport protocol with advanced NAT traversal for P2P networks
Documentation
//! Tests for token_v2 binding to (PeerId || CID || nonce)

#![allow(clippy::unwrap_used, clippy::expect_used)]

use ant_quic::{nat_traversal_api::PeerId, shared::ConnectionId};

#[test]
fn binding_token_round_trip_binds_peer_and_cid() {
    let mut rng = rand::thread_rng();
    let key = ant_quic::token_v2::test_key_from_rng(&mut rng);

    let pid = PeerId([7u8; 32]);
    let cid = ConnectionId::new(&[9u8; 8]); // use 8-byte cid

    let tok = ant_quic::token_v2::encode_binding_token(&key, &pid, &cid).unwrap();
    let dec = ant_quic::token_v2::decode_binding_token(&key, &tok).expect("decodes");

    assert_eq!(dec.peer_id, pid);
    assert_eq!(dec.cid, cid);
}