Skip to content

Commit

Permalink
deps: update pea2pea
Browse files Browse the repository at this point in the history
  • Loading branch information
niklaslong committed Apr 12, 2024
1 parent 4cb0478 commit 88dfdc6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ version = "0.2"
version = "1"

[dev-dependencies.pea2pea]
version = "0.46"
version = "0.49"

[dev-dependencies.snarkos-node-router]
path = "./router"
Expand Down
2 changes: 1 addition & 1 deletion node/bft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ version = "5"
version = "1"

[dev-dependencies.pea2pea]
version = "0.46"
version = "0.49"

[dev-dependencies.proptest]
version = "1.4.0"
Expand Down
12 changes: 4 additions & 8 deletions node/bft/tests/common/test_peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::{
};

use pea2pea::{
protocols::{Disconnect, Handshake, Reading, Writing},
protocols::{Handshake, OnDisconnect, Reading, Writing},
Config,
Connection,
ConnectionSide,
Expand Down Expand Up @@ -54,8 +54,8 @@ impl TestPeer {
let (tx, rx) = mpsc::channel(100);
let inner_node = InnerNode {
node: Node::new(Config {
listener_ip: Some(IpAddr::V4(Ipv4Addr::LOCALHOST)),
max_connections: 200,
listener_addr: Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 0)),
..Default::default()
}),
inbound_tx: tx,
Expand Down Expand Up @@ -107,7 +107,6 @@ impl Pea2Pea for InnerNode {
}
}

#[async_trait::async_trait]
impl Handshake for InnerNode {
// Set the timeout on the test peer to be longer than the gateway's timeout.
const TIMEOUT_MS: u64 = 10_000;
Expand All @@ -118,7 +117,6 @@ impl Handshake for InnerNode {
}
}

#[async_trait::async_trait]
impl Writing for InnerNode {
type Codec = EventCodec<CurrentNetwork>;
type Message = Event<CurrentNetwork>;
Expand All @@ -128,7 +126,6 @@ impl Writing for InnerNode {
}
}

#[async_trait::async_trait]
impl Reading for InnerNode {
type Codec = EventCodec<CurrentNetwork>;
type Message = Event<CurrentNetwork>;
Expand All @@ -144,7 +141,6 @@ impl Reading for InnerNode {
}
}

#[async_trait::async_trait]
impl Disconnect for InnerNode {
async fn handle_disconnect(&self, _peer_addr: SocketAddr) {}
impl OnDisconnect for InnerNode {
async fn on_disconnect(&self, _peer_addr: SocketAddr) {}
}
2 changes: 2 additions & 0 deletions node/bft/tests/gateway_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ async fn handshake_responder_side_timeout() {
let (_accounts, gateway) = new_test_gateway(NUM_NODES, &mut rng).await;
let test_peer = TestPeer::new().await;

dbg!(test_peer.listening_addr());

// Initiate a connection with the gateway, this will only return once the handshake protocol has
// completed on the test peer's side, which is a no-op.
assert!(test_peer.connect(gateway.local_ip()).await.is_ok());
Expand Down
12 changes: 4 additions & 8 deletions node/tests/common/test_peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use std::{

use futures_util::{sink::SinkExt, TryStreamExt};
use pea2pea::{
protocols::{Disconnect, Handshake, Reading, Writing},
protocols::{Handshake, OnDisconnect, Reading, Writing},
Config,
Connection,
ConnectionSide,
Expand Down Expand Up @@ -82,8 +82,8 @@ impl TestPeer {
pub async fn new(node_type: NodeType, account: Account<CurrentNetwork>) -> Self {
let peer = Self {
node: Node::new(Config {
listener_ip: Some(IpAddr::V4(Ipv4Addr::LOCALHOST)),
max_connections: 200,
listener_addr: Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 0)),
..Default::default()
}),
node_type,
Expand Down Expand Up @@ -113,7 +113,6 @@ impl TestPeer {
}
}

#[async_trait::async_trait]
impl Handshake for TestPeer {
async fn perform_handshake(&self, mut conn: Connection) -> io::Result<Connection> {
let rng = &mut TestRng::default();
Expand Down Expand Up @@ -174,7 +173,6 @@ impl Handshake for TestPeer {
}
}

#[async_trait::async_trait]
impl Writing for TestPeer {
type Codec = MessageCodec<CurrentNetwork>;
type Message = Message<CurrentNetwork>;
Expand All @@ -184,7 +182,6 @@ impl Writing for TestPeer {
}
}

#[async_trait::async_trait]
impl Reading for TestPeer {
type Codec = MessageCodec<CurrentNetwork>;
type Message = Message<CurrentNetwork>;
Expand All @@ -198,7 +195,6 @@ impl Reading for TestPeer {
}
}

#[async_trait::async_trait]
impl Disconnect for TestPeer {
async fn handle_disconnect(&self, _peer_addr: SocketAddr) {}
impl OnDisconnect for TestPeer {
async fn on_disconnect(&self, _peer_addr: SocketAddr) {}
}

0 comments on commit 88dfdc6

Please sign in to comment.