mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-12-23 12:09:57 +00:00
848a6a71c4
Some checks failed
Audit / audit (push) Has been cancelled
CI / fmt (push) Has been cancelled
CI / typo (push) Has been cancelled
CI / ci (macos-latest, stable, bash) (push) Has been cancelled
CI / ci (ubuntu-latest, stable, bash) (push) Has been cancelled
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Has been cancelled
Deny / audit (push) Has been cancelled
Doc / build (push) Has been cancelled
Doc / deploy (push) Has been cancelled
* p2p-core: enable workspace lints * fmt * fix tests * fixes * fixes * fixes * expect reason
67 lines
1.9 KiB
Rust
67 lines
1.9 KiB
Rust
#![expect(unused_crate_dependencies, reason = "external test module")]
|
|
|
|
use tower::{Service, ServiceExt};
|
|
|
|
use cuprate_helper::network::Network;
|
|
use cuprate_test_utils::monerod::monerod;
|
|
use cuprate_wire::{common::PeerSupportFlags, protocol::GetObjectsRequest, BasicNodeData};
|
|
|
|
use cuprate_p2p_core::{
|
|
client::{handshaker::HandshakerBuilder, ConnectRequest, Connector},
|
|
protocol::{PeerRequest, PeerResponse},
|
|
ClearNet, ProtocolRequest, ProtocolResponse,
|
|
};
|
|
|
|
#[tokio::test]
|
|
async fn get_single_block_from_monerod() {
|
|
let monerod = monerod(["--out-peers=0"]).await;
|
|
|
|
let our_basic_node_data = BasicNodeData {
|
|
my_port: 0,
|
|
network_id: Network::Mainnet.network_id(),
|
|
peer_id: 87980,
|
|
support_flags: PeerSupportFlags::FLUFFY_BLOCKS,
|
|
rpc_port: 0,
|
|
rpc_credits_per_hash: 0,
|
|
};
|
|
|
|
let handshaker = HandshakerBuilder::<ClearNet>::new(our_basic_node_data).build();
|
|
|
|
let mut connector = Connector::new(handshaker);
|
|
|
|
let mut connected_peer = connector
|
|
.ready()
|
|
.await
|
|
.unwrap()
|
|
.call(ConnectRequest {
|
|
addr: monerod.p2p_addr(),
|
|
permit: None,
|
|
})
|
|
.await
|
|
.unwrap();
|
|
|
|
let PeerResponse::Protocol(ProtocolResponse::GetObjects(obj)) = connected_peer
|
|
.ready()
|
|
.await
|
|
.unwrap()
|
|
.call(PeerRequest::Protocol(ProtocolRequest::GetObjects(
|
|
GetObjectsRequest {
|
|
blocks: hex::decode(
|
|
"418015bb9ae982a1975da7d79277c2705727a56894ba0fb246adaabb1f4632e3",
|
|
)
|
|
.unwrap()
|
|
.try_into()
|
|
.unwrap(),
|
|
pruned: false,
|
|
},
|
|
)))
|
|
.await
|
|
.unwrap()
|
|
else {
|
|
panic!("Client returned wrong response");
|
|
};
|
|
|
|
assert_eq!(obj.blocks.len(), 1);
|
|
assert_eq!(obj.missed_ids.len(), 0);
|
|
assert_eq!(obj.current_blockchain_height, 1);
|
|
}
|