-
Notifications
You must be signed in to change notification settings - Fork 610
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
tests: refactor solomachine tests to use light client module as entrypoint. #6038
Conversation
WalkthroughWalkthroughThis update focuses on enhancing the Solo Machine light client module within the IBC protocol, primarily through the introduction of new test functions and renaming existing ones for consistency. It improves error handling and refactors client state testing, aiming to increase code coverage and streamline verification processes related to client status, membership, and state updates. Changes
Possibly related issues
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
opening as draft to get a first run of tests. Will update testing funcs to use |
6327575
to
7569798
Compare
7569798
to
5a9a52f
Compare
@@ -26,7 +26,7 @@ func VerifySignature(pubKey cryptotypes.PubKey, signBytes []byte, sigData signin | |||
if err := pubKey.VerifyMultisignature(func(signing.SignMode) ([]byte, error) { | |||
return signBytes, nil | |||
}, data); err != nil { | |||
return err | |||
return errorsmod.Wrapf(ErrSignatureVerificationFailed, err.Error()) |
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.
Unsure why this didn't do this before but made sense to add. Bumped into it due to tests running for solomachine's configured with a single pubkey and a multi one, adding error checking in the tests lead to a discrepancy here.
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (3)
- modules/light-clients/06-solomachine/client_state_test.go (4 hunks)
- modules/light-clients/06-solomachine/light_client_module_test.go (1 hunks)
- modules/light-clients/06-solomachine/proof.go (1 hunks)
Additional comments: 3
modules/light-clients/06-solomachine/proof.go (1)
- 29-29: The error wrapping in
VerifySignature
enhances error context, which is good practice. However, consider adding more specific context to the error message to aid in debugging. For example, including details about the multisignature verification failure could be helpful.modules/light-clients/06-solomachine/client_state_test.go (1)
- 3-13: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-794]
The modifications to the test functions in
client_state_test.go
significantly improve test coverage for various verification scenarios. Ensure that each test case has a descriptive name that clearly indicates what is being tested. Additionally, keep the setup and assertions focused and concise to maintain test clarity and effectiveness.modules/light-clients/06-solomachine/light_client_module_test.go (1)
- 1-794: The additions and modifications to the test functions in
light_client_module_test.go
enhance the test suite's coverage and robustness. Ensure that the tests are well-structured and isolated, with clear, descriptive names for each test case. Additionally, verify that the assertions accurately reflect the expected outcomes for each scenario.
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (2)
- modules/light-clients/06-solomachine/light_client_module_test.go (2 hunks)
- modules/light-clients/06-solomachine/solomachine_test.go (1 hunks)
Additional comments: 7
modules/light-clients/06-solomachine/solomachine_test.go (1)
- 48-49: The identifiers for the Solo Machine instances have been updated to
"06-solomachine-1"
and"06-solomachine-2"
. This change improves the clarity of the test setup by making the identifiers more descriptive. However, ensure that these new identifiers are consistently used throughout all tests and related documentation to avoid confusion.modules/light-clients/06-solomachine/light_client_module_test.go (6)
- 24-45: The
TestStatus
function tests the status of a Solo Machine client before and after freezing it. This test is well-structured and covers an important aspect of client behavior. It's good practice to also include a test case for an uninitialized or incorrectly initialized client to ensure the function behaves as expected in error scenarios.- 47-92: The
TestGetTimestampAtHeight
function introduces test cases for retrieving timestamps at specific heights. The setup and execution of test cases are clear and well-structured. However, consider adding a test case for heights that have not been reached yet or are invalid to ensure robust error handling.- 94-572: The
TestVerifyMembership
function tests various scenarios for verifying membership. The test cases are comprehensive, covering success and failure scenarios. It's advisable to ensure that all error messages are clear and informative, especially in complex scenarios like malformed proofs or invalid path types. This helps in debugging and maintaining the tests.- 574-792: The
TestVerifyNonMembership
function, similar toTestVerifyMembership
, tests the verification of non-membership with comprehensive scenarios. Ensure consistency in error handling and messaging across these tests for better maintainability and clarity.- 1-796: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [793-892]
The
TestRecoverClient
function tests the recovery of a Solo Machine client. This test is crucial for ensuring the robustness of client recovery mechanisms. It's important to include a variety of scenarios, including those where recovery should not be possible, to fully test the boundaries of this functionality.
- 890-896: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [893-899]
The
TestVerifyUpgradeAndUpdateState
function attempts to verify the upgrade and update state but expects an error. This test is a good start, but it would be beneficial to expand it with more detailed scenarios, including successful upgrade paths and edge cases that might occur during the upgrade process.
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.
Review Status
Actionable comments generated: 1
Configuration used: .coderabbit.yml
Files selected for processing (2)
- modules/light-clients/06-solomachine/client_state_test.go (4 hunks)
- modules/light-clients/06-solomachine/light_client_module_test.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- modules/light-clients/06-solomachine/light_client_module_test.go
Additional comments: 2
modules/light-clients/06-solomachine/client_state_test.go (2)
- 14-14: The code generally adheres to the Uber Golang style guide. However, consider using table-driven tests more effectively by defining the test cases outside the loop over SoloMachines. This approach can improve readability and maintainability.
- 14-14: The
TestSignBytesMarshalling
function is clear and tests an important aspect of marshalling behavior. Consider adding comments to explain why it's important thatsignBzNil
andsignBzEmptyArray
produce the same output, as this could help future maintainers understand the test's purpose.
I'll add functions for misbehaviour, update/upgrade etc and copy the test cases from there in the light client module, as is done for the 08-wasm PR. I think we'll probably fold more solomachine methods and then tests won't really need updating. |
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (4)
- modules/light-clients/06-solomachine/light_client_module_test.go (5 hunks)
- modules/light-clients/06-solomachine/misbehaviour_test.go (1 hunks)
- modules/light-clients/06-solomachine/proposal_handle_test.go (1 hunks)
- modules/light-clients/06-solomachine/update_test.go (1 hunks)
Files skipped from review due to trivial changes (1)
- modules/light-clients/06-solomachine/update_test.go
Additional comments: 9
modules/light-clients/06-solomachine/proposal_handle_test.go (1)
- 12-12: The function name
Test_Check_SubstituteAndUpdateState
uses underscores, which is unconventional in Go. Consider using CamelCase for test function names to align with Go naming conventions. However, if this naming scheme is a project-specific decision for readability or other reasons, it can be considered acceptable.modules/light-clients/06-solomachine/misbehaviour_test.go (1)
- 15-15: The function name
Test_MisbehaviourValidateBasic
uses underscores, which is unconventional in Go. Consider using CamelCase for test function names to align with Go naming conventions. However, if this naming scheme is a project-specific decision for readability or other reasons, it can be considered acceptable.modules/light-clients/06-solomachine/light_client_module_test.go (7)
- 26-26: The function
TestStatus
correctly tests various scenarios related to the status of a solo machine client. It's good practice to reset the test environment at the beginning of each test case usingsuite.SetupTest()
to ensure test isolation.- 81-81: The function
TestGetTimestampAtHeight
effectively tests the retrieval of timestamps at specific heights. Consider adding more test cases to cover edge cases, such as heights that have not been reached yet.- 204-204: The function
TestVerifyMembership
is comprehensive and covers a wide range of scenarios for verifying membership. It's good to see the use of table-driven tests for clarity. Ensure that the test data used (e.g.,counterpartyClientIdentifier
,ibctesting.FirstConnectionID
) is correctly set up and represents realistic scenarios.- 686-686: The function
TestVerifyNonMembership
thoroughly tests the non-membership verification logic. Similar toTestVerifyMembership
, ensure that the test setup accurately reflects realistic scenarios and that all necessary preconditions are met before running the tests.- 1005-1005: The function
TestUpdateState
demonstrates how to test state updates in the solo machine client. It's important to ensure that the test cases cover all possible state transitions, including error scenarios and edge cases. Consider adding comments to explain the rationale behind each test case, especially for complex scenarios.- 1092-1092: The function
TestVerifyUpgradeAndUpdateState
attempts to test the upgrade and update state functionality. However, it only tests for an error scenario. It would be beneficial to add more test cases that cover successful upgrade scenarios and verify the state of the client post-upgrade.- 1101-1101: The function
TestLatestHeight
correctly tests the retrieval of the latest height for a solo machine client. It's a good practice to test both successful retrieval and error scenarios, such as when the client state cannot be found. Ensure that the test setup accurately reflects the state of the blockchain at various heights.
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (2)
- modules/light-clients/06-solomachine/light_client_module_test.go (4 hunks)
- modules/light-clients/06-solomachine/update_test.go (5 hunks)
Files not summarized due to errors (1)
- modules/light-clients/06-solomachine/light_client_module_test.go: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (1)
- modules/light-clients/06-solomachine/update_test.go
Additional comments: 12
modules/light-clients/06-solomachine/light_client_module_test.go (12)
- 27-80: The test function
TestStatus
effectively covers different scenarios for the status of a SoloMachine client, including active, frozen, and unknown states. It's well-structured and follows best practices for table-driven tests in Go. However, it's recommended to add a brief comment above each test case struct to explain the purpose of the malleate function and expected outcomes for clarity and maintainability.- 82-124: The function
TestGetTimestampAtHeight
is well-implemented, testing both successful retrieval of a timestamp and handling of a client not found error. To enhance the test's robustness, consider adding more edge cases, such as querying a height that doesn't exist or a height with a default timestamp value. This would ensure the function behaves correctly under all circumstances.- 178-188: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [125-205]
In
TestInitialize
, the test cases are comprehensive, covering various scenarios for both consensus state and client state validation. However, there's a potential improvement in error handling. Specifically, when testing for expected errors, usingsuite.Require().ErrorIs
instead ofsuite.Require().ErrorContains
would ensure that the exact error type is returned, not just an error containing a specific message. This change would make the tests more precise and reliable.- suite.Require().ErrorContains(err, tc.expErr.Error()) + suite.Require().ErrorIs(err, tc.expErr)
- 205-687: The
TestVerifyMembership
function thoroughly tests various scenarios for verifying membership with the SoloMachine light client. It's commendable that the test covers a wide range of cases, including success scenarios for different state verifications and various error conditions. To further improve, consider abstracting the repetitive setup logic (e.g., creating signature documents, marshaling data) into helper functions. This would reduce code duplication and enhance readability.- 687-906: Similar to
TestVerifyMembership
,TestVerifyNonMembership
provides a comprehensive suite of tests for non-membership verification. The recommendation to abstract repetitive setup logic into helper functions applies here as well. Additionally, ensure consistency in error handling as mentioned previously, by usingsuite.Require().ErrorIs
for stronger assertion of expected errors.- 908-1004:
TestRecoverClient
effectively tests the client recovery functionality, including scenarios where the substitute client ID is malformed or does not match the expected client type. It's recommended to add a comment explaining the rationale behind each malleate function, especially for cases that might not be immediately obvious, such as why changing the substitute client ID to a wasm client ID should result in anErrInvalidClientType
.- 1006-1090: The
TestUpdateState
function tests the state update functionality of the SoloMachine light client. The test cases are well-structured and cover a range of scenarios. However, the test case named "invalid type misbehaviour" seems to expect a panic with a specific error message. Given that panicking in production code is generally discouraged, it would be beneficial to verify if the code being tested should indeed panic under these conditions or if there's a more graceful way to handle such errors.Verification successful
The grep command output confirms that the code in question does indeed use panic in response to an unsupported ClientMessage, specifically in the
update.go
file. This directly aligns with the concern raised in the review comment about the use of panic in production code for handling invalid client messages. Therefore, the review comment is validated by the evidence found in the codebase.* 1092-1164: `TestCheckForMisbehaviour` provides a good set of tests for checking misbehaviour detection. It's important to ensure that the test cases cover all possible misbehaviour scenarios comprehensively. Additionally, consider adding comments to explain the setup and expected outcomes in complex test cases, enhancing readability and maintainability. * 1166-1226: In `TestUpdateStateOnMisbehaviour`, the tests are focused and cover the essential scenarios. It's recommended to ensure that the test for "cannot find subject client state" accurately reflects the behavior of the system when the client state is indeed missing. This might involve verifying that the correct error is returned or that the system behaves as expected in the absence of the client state.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify if the code correctly handles invalid client messages without panicking grep -R "panic" modules/light-clients/06-solomachine/*.goLength of output: 1927
Verification successful
The grep output confirms that the test suite, specifically
TestUpdateStateOnMisbehaviour
, interacts with the client state retrieval mechanism (GetClientState
) and includes a test case designed to simulate and verify the system's behavior when the client state is missing. This test case manipulates theclientID
to an unused value to simulate the absence of the client state and expects a specific error, which aligns with the intended system behavior. Therefore, the review comment's concern is addressed by the existing test implementation.* 1228-1401: `TestVerifyClientMessageHeader` and `TestVerifyClientMessageMisbehaviour` are crucial for ensuring the integrity of client messages. These tests are comprehensive, but there's room for improvement in error handling and clarity. Specifically, ensure that the tests accurately reflect the expected behavior for each scenario, especially in cases where the outcome might depend on subtle aspects of the system's state or configuration. Adding detailed comments to complex test cases would also improve understandability. * 1649-1658: The `TestVerifyUpgradeAndUpdateState` function tests the upgrade verification and state update functionality. It's important to ensure that this test covers all relevant scenarios, including successful upgrades and various error conditions. If the current implementation is expected to always return an error (as suggested by the assertion), clarify the intended use case and conditions under which this functionality would be used. * 1659-1702: `TestLatestHeight` provides a straightforward test for retrieving the latest height of the client. The test cases are simple and cover the basic scenarios. To enhance the test's coverage, consider adding scenarios that involve updating the client's state to a new height and then verifying that `LatestHeight` returns the updated height. This would ensure the function behaves correctly after state changes.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Ensure that the system behaves correctly when the client state is missing grep -R "GetClientState" modules/light-clients/06-solomachine/*.goLength of output: 2197
Changed functions to check for errors, cleaned up some additional cruft (we should be able to remove |
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (1)
- modules/light-clients/06-solomachine/light_client_module_test.go (5 hunks)
Files not summarized due to errors (1)
- modules/light-clients/06-solomachine/light_client_module_test.go: Error: Message exceeds token limit
Additional comments: 12
modules/light-clients/06-solomachine/light_client_module_test.go (12)
- 27-78: The test cases for
TestStatus
are well-structured and cover various scenarios including active, frozen, and unknown client states. However, it's important to ensure that the setup for each test case does not inadvertently affect other tests due to shared state. Usingsuite.SetupTest()
within each test case can help isolate them.- 80-126: In
TestGetTimestampAtHeight
, consider adding more edge cases, such as querying a height that doesn't exist or a height that is greater than the current sequence. This can help ensure the robustness of the timestamp retrieval logic.- 138-174: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [127-231]
For
TestInitialize
, it's crucial to validate the error messages for each failure case to ensure they are informative and specific to the failure scenario. This aids in debugging and maintainability. Additionally, consider testing the initialization with various consensus state types to ensure compatibility.
- 207-685:
TestVerifyMembership
thoroughly tests the verification of membership for various states and scenarios. To enhance these tests, consider adding cases that simulate network or encoding errors to ensure the robustness of error handling. Also, verify the state of the client after successful and failed verifications to ensure it remains consistent.- 689-909: In
TestVerifyNonMembership
, similar to the membership verification tests, it would be beneficial to include tests for network or encoding errors. Additionally, testing the effect of non-membership verification on client state would ensure that the client's state is not inadvertently modified.- 912-1008:
TestRecoverClient
covers the basic scenarios for client recovery. It would be beneficial to add tests that simulate more complex recovery scenarios, such as recovering from a state where multiple updates have occurred since the last known good state. This can help ensure the resilience of the recovery process.- 1010-1095: For
TestUpdateState
, ensure that the tests cover scenarios where the update would be rejected due to invalid state transitions or incorrect signatures. This can help validate the robustness of the state update logic.- 1097-1169:
TestCheckForMisbehaviour
effectively tests for misbehaviour detection. Consider adding tests that simulate edge cases, such as misbehaviour that is barely within the acceptable time window or misbehaviour involving complex signature schemes.- 1171-1231: In
TestUpdateStateOnMisbehaviour
, it's important to test the client's state after misbehaviour has been detected and processed. This includes verifying that the client is correctly frozen and that subsequent updates are rejected.- 1233-1404:
TestVerifyClientMessageHeader
andTestVerifyClientMessageMisbehaviour
provide comprehensive tests for verifying client messages. To further improve these tests, consider adding scenarios that test the limits of the message verification logic, such as messages with minimal or maximal valid values.- 1652-1661:
TestVerifyUpgradeAndUpdateState
checks the upgrade verification logic. Given the critical nature of client upgrades, it's essential to include tests that cover a wide range of upgrade scenarios, including valid and invalid upgrade proposals, to ensure the upgrade process is robust and secure.- 1662-1704: For
TestLatestHeight
, adding tests that simulate scenarios where the client has undergone several state updates would provide a more thorough validation of theLatestHeight
functionality. This ensures that the latest height is accurately reported under various conditions.
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.
Great work, @DimitrisJim! Left just a bunch of nits.
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
|
||
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), clientID, sm.ClientState()) | ||
}, | ||
// TODO(jim): Doesn't fail on VerifySignature |
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.
Do we need to follow up on these TODOs?
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 am not entirely certain if this should fail there. Just added a todo since it seemed sketch to me. I will follow up on them.
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.
these were previously using the expPass
format in testing, right?
Will check out the branch and step through with debugger and see if I can help!
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.
yes, exactly. This is an unfortunate thing that happens when we swap from expPass to expErr, some expPass false
's just failed in earlier points.
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
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.
Review Status
Actionable comments generated: 2
Configuration used: .coderabbit.yml
Files selected for processing (1)
- modules/light-clients/06-solomachine/light_client_module_test.go (5 hunks)
Files not summarized due to errors (1)
- modules/light-clients/06-solomachine/light_client_module_test.go: Error: Message exceeds token limit
Additional comments: 2
modules/light-clients/06-solomachine/light_client_module_test.go (2)
- 22-24: Given the existing comment about potentially removing
smClientID
in favor ofunusedSmClientID
, it's important to assess if this change has been made. IfsmClientID
is no longer used, consider removing it to clean up the code and reduce confusion.- 22-24: The constants
smClientID
,unusedSmClientID
, andwasmClientID
are defined but it's important to ensure they are used appropriately throughout the tests. Given the previous comment about potentially consolidatingsmClientID
andunusedSmClientID
, verify their usage and ensure consistency in their application.Verification successful
The constants
smClientID
,unusedSmClientID
, andwasmClientID
are indeed used throughout the tests inmodules/light-clients/06-solomachine/light_client_module_test.go
, each serving specific roles within the test scenarios. The usage patterns suggest that these constants are applied consistently and appropriately, aligning with the expectations for varied test cases, including error handling and specific client testing. Therefore, the review comment is verified as the constants are utilized effectively in the test file.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check usage of smClientID and unusedSmClientID rg "smClientID|unusedSmClientID" modules/light-clients/06-solomachine/light_client_module_test.goLength of output: 1022
|
||
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), clientID, sm.ClientState()) | ||
}, | ||
// TODO(jim): Doesn't fail on VerifySignature |
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.
The TODO comment regarding the uncertainty of a test case failing at a specific point needs attention. It's crucial to resolve such uncertainties to ensure the test suite is reliable and covers all necessary scenarios. If the behavior is now understood, the TODO should be addressed by either implementing the required test logic or removing the comment if deemed unnecessary.
Would you like assistance in resolving this TODO by clarifying the expected behavior and potentially adding the necessary test logic?
Given the TODO comment about the uncertainty of a test case's expected behavior, it's crucial to follow up and ensure that all test cases are clear and accurately reflect the intended functionality. Ambiguities in test expectations can lead to overlooked issues or misinterpretations of the light client's behavior.
If there's still uncertainty regarding this test case, I can help clarify the expected behavior or assist in refining the test to ensure it accurately tests the intended functionality.
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (1)
- modules/light-clients/06-solomachine/solomachine_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- modules/light-clients/06-solomachine/solomachine_test.go
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.
really thorough work @DimitrisJim! thank you
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
Review Status
Configuration used: .coderabbit.yml
Files selected for processing (2)
- modules/light-clients/06-solomachine/light_client_module_test.go (5 hunks)
- modules/light-clients/06-solomachine/proof.go (1 hunks)
Files not summarized due to errors (1)
- modules/light-clients/06-solomachine/light_client_module_test.go: Error: Message exceeds token limit
Additional Context Used
Path-based Instructions (2)
modules/light-clients/06-solomachine/proof.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.modules/light-clients/06-solomachine/light_client_module_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
Additional comments not posted (14)
modules/light-clients/06-solomachine/proof.go (1)
29-29
: The error wrapping witherrorsmod.Wrapf
adds valuable context to the error, making it easier to debug issues related to signature verification. This change aligns with best practices for error handling in Go, as it provides more detailed error information.modules/light-clients/06-solomachine/light_client_module_test.go (13)
26-77
: TheTestStatus
function is well-structured and uses table-driven tests effectively to cover different client statuses. This approach enhances the readability and maintainability of the test code.
79-125
: TheTestGetTimestampAtHeight
function effectively tests the timestamp retrieval functionality, including both success and failure scenarios. The use of table-driven tests is commendable for its clarity.
137-173
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [126-233]
The
TestInitialize
function thoroughly tests the initialization process of the Solo Machine client, covering a wide range of scenarios. The detailed test cases ensure that both success and failure paths are adequately tested.
206-683
: TheTestVerifyMembership
function comprehensively tests the membership verification functionality of the Solo Machine client. The extensive range of test cases, including both success and failure scenarios, ensures thorough coverage of the functionality.
688-906
: TheTestVerifyNonMembership
function provides a thorough examination of the non-membership verification functionality, with a well-structured set of test cases that cover both successful and failure scenarios.
911-1007
: TheTestRecoverClient
function effectively tests the client recovery process, including both successful recovery and various failure scenarios. The clear separation of test cases enhances the readability and maintainability of the test code.
1009-1094
: TheTestUpdateState
function thoroughly tests the state update functionality for the Solo Machine client, covering both successful updates and failure scenarios. The use of table-driven tests contributes to the clarity of the test code.
1096-1168
: TheTestCheckForMisbehaviour
function effectively tests the detection of misbehaviour, including both successful detection and failure scenarios. The structured approach to testing ensures comprehensive coverage of the functionality.
1170-1229
: TheTestUpdateStateOnMisbehaviour
function provides a focused test on the client state update process in response to detected misbehaviour. The inclusion of both a successful update and a failure scenario due to missing client state ensures thorough testing of this critical functionality.
1232-1403
: TheTestVerifyClientMessageHeader
function comprehensively tests the verification of client message headers, covering a wide range of scenarios. The detailed test cases ensure that both success and failure paths are adequately tested, contributing to the robustness of the Solo Machine client implementation.
1405-1649
: TheTestVerifyClientMessageMisbehaviour
function thoroughly tests the verification of client message misbehaviour, with a well-structured set of test cases that cover both successful detection and various failure scenarios. This approach ensures comprehensive testing of misbehaviour detection functionality.
1651-1659
: TheTestVerifyUpgradeAndUpdateState
function correctly tests for an error due to missing implementation details for the upgrade verification and state update process. This placeholder test ensures that the functionality is not overlooked in future development.
1661-1702
: TheTestLatestHeight
function effectively tests the retrieval of the latest height for the Solo Machine client, including both a successful retrieval and a failure scenario due to missing client state. The clear and concise test cases contribute to the maintainability of the test suite.
// TODO(jim): Doesn't fail on VerifySignature | ||
clienttypes.ErrInvalidHeader, |
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.
The TODO comment at lines 1356-1357 regarding the uncertainty of a test case failing at a specific point needs attention. It's crucial to resolve such uncertainties to ensure the test suite is reliable and covers all necessary scenarios. If the behavior is now understood, the TODO should be addressed by either implementing the required test logic or removing the comment if deemed unnecessary.
Would you like assistance in resolving this TODO by clarifying the expected behavior and potentially adding the necessary test logic?
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.
Awesome work @DimitrisJim! Dropping my approval, will follow up on the todos with you also - I check this out locally and step through to take a look
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
|
||
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), clientID, sm.ClientState()) | ||
}, | ||
// TODO(jim): Doesn't fail on VerifySignature |
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.
these were previously using the expPass
format in testing, right?
Will check out the branch and step through with debugger and see if I can help!
1c3ad24
to
048debd
Compare
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: 0
Review Status
Configuration used: .coderabbit.yml
Files selected for processing (1)
- modules/light-clients/06-solomachine/light_client_module_test.go (5 hunks)
Files not summarized due to errors (1)
- modules/light-clients/06-solomachine/light_client_module_test.go: Error: Message exceeds token limit
Additional Context Used
Path-based Instructions (1)
modules/light-clients/06-solomachine/light_client_module_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
Additional comments not posted (13)
modules/light-clients/06-solomachine/light_client_module_test.go (13)
26-77
: Consider adding a test case for an uninitialized client state to ensure the function handles this scenario gracefully.
79-137
: Add a test case to verify behavior when the height argument is greater than the current height of the client state, ensuring the function's robustness in handling such cases.
149-185
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [138-243]
Ensure that the test case for a successful initialization verifies not only the absence of errors but also the correct state of the client post-initialization, such as checking if the client state and consensus state are correctly set in the store.
218-696
: Consider adding a test case for verifying membership with a valid proof but for data that does not exist in the state, to ensure the function correctly identifies non-existent data as not being part of the state.
700-920
: Add a test case for verifying non-membership with a proof that incorrectly indicates the presence of data, to ensure the function correctly identifies such proofs as invalid.
923-1019
: In the test case for successful client recovery, verify that the subject client's state is correctly updated to reflect the substitute client's state, including checking the consensus state and sequence number.
1021-1106
: For the test case "failure: invalid type misbehaviour", ensure that the test not only checks for the expected error but also verifies that the client state remains unchanged after attempting to update with an invalid misbehaviour.
1108-1180
: In the test case for detecting misbehaviour, verify that the client state is correctly updated to reflect the detected misbehaviour, such as checking if the client state is frozen.
1182-1241
: In the success scenario for updating state on misbehaviour, ensure that the test verifies the client state is correctly marked as frozen and that the consensus state is updated accordingly.
1244-1415
: For the test case "failure: invalid timestamp in header", consider adding a verification step to ensure that the client state remains unchanged after attempting to process an invalid header, maintaining the integrity of the client state.
1417-1660
: In the test case "success: successful misbehaviour", ensure that the test verifies the client state is correctly updated to reflect the detected misbehaviour, such as checking if the client state is frozen and the misbehaviour is recorded.
1663-1671
: Consider adding test cases for successful upgrade verification and update of the client state, as well as failure scenarios with specific reasons for the upgrade verification failure, to ensure comprehensive testing of the upgrade process.
1673-1715
: In the success scenario for retrieving the latest height, verify that the test setup includes updating the client state to a higher sequence number before retrieving the latest height, to ensure the function correctly returns the most recent height.
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: 3
Review Status
Configuration used: .coderabbit.yml
Files selected for processing (2)
- modules/light-clients/06-solomachine/client_state_test.go (4 hunks)
- modules/light-clients/06-solomachine/light_client_module_test.go (5 hunks)
Files not summarized due to errors (1)
- modules/light-clients/06-solomachine/light_client_module_test.go: Error: Message exceeds token limit
Additional Context Used
Path-based Instructions (2)
modules/light-clients/06-solomachine/client_state_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"modules/light-clients/06-solomachine/light_client_module_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
Additional comments not posted (1)
modules/light-clients/06-solomachine/client_state_test.go (1)
17-17
: LGTM! TheTestSignBytesMarshalling
function correctly tests the marshalling behavior for sign bytes with nil and empty array data.
Quality Gate passed for 'ibc-go'Issues Measures |
Description
partially addresses #6001
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
).godoc
comments.Files changed
in the GitHub PR explorer.SonarCloud Report
in the comment section below once CI passes.Summary by CodeRabbit
VerifySignature
function for improved clarity and context.