-
Notifications
You must be signed in to change notification settings - Fork 112
Conversation
Part of ipfs/boxo#86 |
} else { | ||
dhtm.checkForTimeoutsTimer.Stop() | ||
dhtm.checkForTimeoutsTimer.Reset(until) | ||
} | ||
} | ||
|
||
func (dhtm *dontHaveTimeoutMgr) consumeTimeouts() { | ||
for { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be a for loop, because checkForTimeouts() is a recursive call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note this will only get called once cause then checkForTimeoutsTimer will not be null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the for loop will continue looping forever though - so I'm suggesting that we only have the select (without putting it inside a for loop)
checkForTimeoutsTimer *time.Timer | ||
checkForTimeoutsTimer *clock.Timer | ||
// used for testing -- signal when a scheduled timeout check has happened | ||
signal chan struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: suggest renaming signal to something like timeoutChecked
ee7f583
to
f60e47c
Compare
count message received before callback so that the count is always accurate at the time of counting
The TestSessionWithPeers test was most commonly failing cause of a don't have timeout, which triggered simulated don't have message for all CIDs on the peer with content, which triggered a re-broadcast, causing peers with no content to receive additional wants
s/SetSendDontHavesOnTimeout/SetSimulateDontHavesOnTimeout
convery DontHaveTimeoutMgr to use clock interface, use mocks in tests to make tests predictable and fast
f60e47c
to
38aae7e
Compare
These tests appear to be passing now. |
…nager-timeouts Fix flaky DontHaveTimeoutManger tests This commit was moved from ipfs/go-bitswap@bfac454
Goals
Fix flaky tests for the DontHaveTimeoutManger
Implementation
Replace clock with a mock, so that we are able to mock out time in tests, modify tests to use mock time and be more predictable.
Also avoid AfterFunc cause of potential problems with channel consumption.