[multistream-select] Fix panic with V1Lazy (regression) and more convenient transport boxing. (#1783)

* [multistream-select] Fix panic with V1Lazy and add integration tests.

Fixes a panic when using the `V1Lazy` negotiation protocol,
a regression introduced in https://github.com/libp2p/rust-libp2p/pull/1484.

Thereby adds integration tests for a transport upgrade with both
`V1` and `V1Lazy` to the `multistream-select` crate to prevent
future regressions.

* Cleanup.

* Update changelog.
This commit is contained in:
Roman Borschel
2020-10-07 11:10:54 +02:00
committed by GitHub
parent 2a5c1832a1
commit 3e31ea9337
13 changed files with 193 additions and 78 deletions

View File

@ -303,8 +303,8 @@ pub fn build_tcp_ws_noise_mplex_yamux(keypair: identity::Keypair)
.upgrade(core::upgrade::Version::V1)
.authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated())
.multiplex(core::upgrade::SelectUpgrade::new(yamux::Config::default(), mplex::MplexConfig::new()))
.map(|(peer, muxer), _| (peer, core::muxing::StreamMuxerBox::new(muxer)))
.timeout(std::time::Duration::from_secs(20)))
.timeout(std::time::Duration::from_secs(20))
.boxed())
}
/// Builds an implementation of `Transport` that is suitable for usage with the `Swarm`.
@ -335,6 +335,6 @@ pub fn build_tcp_ws_pnet_noise_mplex_yamux(keypair: identity::Keypair, psk: PreS
.upgrade(core::upgrade::Version::V1)
.authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated())
.multiplex(core::upgrade::SelectUpgrade::new(yamux::Config::default(), mplex::MplexConfig::new()))
.map(|(peer, muxer), _| (peer, core::muxing::StreamMuxerBox::new(muxer)))
.timeout(std::time::Duration::from_secs(20)))
.timeout(std::time::Duration::from_secs(20))
.boxed())
}