-
Notifications
You must be signed in to change notification settings - Fork 14
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
test: update mockery configuration and regenerate mocks #955
base: v1.3-dev
Are you sure you want to change the base?
Conversation
Bumps [github.com/vektra/mockery/v2](https://github.com/vektra/mockery) from 2.41.0 to 2.46.2. - [Release notes](https://github.com/vektra/mockery/releases) - [Changelog](https://github.com/vektra/mockery/blob/master/docs/changelog.md) - [Commits](vektra/mockery@v2.41.0...v2.46.2) --- updated-dependencies: - dependency-name: github.com/vektra/mockery/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]>
…/vektra/mockery/v2-2.46.2' into build/go-1.23
5e84ee7
to
809073e
Compare
WalkthroughThe pull request introduces several changes across multiple files, primarily focusing on mock implementations and configuration for testing. Key updates include the introduction of a new Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
.mockery.yaml (2)
1-9
: Consider enablingwith-expecter
for more powerful mocking capabilities.The global configuration settings are well-structured and follow good practices. However, you might want to consider setting
with-expecter: true
. This would generate expecter structs, allowing for more powerful and flexible mocking scenarios, especially useful for complex testing situations.The rest of the configuration looks good:
- The directory structure and naming conventions are clear and intuitive.
- Using warn-level logging and disabling version strings will keep the output clean.
- Setting
all: false
gives precise control over which interfaces are mocked.
10-71
: Comprehensive package list, but consider addressing potential naming conflicts.The package list for mock generation is thorough and covers key components of the Tenderdash project. It's great to see that various crucial interfaces are included, which will facilitate effective testing and dependency injection throughout the codebase.
However, there are two suggestions for improvement:
Potential naming conflicts: Some packages (e.g.,
abci/client
anddash/core
) both have aClient
interface. This might lead to naming conflicts in the generated mocks. Consider using more specific names or prefixing the mock names with the package name to avoid confusion.Add explanatory comments: It would be beneficial to add brief comments explaining the purpose of mocking each interface, especially for less obvious ones. This can help other developers understand the testing strategy and the role of each mock.
cmd/tenderdash/commands/reindex_event_test.go (1)
Line range hint
1-203
: Overall assessment: Changes align with PR objectives.The modifications in this file successfully update the mocking implementation as intended. The test logic remains unchanged, which suggests that the new mock is compatible with the existing test structure. This approach minimizes the risk of introducing new bugs while achieving the goal of updating the mocking solution.
To further improve the PR:
- Consider adding a comment explaining the reason for the mock update, which would help future developers understand the change.
- Ensure that all other files using
EventSink
mocks have been similarly updated for consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (23)
- .github/workflows/check-generated.yml (2 hunks)
- .mockery.yaml (1 hunks)
- Makefile (1 hunks)
- cmd/tenderdash/commands/reindex_event_test.go (2 hunks)
- dash/core/mocks/client.go (3 hunks)
- internal/blocksync/mocks/block_client.go (0 hunks)
- internal/consensus/mocks/fast_sync_reactor.go (0 hunks)
- internal/proxy/mocks/app_conn_mempool.go (0 hunks)
- internal/proxy/mocks/app_conn_query.go (0 hunks)
- internal/proxy/mocks/app_conn_snapshot.go (0 hunks)
- internal/state/mocks/event_sink.go (0 hunks)
- internal/statesync/mocks/Metricer.go (0 hunks)
- rpc/client/mocks/abci_client.go (0 hunks)
- rpc/client/mocks/events_client.go (0 hunks)
- rpc/client/mocks/evidence_client.go (0 hunks)
- rpc/client/mocks/history_client.go (0 hunks)
- rpc/client/mocks/mempool_client.go (0 hunks)
- rpc/client/mocks/network_client.go (0 hunks)
- rpc/client/mocks/sign_client.go (0 hunks)
- rpc/client/mocks/status_client.go (0 hunks)
- rpc/client/mocks/subscription_client.go (0 hunks)
- scripts/mockery_generate.sh (1 hunks)
- types/mocks/privvalidator.go (15 hunks)
💤 Files with no reviewable changes (16)
- internal/blocksync/mocks/block_client.go
- internal/consensus/mocks/fast_sync_reactor.go
- internal/proxy/mocks/app_conn_mempool.go
- internal/proxy/mocks/app_conn_query.go
- internal/proxy/mocks/app_conn_snapshot.go
- internal/state/mocks/event_sink.go
- internal/statesync/mocks/Metricer.go
- rpc/client/mocks/abci_client.go
- rpc/client/mocks/events_client.go
- rpc/client/mocks/evidence_client.go
- rpc/client/mocks/history_client.go
- rpc/client/mocks/mempool_client.go
- rpc/client/mocks/network_client.go
- rpc/client/mocks/sign_client.go
- rpc/client/mocks/status_client.go
- rpc/client/mocks/subscription_client.go
✅ Files skipped from review due to trivial changes (1)
- scripts/mockery_generate.sh
🧰 Additional context used
🔇 Additional comments (19)
.github/workflows/check-generated.yml (2)
38-38
: Simplified diff check for generated mocksThe removal of the
--stat
option from thegit diff
command simplifies the check. This change focuses the output solely on whether there are differences, without providing statistics about the changes.This simplification is beneficial as it:
- Reduces noise in the CI output
- Maintains the core functionality of detecting changes in generated mocks
- Potentially speeds up the check process slightly
The error message (lines 39-44) still provides clear instructions on what to do if changes are detected, so no important information is lost with this simplification.
26-26
: Verify the Go version numberThe update to a newer Go version is good practice. However, the version "1.23.2" seems unusual, as Go versions typically follow a different pattern (e.g., 1.20, 1.21, etc.).
Please confirm that this is the correct version number. If it's a typo, consider updating it to the latest stable Go version.
To verify the latest stable Go version, you can run:
✅ Verification successful
Go version "1.23.2" verified as the latest stable release.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Fetch the latest stable Go version curl -sSL https://golang.org/VERSION?m=textLength of output: 82
cmd/tenderdash/commands/reindex_event_test.go (2)
16-16
: LGTM: New import for updated mocking solution.The addition of the
imocks
import aligns with the PR objective of updating the mocking solution. This change is consistent with the migration from the current deprecated mocking solution to the new configuration.
140-140
: LGTM: Updated mock type consistent with new import.The change from
*mocks.EventSink
to*imocks.EventSink
is consistent with the new import and aligns with the PR objectives of updating the mocking solution.To ensure consistency across the codebase, please run the following script to verify that all
EventSink
mocks have been updated:✅ Verification successful
LGTM: Updated mock type in
reindex_event_test.go
is correct.
The change from*mocks.EventSink
to*imocks.EventSink
incmd/tenderdash/commands/reindex_event_test.go
aligns with the PR objectives.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all EventSink mocks have been updated to use imocks. # Test: Search for any remaining uses of mocks.EventSink rg --type go 'mocks\.EventSink' # Test: Confirm new usage of imocks.EventSink rg --type go 'imocks\.EventSink'Length of output: 1006
dash/core/mocks/client.go (3)
9-10
: LGTM: New import added correctly.The new import for the
crypto
package is correctly added and is necessary for the updatedQuorumInfo
method signature.
Line range hint
155-170
: LGTM: Method body updated consistently.The
QuorumInfo
method body has been correctly updated to use the newcrypto.QuorumHash
type in type assertions and function calls. These changes are consistent with the method signature update and maintain the existing error handling and return logic.
Line range hint
1-240
: Summary: Mock file updated successfully.The changes to this mock file are consistent with the PR objectives. The
QuorumInfo
method has been updated to use the newcrypto.QuorumHash
type, and all related code has been adjusted accordingly. These changes should improve type safety and consistency in the project.To ensure full compatibility, please verify that:
- The actual
Client
interface in the main codebase has been updated to match this mock.- Any tests using this mock have been updated to use the new
crypto.QuorumHash
type.You can use the following script to check for the interface definition:
#!/bin/bash # Search for the Client interface definition rg --type go 'type\s+Client\s+interface' -A 20types/mocks/privvalidator.go (11)
28-36
: LGTM: Method signature and implementation updated correctlyThe
ExtractIntoValidator
method has been successfully updated to usecrypto.QuorumHash
instead ofbytes.HexBytes
for thequorumHash
parameter. The implementation logic has been adjusted accordingly to handle the new type.Also applies to: 36-43
48-55
: LGTM: Return type and implementation updated correctlyThe
GetFirstQuorumHash
method has been successfully updated to returncrypto.QuorumHash
instead ofbytes.HexBytes
. The implementation logic has been adjusted accordingly to handle the new return type.Also applies to: 55-57, 57-64, 64-75
Line range hint
78-87
: LGTM: Method signature and implementation updated correctlyThe
GetHeight
method has been successfully updated to usecrypto.QuorumHash
instead ofbytes.HexBytes
for thequorumHash
parameter. The implementation logic has been adjusted accordingly to handle the new type.Also applies to: 87-90, 90-96, 96-103
Line range hint
106-115
: LGTM: Method signature and implementation updated correctlyThe
GetPrivateKey
method has been successfully updated to usecrypto.QuorumHash
instead ofbytes.HexBytes
for thequorumHash
parameter. The implementation logic has been adjusted accordingly to handle the new type.Also applies to: 115-118, 118-126, 126-133
136-143
: LGTM: Return type and implementation updated correctlyThe
GetProTxHash
method has been successfully updated to returncrypto.ProTxHash
instead ofbytes.HexBytes
. The implementation logic has been adjusted accordingly to handle the new return type.Also applies to: 143-145, 145-148, 148-152, 152-163
Line range hint
166-175
: LGTM: Method signature and implementation updated correctlyThe
GetPubKey
method has been successfully updated to usecrypto.QuorumHash
instead ofbytes.HexBytes
for thequorumHash
parameter. The implementation logic has been adjusted accordingly to handle the new type.Also applies to: 175-178, 178-186, 186-193
Line range hint
196-205
: LGTM: Method signature and implementation updated correctlyThe
GetThresholdPublicKey
method has been successfully updated to usecrypto.QuorumHash
instead ofbytes.HexBytes
for thequorumHash
parameter. The implementation logic has been adjusted accordingly to handle the new type.Also applies to: 205-208, 208-216, 216-223
Line range hint
226-235
: LGTM: Method signature and implementation updated correctlyThe
SignProposal
method has been successfully updated to usecrypto.QuorumHash
instead ofbytes.HexBytes
for thequorumHash
parameter. The implementation logic has been adjusted accordingly to handle the new type.Also applies to: 235-238, 238-246, 246-253
256-264
: LGTM: Method signature and implementation updated correctlyThe
SignVote
method has been successfully updated to usecrypto.QuorumHash
instead ofbytes.HexBytes
for thequorumHash
parameter. The implementation logic has been adjusted accordingly to handle the new type.Also applies to: 264-270
274-276
: LGTM: Method signature updated correctlyThe
UpdatePrivateKey
method has been successfully updated to usecrypto.QuorumHash
instead ofbytes.HexBytes
for thequorumHash
parameter.
Line range hint
1-292
: Summary: Successful update of PrivValidator mockThis review has confirmed that all method signatures in the
PrivValidator
mock have been successfully updated to usecrypto.QuorumHash
instead ofbytes.HexBytes
for thequorumHash
parameter. The implementation logic for each method has been adjusted accordingly to handle the new type.These changes are consistent with the PR objectives of updating the mocking solution and align with the shift from
bytes.HexBytes
tocrypto.QuorumHash
in the main codebase. The updates should ensure that the mock accurately reflects the behavior of the actualPrivValidator
implementation.No issues or inconsistencies were found in the changes. The mock should now be compatible with the updated interfaces in the main codebase.
Makefile (1)
339-339
: LGTM. Verify mock generation consistency.The simplification of the
mockery
target by directly calling the script is a good change. It aligns with the PR objectives of updating the mockery configuration.To ensure this change doesn't affect the mock generation process or its output, please run the following verification:
This script will help verify that the mock generation process produces consistent results with the new implementation.
Issue being fixed or feature implemented
Current mocking solution with mockery using
go:generate
is deprecated.What was done?
How Has This Been Tested?
GHA
Breaking Changes
None
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
crypto.QuorumHash
instead ofbytes.HexBytes
.