Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(iroh-net): fix relay's codec proptesting #2283

Merged
merged 3 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions iroh-net/proptest-regressions/derp/codec.txt

This file was deleted.

22 changes: 10 additions & 12 deletions iroh-net/src/relay/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ pub(crate) enum FrameType {
///
/// Handled on the `[relay::Client]`, but currently never sent on the `[relay::Server]`
Restarting = 15,
/// 32B src pub key + 32B dst pub key + packet bytes
ForwardPacket = 16,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ramfox this was part of the compilation failures, but I think was part of meshing. Is this correct? it's otherwise not used anywhere

#[num_enum(default)]
Unknown = 255,
}
Expand Down Expand Up @@ -565,9 +563,7 @@ mod tests {
}
}

/// these test are slow in debug mode, so only run them in release mode
#[cfg(test)]
#[cfg(not(debug_assertions))]
mod proptests {
use super::*;
use proptest::prelude::*;
Expand All @@ -588,11 +584,16 @@ mod proptests {

/// Generates a random valid frame
fn frame() -> impl Strategy<Value = Frame> {
let server_key = key().prop_map(|key| Frame::ServerKey { key });
let client_info = (key(), data(32)).prop_map(|(client_public_key, encrypted_message)| {
let client_info = (secret_key()).prop_map(|secret_key| {
let info = ClientInfo {
version: PROTOCOL_VERSION,
};
let msg = postcard::to_stdvec(&info).expect("using default ClientInfo");
let signature = secret_key.sign(&msg);
Frame::ClientInfo {
client_public_key,
encrypted_message,
client_public_key: secret_key.public(),
message: msg.into(),
signature,
}
});
let send_packet =
Expand All @@ -611,9 +612,7 @@ mod proptests {
try_for,
});
prop_oneof![
server_key,
client_info,
server_info,
send_packet,
recv_packet,
keep_alive,
Expand All @@ -629,8 +628,7 @@ mod proptests {
fn inject_error(buf: &mut BytesMut) {
fn is_fixed_size(tpe: FrameType) -> bool {
match tpe {
FrameType::ServerKey
| FrameType::KeepAlive
FrameType::KeepAlive
| FrameType::NotePreferred
| FrameType::Ping
| FrameType::Pong
Expand Down
Loading