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

eth/fetcher: fix test to avoid hanging. Partial fix for #23331 #23351

Merged
merged 3 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion eth/fetcher/tx_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func TestTransactionFetcherSingletonRequesting(t *testing.T) {
func TestTransactionFetcherFailedRescheduling(t *testing.T) {
// Create a channel to control when tx requests can fail
proceed := make(chan struct{})

defer close(proceed)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: look into why this is needed

Copy link
Member

Choose a reason for hiding this comment

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

IMHO this is a bad change. The proceed channel is used to tightly control when the fetchers can tick ahead. If there's a leftover hanging, waiting to proceed, we should figure out if it's correct or not. And if correct, we should add a doFunc step that permits it to continue. If it's incorrect, we need to find why. Closing the channel just blindly unblocks stuff that might be incorrectly blocked.

testTransactionFetcherParallel(t, txFetcherTest{
init: func() *TxFetcher {
return NewTxFetcher(
Expand Down Expand Up @@ -1263,6 +1263,17 @@ func testTransactionFetcher(t *testing.T, tt txFetcherTest) {
fetcher.Start()
defer fetcher.Stop()

defer func() { // drain the wait chan on exit
for {
select {
case <-wait:
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

This continue is not needed.

default:
return
}
}
}()

// Crunch through all the test steps and execute them
for i, step := range tt.steps {
switch step := step.(type) {
Expand Down
11 changes: 7 additions & 4 deletions eth/filters/filter_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,15 @@ func TestLogFilterCreation(t *testing.T) {
)

for i, test := range testCases {
_, err := api.NewFilter(test.crit)
if test.success && err != nil {
id, err := api.NewFilter(test.crit)
if err != nil && test.success {
t.Errorf("expected filter creation for case %d to success, got %v", i, err)
}
if !test.success && err == nil {
t.Errorf("expected testcase %d to fail with an error", i)
if err == nil {
api.UninstallFilter(id)
if !test.success {
t.Errorf("expected testcase %d to fail with an error", i)
}
}
}
}
Expand Down