MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / test_request_encode_decode

Function test_request_encode_decode

ext/libp2p-bitswap/src/protocol.rs:256–273  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

254
255 #[test]
256 fn test_request_encode_decode() {
257 let requests = [
258 BitswapRequest {
259 ty: RequestType::Have,
260 cid: create_cid(&b"have_request"[..]),
261 },
262 BitswapRequest {
263 ty: RequestType::Block,
264 cid: create_cid(&b"block_request"[..]),
265 },
266 ];
267 let mut buf = Vec::with_capacity(MAX_CID_SIZE + 1);
268 for request in &requests {
269 buf.clear();
270 request.write_to(&mut buf).unwrap();
271 assert_eq!(&BitswapRequest::from_bytes(&buf).unwrap(), request);
272 }
273 }
274
275 #[test]
276 fn test_response_encode_decode() {

Callers

nothing calls this directly

Calls 2

create_cidFunction · 0.85
write_toMethod · 0.45

Tested by

no test coverage detected