mirror of
https://github.com/hinto-janai/cuprate.git
synced 2025-01-10 12:54:44 +00:00
fix tests
This commit is contained in:
parent
0fe82b1c76
commit
719f4cd64d
9 changed files with 25 additions and 9 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -776,6 +776,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"borsh",
|
"borsh",
|
||||||
|
"cfg-if",
|
||||||
"cuprate-helper",
|
"cuprate-helper",
|
||||||
"cuprate-pruning",
|
"cuprate-pruning",
|
||||||
"cuprate-test-utils",
|
"cuprate-test-utils",
|
||||||
|
|
|
@ -210,7 +210,6 @@ unseparated_literal_suffix = "deny"
|
||||||
unnecessary_safety_doc = "deny"
|
unnecessary_safety_doc = "deny"
|
||||||
unnecessary_safety_comment = "deny"
|
unnecessary_safety_comment = "deny"
|
||||||
unnecessary_self_imports = "deny"
|
unnecessary_self_imports = "deny"
|
||||||
tests_outside_test_module = "deny"
|
|
||||||
string_to_string = "deny"
|
string_to_string = "deny"
|
||||||
rest_pat_in_fully_bound_structs = "deny"
|
rest_pat_in_fully_bound_structs = "deny"
|
||||||
redundant_type_annotations = "deny"
|
redundant_type_annotations = "deny"
|
||||||
|
|
|
@ -21,6 +21,7 @@ futures = { workspace = true, features = ["std"] }
|
||||||
async-trait = { workspace = true }
|
async-trait = { workspace = true }
|
||||||
tower = { workspace = true, features = ["util", "tracing"] }
|
tower = { workspace = true, features = ["util", "tracing"] }
|
||||||
|
|
||||||
|
cfg-if = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
tracing = { workspace = true, features = ["std", "attributes"] }
|
tracing = { workspace = true, features = ["std", "attributes"] }
|
||||||
hex-literal = { workspace = true }
|
hex-literal = { workspace = true }
|
||||||
|
|
|
@ -231,7 +231,7 @@ pub async fn ping<N: NetworkZone>(addr: N::Addr) -> Result<u64, HandshakeError>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This function completes a handshake with the requested peer.
|
/// This function completes a handshake with the requested peer.
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[expect(clippy::too_many_arguments)]
|
||||||
async fn handshake<Z: NetworkZone, AdrBook, CSync, PSync, ProtoHdlr, BrdcstStrmMkr, BrdcstStrm>(
|
async fn handshake<Z: NetworkZone, AdrBook, CSync, PSync, ProtoHdlr, BrdcstStrmMkr, BrdcstStrm>(
|
||||||
req: DoHandshakeRequest<Z>,
|
req: DoHandshakeRequest<Z>,
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,15 @@
|
||||||
//! .unwrap();
|
//! .unwrap();
|
||||||
//! # });
|
//! # });
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
|
cfg_if::cfg_if! {
|
||||||
|
// Used in `tests/`
|
||||||
|
if #[cfg(test)] {
|
||||||
|
use cuprate_test_utils as _;
|
||||||
|
use hex as _;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
use std::{fmt::Debug, future::Future, hash::Hash};
|
use std::{fmt::Debug, future::Future, hash::Hash};
|
||||||
|
|
||||||
use futures::{Sink, Stream};
|
use futures::{Sink, Stream};
|
||||||
|
@ -65,9 +74,6 @@ use cuprate_wire::{
|
||||||
NetworkAddress,
|
NetworkAddress,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests;
|
|
||||||
|
|
||||||
pub mod client;
|
pub mod client;
|
||||||
mod constants;
|
mod constants;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
//! This file contains a test for a handshake with monerod but uses fragmented messages.
|
//! This file contains a test for a handshake with monerod but uses fragmented messages.
|
||||||
|
|
||||||
|
#![expect(unused_crate_dependencies, reason = "external test module")]
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
net::SocketAddr,
|
net::SocketAddr,
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
|
@ -29,7 +31,7 @@ use cuprate_wire::{
|
||||||
BasicNodeData, Message, MoneroWireCodec,
|
BasicNodeData, Message, MoneroWireCodec,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use cuprate_p2p_core::{
|
||||||
client::{
|
client::{
|
||||||
handshaker::HandshakerBuilder, ConnectRequest, Connector, DoHandshakeRequest,
|
handshaker::HandshakerBuilder, ConnectRequest, Connector, DoHandshakeRequest,
|
||||||
InternalPeerID,
|
InternalPeerID,
|
|
@ -1,8 +1,10 @@
|
||||||
|
#![expect(unused_crate_dependencies, reason = "external test module")]
|
||||||
|
|
||||||
use std::{sync::Arc, time::Duration};
|
use std::{sync::Arc, time::Duration};
|
||||||
|
|
||||||
use tokio::sync::Semaphore;
|
use tokio::sync::Semaphore;
|
||||||
|
|
||||||
use crate::handles::HandleBuilder;
|
use cuprate_p2p_core::handles::HandleBuilder;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn send_ban_signal() {
|
fn send_ban_signal() {
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![expect(unused_crate_dependencies, reason = "external test module")]
|
||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
|
@ -15,7 +17,7 @@ use cuprate_test_utils::{
|
||||||
};
|
};
|
||||||
use cuprate_wire::{common::PeerSupportFlags, BasicNodeData, MoneroWireCodec};
|
use cuprate_wire::{common::PeerSupportFlags, BasicNodeData, MoneroWireCodec};
|
||||||
|
|
||||||
use crate::{
|
use cuprate_p2p_core::{
|
||||||
client::{
|
client::{
|
||||||
handshaker::HandshakerBuilder, ConnectRequest, Connector, DoHandshakeRequest,
|
handshaker::HandshakerBuilder, ConnectRequest, Connector, DoHandshakeRequest,
|
||||||
InternalPeerID,
|
InternalPeerID,
|
||||||
|
@ -24,6 +26,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[expect(clippy::significant_drop_tightening)]
|
||||||
async fn handshake_cuprate_to_cuprate() {
|
async fn handshake_cuprate_to_cuprate() {
|
||||||
// Tests a Cuprate <-> Cuprate handshake by making 2 handshake services and making them talk to
|
// Tests a Cuprate <-> Cuprate handshake by making 2 handshake services and making them talk to
|
||||||
// each other.
|
// each other.
|
|
@ -1,10 +1,12 @@
|
||||||
|
#![expect(unused_crate_dependencies, reason = "external test module")]
|
||||||
|
|
||||||
use tower::{Service, ServiceExt};
|
use tower::{Service, ServiceExt};
|
||||||
|
|
||||||
use cuprate_helper::network::Network;
|
use cuprate_helper::network::Network;
|
||||||
use cuprate_test_utils::monerod::monerod;
|
use cuprate_test_utils::monerod::monerod;
|
||||||
use cuprate_wire::{common::PeerSupportFlags, protocol::GetObjectsRequest, BasicNodeData};
|
use cuprate_wire::{common::PeerSupportFlags, protocol::GetObjectsRequest, BasicNodeData};
|
||||||
|
|
||||||
use crate::{
|
use cuprate_p2p_core::{
|
||||||
client::{handshaker::HandshakerBuilder, ConnectRequest, Connector},
|
client::{handshaker::HandshakerBuilder, ConnectRequest, Connector},
|
||||||
protocol::{PeerRequest, PeerResponse},
|
protocol::{PeerRequest, PeerResponse},
|
||||||
ClearNet, ProtocolRequest, ProtocolResponse,
|
ClearNet, ProtocolRequest, ProtocolResponse,
|
Loading…
Reference in a new issue