fix(mocknet): make stream deadline methods noop instead of returning error #3471
Conversation
|
We recently released the simlibp2p package under I think we should deprecate our mocknet package. We aren't using it anywhere within go-libp2p, and I don't want to spend time maintaining it when we have a better alternative. That said, I don't strongly oppose the general idea here, and I'm a bit surprised it's taken this long to find this issue.
Deadlines aren't only about how fast writes happen. They protect a node from peers that are (possibly maliciously) stalling a stream. These changes wouldn't work for testing those cases. But maybe that's fine |
|
This is a quick way to solve the issue that doesn't require major testing refactoring. We are aware of simnet and that mocknet looms with deprecation. |
|
Please gofmt the file @walldiss, and we can merge this. |
e57a25f to
779197b
Compare
|
There seems to be some CI issue related to testing setup: |
|
nope, that's a known issue that I haven't had a chance to fix it. |
|
thanks for the PR |
Summary
SetDeadline,SetReadDeadline, andSetWriteDeadlineon mocknet streams return nil instead of an errorio.Pipewhich doesn't support deadlines, but returning an error breaks callers that treatSetWriteDeadlinefailure as fatalContext
go-libp2p-pubsub added
SetWriteDeadlinecalls inhandleSendingMessages(part of libp2p/go-libp2p-pubsub#631). The deadline error is treated as fatal. The stream is reset and the hello packet is never sent. This prevents gossipsub peers from discovering each other's subscriptions in any mocknet-based test.