Skip to content

Improve client test coverage#1024

Merged
ylg-avalabs merged 20 commits intomainfrom
improve-tests
Jan 14, 2026
Merged

Improve client test coverage#1024
ylg-avalabs merged 20 commits intomainfrom
improve-tests

Conversation

@ylg-avalabs
Copy link
Copy Markdown
Contributor

Why this should be merged

How this works

How this was tested

How is this documented

@ylg-avalabs ylg-avalabs changed the title Improve tests Improve client test coverage Nov 17, 2025
@ylg-avalabs ylg-avalabs marked this pull request as ready for review November 17, 2025 15:52
@ylg-avalabs ylg-avalabs requested a review from a team as a code owner November 17, 2025 15:52
Comment thread peers/info_client_test.go Outdated
Comment thread peers/proposervm_client_test.go Outdated
Comment on lines +138 to +139
// TestProposerVMAPI_CombinedQueryParamsAndHeaders verifies both work together
func TestProposerVMAPI_CombinedQueryParamsAndHeaders(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a way that headers and query params interact that we need to test them together?

Comment thread peers/proposervm_client_test.go Outdated
Comment thread vms/evm/destination_client_test.go Outdated
Comment thread peers/clients/proposervm_client_test.go Outdated
Comment thread peers/clients/proposervm_client_test.go Outdated
Comment thread peers/clients/info_client_test.go Outdated
Comment thread peers/clients/info_client_test.go
Copy link
Copy Markdown
Contributor

@geoff-vball geoff-vball left a comment

Choose a reason for hiding this comment

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

Just a few nits. They should also be applied to the other test in the file. Otherwise lgtm :)

Comment thread vms/evm/destination_client_test.go Outdated
Comment on lines +457 to +458
logger := logging.NoLog{}
_, err := NewDestinationClient(logger, &destinationBlockchain, time.Minute)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should just inline short declarations that are only used once.

Suggested change
logger := logging.NoLog{}
_, err := NewDestinationClient(logger, &destinationBlockchain, time.Minute)
_, err := NewDestinationClient(logging.NoLog{}, &destinationBlockchain, time.Minute)

Comment thread vms/evm/destination_client_test.go Outdated
client, err := NewDestinationClient(logger, &destinationBlockchain, time.Minute)
require.NoError(t, err)

ctx := context.Background()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
ctx := context.Background()
ctx := t.Context()

Comment thread vms/evm/destination_client_test.go Outdated
Comment on lines +526 to +527
mu.Lock()
defer mu.Unlock()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this mutex is just ensuring that the handler func has finished running? But ethClient.SuggestGasTipCap(ctx) won't finish until the handlerfunc is finished, so I don't think we need it.

@geoff-vball
Copy link
Copy Markdown
Contributor

@ylg-avalabs I left some feedback here that should be pretty easy to address, and then we can get this merged in :)

Comment thread vms/evm/destination_client_test.go Outdated
"X-API-Key": "secret-key",
}

var mu sync.Mutex
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This mutex isn't needed

Comment thread vms/evm/destination_client_test.go Outdated
"api-key": "secret-key-789",
}

var mu sync.Mutex
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This mutex isn't needed

Comment thread vms/evm/destination_client_test.go Outdated
AccountPrivateKeys: []string{"56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027"},
}

logger := logging.NoLog{}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be cleaner to inline logging.NoLog{} on the line below (and do the same for the other functions in this file)

Copy link
Copy Markdown
Contributor

@batconjurer batconjurer left a comment

Choose a reason for hiding this comment

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

It seems to me that there is a lot of code repetition. It would be nice to try and abstract the setup into separate functions.

Copy link
Copy Markdown
Contributor

@geoff-vball geoff-vball left a comment

Choose a reason for hiding this comment

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

It might be worthwhile to consolidate these tests where applicable re: Jacob's comments, but this PR has been languishing for a while, and it's just test code, so I'm fine merging it as is if you'd like

@batconjurer
Copy link
Copy Markdown
Contributor

It might be worthwhile to consolidate these tests where applicable re: Jacob's comments, but this PR has been languishing for a while, and it's just test code, so I'm fine merging it as is if you'd like

Yeah, lets get it merged.

@ylg-avalabs ylg-avalabs merged commit e8d4f4b into main Jan 14, 2026
22 checks passed
@ylg-avalabs ylg-avalabs deleted the improve-tests branch January 14, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants