Fix: Increment stats.MessagesSent in msgToStream() function (#441)
* Share common code between network/ipfs_impl_test.go tests
Extract the code that is common in TestMessageResendAfterError,
TestMessageSendTimeout and TestMessageSendNotSupportedResponse to a
separate function.
* Make prepareNetwork() return two hosts and two networks
Let prepareNetwork() make simmetric setup with two `ErrHost`s
with two `impl` networks to be sure we test `impl` instances on
both ends.
* Added TestNetworkCounters test to the "network" package
The test shows we have a problem with `MessagesSent` counter.
* Fix: Increment stats.MessagesSent in msgToStream() function
Fixes the bug with incrementing `MessagesSent` counter only in
`SendMessage()` method if `impl`. Now it works for `MessageSender`
too.
* Allow to specify a network event listener for tests
Added `listener network.Notifiee` to the `receiver` structure.
If a listener is specified then `prepareNetwork()` connects it
to the mock network it builds before making any connections.
* Wait for all network streams are closed in testNetworkCounters
Wait for all network streams are closed instead of just using a
timeout. The timeout of 5 s is still used as a deadline (it makes
the test to fail).
* Fix: Close the MessageSender in testNetworkCounters()
The `MessageSender` needs to be closed if we want all streams in
the network to be closed.
* Fix: Close MessageSender in other tests too
Co-authored-by: Paul Wolneykien <manowar@altlinux.org>
Showing
Please register or sign in to comment