Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests to established connections #2323

Merged
merged 17 commits into from
Oct 13, 2022
Merged

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented May 27, 2022

Adds a test to the established connections.

I initially just wanted to write regression tests, unfortunately the first test I wrote doesn't pass because of this generally messy piece of code.
I'm going to fix that generally messy piece of code before we can merge this PR.


Update:

Working on the tests revealed a couple of bugs that I've fixed.

Additionally, I've also made a change where we now pass a timeout to open_notifications_substream to allow configuring it and to make it similar to add_request.

Copy link
Contributor

@mergify mergify bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatically approving tomaka's pull requests. This auto-approval will be removed once more maintainers are active.

@github-actions
Copy link
Contributor

github-actions bot commented May 27, 2022

twiggy diff report

Difference in .wasm size before and after this pull request.


 Delta Bytes │ Item
─────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
      +10232 ┊ smoldot::libp2p::connection::established::substream::Substream<TNow,TRqUd,TNotifUd>::read_write2::h0f7e34003cbeb9ac
       -9740 ┊ smoldot::libp2p::connection::established::substream::Substream<TNow,TRqUd,TNotifUd>::read_write2::ha53af24fcae11d83
        -361 ┊ core::ptr::drop_in_place<smoldot::libp2p::connection::established::substream::SubstreamInner<smoldot_light_wasm::Instant,smoldot::libp2p::collection::SubstreamId,()>>::h1e3f9403be0e4678
        +361 ┊ core::ptr::drop_in_place<smoldot::libp2p::connection::established::substream::SubstreamInner<smoldot_light_wasm::Instant,smoldot::libp2p::collection::SubstreamId,()>>::h22e17444d1dc3c35
        -231 ┊ smoldot::libp2p::connection::established::single_stream::SingleStream<TNow,TRqUd,TNotifUd>::open_notifications_substream::h1b4c3657c0864ad0
        +221 ┊ smoldot::libp2p::connection::established::single_stream::SingleStream<TNow,TRqUd,TNotifUd>::open_notifications_substream::h1ac919ba1c2df275
        -112 ┊ data[0]
         +60 ┊ smoldot::libp2p::connection::established::single_stream::SingleStream<TNow,TRqUd,TNotifUd>::process_substream::h908acae52f8a1cf5
         -49 ┊ smoldot::libp2p::read_write::ReadWrite<TNow>::close_write_if_empty::hc16464fdb62e71a1
         -33 ┊ smoldot::libp2p::connection::yamux::Yamux<T>::remove_dead_substream::h7492aefbefdaed4a
         +18 ┊ smoldot::libp2p::collection::multi_stream::MultiStreamConnectionTask<TNow,TSubId>::substream_read_write::h2da2553fcea14137
         +15 ┊ smoldot::libp2p::connection::established::single_stream::SingleStream<TNow,TRqUd,TNotifUd>::read_write::h9f6718ead376aea4
         -15 ┊ type[68]: (i32, i32, i32, f64, i32, i32, i32, i32, i32, i32, i32, i32) -> nil
         +15 ┊ type[69]: (i32, i32, i32, f64, i32, i32, i32, i32, i32, i32, i32, i32) -> nil
         -12 ┊ type[103]: (i32, i32, i32, i32, i32, i32, i64, i64, i64) -> nil
         +12 ┊ type[104]: (i32, i32, i32, i32, i32, i32, i64, i64, i64) -> nil
         -12 ┊ type[79]: (i32, f64, i32, i32, i32, i64, i32, i32) -> i64
         +12 ┊ type[80]: (i32, f64, i32, i32, i32, i64, i32, i32) -> i64
         -12 ┊ type[81]: (i32, i32, f64, i32, i32, i32, i64, i64) -> i64
         +12 ┊ type[82]: (i32, i32, f64, i32, i32, i32, i64, i64) -> i64
         +24 ┊ ... and 79 more.
        +306 ┊ Σ [99 Total Rows]

mergify bot pushed a commit that referenced this pull request Sep 6, 2022
This PR is a general clean-up of the single stream connection code. It fixes many small issues, and also handles the shutdown phase more properly.
We now properly handle incoming GoAway frames, and have the possibility to send some.

Can be reviewed commit by commit.
I understand that this code is generally extremely complicated, but I don't really have a good solution for this. Networking code *is* extremely complicated, both in terms of logic and implementation.
Maybe a solution is tests, such as #2323, but at the moment the code isn't even robust enough to have tests.
@tomaka
Copy link
Contributor Author

tomaka commented Oct 12, 2022

Tests are now passing. Will add more tests.

@tomaka tomaka marked this pull request as ready for review October 13, 2022 10:40
@tomaka
Copy link
Contributor Author

tomaka commented Oct 13, 2022

This PR is definitely a bit embarrassing: it revealed many unimplemented things, which now are.

@tomaka tomaka requested a review from melekes October 13, 2022 11:12
@tomaka tomaka added the automerge Automatically merge pull request as soon as possible label Oct 13, 2022
@mergify mergify bot merged commit 0da8bb3 into paritytech:main Oct 13, 2022
@tomaka tomaka deleted the established-tests branch October 13, 2022 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Automatically merge pull request as soon as possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants