qlog/testing/mod.rs
1// Copyright (C) 2026, Cloudflare, Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// * Redistributions of source code must retain the above copyright notice,
9// this list of conditions and the following disclaimer.
10//
11// * Redistributions in binary form must reproduce the above copyright
12// notice, this list of conditions and the following disclaimer in the
13// documentation and/or other materials provided with the distribution.
14//
15// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
19// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27//! Testing utilities for qlog.
28
29use crate::events::quic::PacketType;
30use crate::PacketHeader;
31use crate::Trace;
32use crate::TraceSeq;
33use crate::VantagePoint;
34use crate::VantagePointType;
35
36pub fn make_pkt_hdr(packet_type: PacketType) -> PacketHeader {
37 let scid = [0x7e, 0x37, 0xe4, 0xdc, 0xc6, 0x68, 0x2d, 0xa8];
38 let dcid = [0x36, 0xce, 0x10, 0x4e, 0xee, 0x50, 0x10, 0x1c];
39
40 // Some(1251),
41 // Some(1224),
42
43 PacketHeader::new(
44 packet_type,
45 Some(0),
46 None,
47 None,
48 Some(0x0000_0001),
49 Some(&scid),
50 Some(&dcid),
51 )
52}
53
54pub fn make_trace() -> Trace {
55 Trace::new(
56 Some("Quiche qlog trace".to_string()),
57 Some("Quiche qlog trace description".to_string()),
58 None,
59 Some(VantagePoint {
60 name: None,
61 ty: VantagePointType::Server,
62 flow: None,
63 }),
64 vec![],
65 )
66}
67
68pub fn make_trace_seq() -> TraceSeq {
69 TraceSeq::new(
70 Some("Quiche qlog trace".to_string()),
71 Some("Quiche qlog trace description".to_string()),
72 None,
73 Some(VantagePoint {
74 name: None,
75 ty: VantagePointType::Server,
76 flow: None,
77 }),
78 vec![],
79 )
80}
81
82#[cfg(test)]
83mod event_tests;
84#[cfg(test)]
85mod trace_tests;