Skip to content

Commit

Permalink
fix compiler errrors
Browse files Browse the repository at this point in the history
  • Loading branch information
jxs committed Nov 7, 2023
1 parent eeec0bc commit d067ea9
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions misc/quick-protobuf-codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ quick-protobuf = "0.8"

[dev-dependencies]
futures = "0.3.28"
quickcheck = { workspace = true }

# Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling
Expand Down
1 change: 1 addition & 0 deletions misc/quick-protobuf-codec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ mod tests {
use asynchronous_codec::FramedRead;
use futures::io::Cursor;
use futures::{FutureExt, StreamExt};
use quickcheck::{Arbitrary, Gen, QuickCheck};
use std::error::Error;

#[test]
Expand Down
8 changes: 7 additions & 1 deletion protocols/gossipsub/src/behaviour/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use crate::{
use async_std::net::Ipv4Addr;
use byteorder::{BigEndian, ByteOrder};
use libp2p_core::{ConnectedPoint, Endpoint};
use prometheus_client::metrics::counter::Counter;
use rand::Rng;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
Expand Down Expand Up @@ -272,7 +273,12 @@ where
for connection_id in peer_connections.connections.clone() {
active_connections = active_connections.checked_sub(1).unwrap();

let dummy_handler = Handler::new(ProtocolConfig::default(), Duration::ZERO);
let dummy_handler = Handler::new(
ProtocolConfig::default(),
Duration::ZERO,
Counter::default(),
Counter::default(),
);

gs.on_swarm_event(FromSwarm::ConnectionClosed(ConnectionClosed {
peer_id: *peer_id,
Expand Down
12 changes: 2 additions & 10 deletions protocols/gossipsub/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,20 +306,12 @@ impl Metrics {
};
let messages_added_to_queue = {
let metric = Counter::default();
registry.register(
"messages_added_to_queue",
"TODO",
metric.clone(),
);
registry.register("messages_added_to_queue", "TODO", metric.clone());
metric
};
let messages_removed_from_queue = {
let metric = Counter::default();
registry.register(
"messages_removed_from_queue",
"TODO",
metric.clone(),
);
registry.register("messages_removed_from_queue", "TODO", metric.clone());
metric
};

Expand Down
4 changes: 2 additions & 2 deletions protocols/gossipsub/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ mod tests {
control_msgs: vec![],
};

let mut codec = GossipsubCodec::new(u32::MAX as usize, ValidationMode::Strict);
let mut codec = GossipsubCodec::new(codec::UviBytes::default(), ValidationMode::Strict);
let mut buf = BytesMut::new();
codec.encode(rpc.into_protobuf(), &mut buf).unwrap();
let decoded_rpc = codec.decode(&mut buf).unwrap().unwrap();
Expand All @@ -608,7 +608,7 @@ mod tests {
}
}

QuickCheck::new().quickcheck(prop as fn(_, _) -> _)
QuickCheck::new().quickcheck(prop as fn(_) -> _)
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions transports/webrtc/src/tokio/substream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ mod tests {
use asynchronous_codec::Encoder;
use bytes::BytesMut;
use quick_protobuf::{MessageWrite, Writer};
use unsigned_varint::codec::UviBytes;

#[test]
fn max_data_len() {
Expand All @@ -274,9 +273,10 @@ mod tests {
.expect("Encoding to succeed");
assert_eq!(encoded_msg.len(), message.len() + PROTO_OVERHEAD);

let mut uvi = UviBytes::default();
let mut dst = BytesMut::new();
uvi.encode(encoded_msg.as_slice(), &mut dst).unwrap();
let mut codec: quick_protobuf_codec::Codec<Message, Message> =
quick_protobuf_codec::Codec::new(MAX_MSG_LEN - VARINT_LEN);
codec.encode(protobuf, &mut dst).unwrap();

// Ensure the varint prefixed and protobuf encoded largest message is no longer than the
// maximum limit specified in the libp2p WebRTC specification.
Expand Down

0 comments on commit d067ea9

Please sign in to comment.