libp2p / rust-libp2p

The Rust Implementation of the libp2p networking stack.
https://libp2p.io
MIT License
4.52k stars 939 forks source link

Move `quic/tests/smoke::{read, write}_after_peer_dropped_stream` to muxer test harness #3211

Open elenaf9 opened 1 year ago

elenaf9 commented 1 year ago

Description

We currently have the two tests {read, write}_after_peer_dropped_stream on QUIC that test reading / writing to a stream after the remote peer already dropped the stream. As @thomaseizinger proposed in https://github.com/libp2p/rust-libp2p/pull/3164#discussion_r1031805526 we should consider moving these tests to the new stream muxer test harness.

Moving the tests to the test harness would require some more design work. Compared to the other tests in the harness these tests test a specific sequential order in which alice and bob do their calls, rather than the things running in parallel. Therefore we can not use the current test harness API and instead have to add a new abstraction for these kind of tests.

Motivation

The test hardness is a great framework for abstracting and maintaining tests that should be run on all libp2p muxers. The mentioned tests are nothing QUIC specific. Moving them to the test harness would:

Current Implementation

The tests currently only live in quic/tests/smoke: https://github.com/libp2p/rust-libp2p/blob/1c2712c1bc288dc608aaec5fc3458b0d07181feb/transports/quic/tests/smoke.rs#L273-L304

Are you planning to do it yourself in a pull request?

No.

thomaseizinger commented 1 year ago

I think it shouldn't be too hard to make this work. We can change the harness to wait for both streams to be established before moving on to the next phase. We can call a single closure that passes in both substreams. All the existing tests can simply compose the two given protocols with futures::future::join.