-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement GetResourceGovAddr
#21
Conversation
WalkthroughThe changes enhance the Changes
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 (
|
Codecov ReportAttention: Patch coverage is
|
35743bd
to
e89c911
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: 4
Outside diff range, codebase verification and nitpick comments (1)
dataverse/errors.go (1)
5-30
: Well-implemented custom error handling.The custom error types and handling mechanisms are implemented correctly. However, consider adding documentation comments for public types and functions to enhance code readability and maintainability.
The code changes are approved.
Add documentation comments for public types and functions.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- dataverse/client.go (2 hunks)
- dataverse/client_test.go (3 hunks)
- dataverse/errors.go (1 hunks)
- dataverse/predicate.go (1 hunks)
- dataverse/query.go (1 hunks)
Additional context used
GitHub Check: codecov/patch
dataverse/client.go
[warning] 51-53: dataverse/client.go#L51-L53
Added lines #L51 - L53 were not covered by tests
[warning] 56-58: dataverse/client.go#L56-L58
Added lines #L56 - L58 were not covered by tests
[warning] 61-65: dataverse/client.go#L61-L65
Added lines #L61 - L65 were not covered by tests
Gitleaks
dataverse/client_test.go
88-88: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
112-112: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
120-120: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
139-139: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
154-154: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
Additional comments not posted (5)
dataverse/predicate.go (1)
3-9
: Variables are well-defined and consistent.The use of
cgschema.IRI_Full
for defining constants is appropriate and follows Go best practices for external package utilization.The code changes are approved.
dataverse/client.go (3)
13-15
: Clarify method documentation forGetResourceGovAddr
.The documentation for
GetResourceGovAddr
is clear and concise, explaining the method's purpose and its interaction with the cognitarium service.
21-23
: Review the updatedclient
struct.The addition of
cognitariumClient
andcognitariumAddr
to theclient
struct is necessary for the new functionality. This change aligns with the PR's objective to enhance governance address retrieval.
26-37
: Ensure proper initialization of new clients inNewDataverseClient
.The constructor now correctly initializes the
cognitariumClient
andcognitariumAddr
. However, ensure that all calls to this constructor throughout the codebase are updated to pass the new requiredcognitariumClient
parameter.Verification successful
All calls to
NewDataverseClient
are correctly updated.The function
NewDataverseClient
is only called in the test filedataverse/client_test.go
, and all instances include the newcognitariumClient
parameter. No other calls were found in the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `NewDataverseClient` include the new parameter. # Test: Search for the function usage. Expect: Only occurrences with the new signature. rg --type go -A 5 $'NewDataverseClient'Length of output: 1572
Script:
#!/bin/bash # Description: Search for all calls to `NewDataverseClient` in the codebase to ensure they include the new parameter. # Search for the function usage across the entire codebase. rg --type go -A 5 'NewDataverseClient'Length of output: 1572
dataverse/client_test.go (1)
47-55
: Review the updated test setup forNewDataverseClient
.The test setup now includes a mock for the
cognitariumClient
, which is necessary for the expanded functionality of theNewDataverseClient
function. This change is well-implemented and aligns with the modifications in the main code.
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 details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- dataverse/client.go (2 hunks)
Additional context used
GitHub Check: codecov/patch
dataverse/client.go
[warning] 51-53: dataverse/client.go#L51-L53
Added lines #L51 - L53 were not covered by tests
[warning] 56-58: dataverse/client.go#L56-L58
Added lines #L56 - L58 were not covered by tests
[warning] 61-65: dataverse/client.go#L61-L65
Added lines #L61 - L65 were not covered by tests
Additional comments not posted (4)
dataverse/client.go (4)
13-15
: Clarify the method's purpose in the interface comment.The comment for
GetResourceGovAddr
in theClient
interface is clear and provides a good explanation of what the method does. This is crucial for understanding the method's purpose at a glance.
21-23
: Review the updatedclient
struct.The addition of
cognitariumClient
andcognitariumAddr
to theclient
struct is consistent with the PR's objective to enhance governance address retrieval. This change supports the new functionality required by theGetResourceGovAddr
method.
68-87
: Refine error handling inGetResourceGovAddr
.The method now includes comprehensive error handling for various failure scenarios, such as no results or incorrect data types. This is a significant improvement in robustness.
However, the use of
context.Background()
in line 70 should be replaced with the passedcontext.Context
to ensure proper propagation of context.Apply this diff to fix the context usage:
-response, err := c.cognitariumClient.Select(context.Background(), &cgschema.QueryMsg_Select{Query: query}) +response, err := c.cognitariumClient.Select(ctx, &cgschema.QueryMsg_Select{Query: query})Likely invalid or redundant comment.
26-37
: Ensure proper initialization of new client fields.The constructor
NewDataverseClient
has been updated to includecognitariumClient
as a parameter and initializes it within theclient
struct. This is a necessary change to support the new functionality. However, ensure that all instances whereNewDataverseClient
is used are updated to pass the new parameter.Verification successful
All instances of
NewDataverseClient
are updated correctly.The function
NewDataverseClient
is used only in the test filedataverse/client_test.go
, and all instances include the new parametercognitariumClient
. No other usages were found in the codebase, confirming that the update is complete.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all instances of `NewDataverseClient` are updated to include the new parameter. # Test: Search for the function usage. Expect: Only occurrences with the new signature. rg --type go -A 5 $'NewDataverseClient'Length of output: 1572
Script:
#!/bin/bash # Comprehensive search for all instances of `NewDataverseClient` in the codebase to ensure all usages are updated. rg --type go 'NewDataverseClient'Length of output: 432
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.
That's pretty great thanks 👍
I just noticed minor remarks :)
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: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- dataverse/client.go (2 hunks)
- dataverse/client_test.go (2 hunks)
Additional context used
GitHub Check: codecov/patch
dataverse/client.go
[warning] 49-51: dataverse/client.go#L49-L51
Added lines #L49 - L51 were not covered by tests
[warning] 54-57: dataverse/client.go#L54-L57
Added lines #L54 - L57 were not covered by tests
Gitleaks
dataverse/client_test.go
66-66: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
90-90: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
98-98: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
117-117: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
132-132: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
Additional comments not posted (11)
dataverse/client.go (7)
7-7
: LGTM: Import statement addition.The new import for the cognitarium schema is correctly added and necessary for the new functionality.
13-15
: LGTM: Clear method documentation added.The new comments for
GetResourceGovAddr
provide a clear explanation of the method's purpose and functionality.
21-22
: LGTM: Client struct updated.The addition of the
cognitariumClient
field to theclient
struct is appropriate for the new functionality.
60-79
: LGTM: Comprehensive implementation of GetResourceGovAddr.The
GetResourceGovAddr
method has been fully implemented with appropriate query construction, cognitarium client interaction, and error handling. The use of the passedctx
addresses the previous comment about usingcontext.Background()
.
44-57
: LGTM: Enhanced client creation with cognitarium support.The
NewClient
function has been updated to fetch the cognitarium address and create a cognitarium client, which is necessary for the new functionality. The error handling is appropriate.As noted by the static analysis tool, there's a lack of test coverage for this new logic. Consider adding unit tests to cover the cognitarium address fetching and client creation scenarios.
To verify the current test coverage and identify areas needing improvement, you can run:
Verification successful
Test Coverage Verified for
NewClient
FunctionThe
NewClient
function is covered by tests in thedataverse/client_test.go
file, specifically by theTestClient_NewClient
function. This addresses the concern about the lack of test coverage.
- Test file:
dataverse/client_test.go
- Test function:
TestClient_NewClient
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check test coverage for NewClient function go test -v -coverprofile=coverage.out ./dataverse go tool cover -func=coverage.out | grep NewClientLength of output: 243
Script:
#!/bin/bash # Find all test files in the dataverse directory fd '_test.go' dataverse # Search for test functions that might be testing NewClient rg 'func Test.*NewClient' --glob '**/*_test.go'Length of output: 165
Tools
GitHub Check: codecov/patch
[warning] 49-51: dataverse/client.go#L49-L51
Added lines #L49 - L51 were not covered by tests
[warning] 54-57: dataverse/client.go#L54-L57
Added lines #L54 - L57 were not covered by tests
25-28
: LGTM: Updated client constructor with new parameter.The
NewDataverseClient
function has been correctly updated to include thecognitariumClient
parameter and initialize it in the returned client.However, as noted by the static analysis tool, there's a lack of test coverage for this new initialization logic. Consider adding unit tests to cover the new client initialization scenarios.
To verify the current test coverage, you can run the following command:
Also applies to: 31-31
Verification successful
Test coverage for
NewDataverseClient
is present.The
NewDataverseClient
function is covered by tests indataverse/client_test.go
, where it is called with mock clients and the error is checked. This indicates that the initialization logic, including the new parameter, is being tested.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check test coverage for NewDataverseClient function go test -v -coverprofile=coverage.out ./dataverse go tool cover -func=coverage.out | grep NewDataverseClientLength of output: 252
Script:
#!/bin/bash # Find test files in the dataverse directory fd --extension go --glob '*_test.go' dataverse # Search for test functions that reference NewDataverseClient rg 'NewDataverseClient' --glob '*_test.go' -A 3Length of output: 390
Line range hint
1-93
: Overall: Good implementation with room for improved test coverage.The changes successfully implement the new functionality for retrieving the governance address of a resource. The code quality is good, with appropriate error handling, clear documentation, and correct use of the cognitarium client.
To ensure the reliability of these changes, it's recommended to add more unit tests, particularly for:
- The new client initialization logic in
NewDataverseClient
andNewClient
.- The
GetResourceGovAddr
method, covering various scenarios (success, no results, incorrect data types).You can use the following script to identify areas with low test coverage:
This will help pinpoint specific functions or methods that need additional test coverage.
Verification successful
Tests for New Functionality Found
The
client_test.go
file contains tests for theNewClient
,NewDataverseClient
, andGetResourceGovAddr
methods, indicating that there is test coverage for the new functionality. Ensure these tests are comprehensive and cover various scenarios to maintain reliability.
client_test.go
: Contains tests forNewClient
,NewDataverseClient
, andGetResourceGovAddr
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Generate a test coverage report go test -v -coverprofile=coverage.out ./dataverse go tool cover -func=coverage.outLength of output: 226
Script:
#!/bin/bash # Find all Go test files in the dataverse package and search for tests related to the new functionality fd --extension go --exec grep -l 'func Test' {} + | xargs grep -E 'NewDataverseClient|NewClient|GetResourceGovAddr'Length of output: 1712
Tools
GitHub Check: codecov/patch
[warning] 49-51: dataverse/client.go#L49-L51
Added lines #L49 - L51 were not covered by tests
[warning] 54-57: dataverse/client.go#L54-L57
Added lines #L54 - L57 were not covered by testsdataverse/client_test.go (4)
9-9
: LGTM: Import statements updated correctly.The addition of the cognitarium schema import is appropriate for the new test cases.
51-53
: LGTM:toAddress
function is well-implemented.The generic
toAddress
function is a useful helper for creating pointers to values. This is often necessary when working with generated code or APIs that require pointers.
162-172
: LGTM: Test setup correctly updated for new client structure.The test setup has been appropriately modified to include a mock Cognitarium client and update the
NewDataverseClient
function call. This reflects the changes in theClient
implementation.
Line range hint
55-190
: LGTM: Comprehensive test cases forGetResourceGovAddr
.The
TestClient_GetResourceGovAddr
function provides thorough coverage of various scenarios, including:
- Successful responses
- gRPC errors
- Invalid variable bindings
- Missing results
- Incorrect value types
The use of mock clients is appropriate for unit testing, and the test cases are well-structured.
Regarding the static analysis warnings about Generic API Keys:
If this script returns no results, it confirms that these DIDs are only used in test files and do not pose a security risk.
Verification successful
Verification Successful: DIDs are only used in test files.
The flagged DIDs are confirmed to be used exclusively within test files, ensuring they do not pose a security risk. The static analysis warnings can be safely disregarded in this context.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the flagged DIDs are only used in test files # Test: Search for the flagged DIDs outside of test files rg --type go --glob '!**/*_test.go' 'did:key:zQ3shuwMJWYXRi64qiGojsV9bPN6Dtugz5YFM2ESPtkaNxTZ5'Length of output: 95
Tools
Gitleaks
66-66: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
90-90: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
98-98: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
117-117: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
132-132: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
e3afdd5
to
991d189
Compare
991d189
to
bc5b3ad
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: 7
Outside diff range, codebase verification and nitpick comments (5)
dataverse/export_test.go (2)
8-16
: LGTM: NewDataverseClient constructor.The
NewDataverseClient
function is well-structured and serves as a constructor for theClient
interface. This is a good practice for testing purposes.Consider adding a brief comment explaining the purpose of this function, especially since it's in a test file. For example:
// NewDataverseClient creates a new Client instance for testing purposes. func NewDataverseClient( dataverseClient dvschema.QueryClient, cognitariumClient cgschema.QueryClient, ) Client { // ... (rest of the function) }
18-18
: LGTM: Exporting internal function for testing.The assignment of
GetCognitariumAddr
togetCognitariumAddr
is a good practice for exposing internal functions in test files.Consider adding a brief comment explaining why this assignment is necessary. For example:
// GetCognitariumAddr exposes the internal getCognitariumAddr function for testing purposes. var GetCognitariumAddr = getCognitariumAddrdataverse/client_test.go (1)
8-8
: Inconsistent Import Alias Usage DetectedThe import alias for the package
github.com/axone-protocol/axone-contract-schema/go/dataverse-schema/v5
is inconsistent across the codebase. Whiledvschema
is used indataverse/export_test.go
anddataverse/client.go
, the old aliasschema
is still used intestutil/dataverse_client_mocks.go
. Please update the alias intestutil/dataverse_client_mocks.go
todvschema
for consistency.
testutil/dataverse_client_mocks.go
: Update alias fromschema
todvschema
.Analysis chain
LGTM: Import statement updated.
The import for the schema package has been renamed from
schema
todvschema
. This change is approved.Ensure that this change is consistent across the codebase:
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for any remaining imports of the old schema package name # Test: Search for old import. Expect: No results rg --type go 'github\.com/axone-protocol/axone-contract-schema/go/dataverse-schema/v5[^/]' -g '!dataverse/client_test.go'Length of output: 837
dataverse/governance_test.go (2)
15-17
: LGTM: Helper functiontoAddress
.The
toAddress
function is a useful generic helper for creating pointers to values. This is particularly helpful when working with generated code that uses pointers for optional fields.Consider adding a brief comment explaining the purpose of this function:
+// toAddress returns a pointer to the input value. +// This is useful for creating pointers to values when working with generated code. func toAddress[T any](v T) *T { return &v }
19-118
: LGTM: Test function and test cases.The
TestClient_GetResourceGovAddr
function and its test cases are well-structured and comprehensive. They cover various scenarios including successful responses, error handling, and edge cases.Consider adding a test case for an empty resource DID to ensure proper handling of invalid input:
{ name: "empty resource DID", resourceDID: "", response: nil, responseError: nil, wantErr: dataverse.NewDVError(dataverse.ErrInvalidInput, fmt.Errorf("empty resource DID")), wantResult: "", },Tools
Gitleaks
30-30: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
54-54: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
62-62: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
81-81: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
96-96: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- dataverse/client.go (2 hunks)
- dataverse/client_test.go (1 hunks)
- dataverse/export_test.go (1 hunks)
- dataverse/governance.go (1 hunks)
- dataverse/governance_test.go (1 hunks)
Additional context used
GitHub Check: codecov/patch
dataverse/governance.go
[warning] 32-33: dataverse/governance.go#L32-L33
Added lines #L32 - L33 were not covered by testsdataverse/client.go
[warning] 39-41: dataverse/client.go#L39-L41
Added lines #L39 - L41 were not covered by tests
[warning] 44-47: dataverse/client.go#L44-L47
Added lines #L44 - L47 were not covered by tests
Gitleaks
dataverse/governance_test.go
30-30: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
54-54: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
62-62: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
81-81: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
96-96: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
Additional comments not posted (12)
dataverse/export_test.go (1)
1-6
: LGTM: Package declaration and imports.The package declaration and imports are appropriate for a test file in the dataverse package. The imports correctly alias the schema packages from the axone-contract-schema repository.
dataverse/governance.go (2)
3-8
: LGTM: Import statements are appropriate.The import statements include necessary standard libraries and the custom cognitarium-schema package, which aligns with the functionality implemented in this file.
10-30
: Overall implementation looks good, but consider the following points:
The
buildGetResourceGovAddrRequest
function is not visible in this file. Consider adding a comment explaining its purpose or moving its implementation to this file for better readability.The error messages use custom error types (e.g., ErrNoResult, ErrVarNotFound, ErrType). Ensure these are properly defined and documented in the package.
The method assumes that the "code" binding will contain a URI type. This might be an implementation detail of the cognitarium schema. Consider adding a comment explaining this assumption or handling other potential types gracefully.
To verify the
buildGetResourceGovAddrRequest
function and error types, run the following script:Verification successful
Verification successful: Error types and function are properly defined.
- The error types
ErrNoResult
,ErrVarNotFound
, andErrType
are defined asMessageError
constants indataverse/errors.go
.- The
buildGetResourceGovAddrRequest
function is located indataverse/query.go
.These components are correctly implemented and used in the codebase.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the buildGetResourceGovAddrRequest function and error types # Test: Search for the buildGetResourceGovAddrRequest function echo "Searching for buildGetResourceGovAddrRequest function:" rg --type go "func buildGetResourceGovAddrRequest" # Test: Search for error type definitions echo "Searching for error type definitions:" rg --type go "var Err(NoResult|VarNotFound|Type)"Length of output: 403
Script:
#!/bin/bash # Description: Verify the definitions of the error types as constants or in other forms # Test: Search for error type definitions as constants echo "Searching for error type definitions as constants:" rg --type go "const Err(NoResult|VarNotFound|Type)" # Test: Search for error type definitions in other forms echo "Searching for error type definitions in other forms:" rg --type go "ErrNoResult|ErrVarNotFound|ErrType"Length of output: 1196
dataverse/client.go (6)
7-15
: LGTM: Import and interface changes look good.The addition of the cognitarium schema import and the detailed method comments for
GetResourceGovAddr
in theClient
interface improve the code's clarity and documentation.
21-22
: LGTM: Client struct update is appropriate.The addition of the
cognitariumClient
field to theclient
struct aligns with the PR objective of interacting with the Cognitarium for governance address retrieval.
Line range hint
49-58
: LGTM: Well-implemented helper function.The
getCognitariumAddr
function is a good addition. It encapsulates the logic for retrieving the cognitarium address and follows good practices for error handling and type conversion.Tools
GitHub Check: codecov/patch
[warning] 39-41: dataverse/client.go#L39-L41
Added lines #L39 - L41 were not covered by tests
[warning] 44-47: dataverse/client.go#L44-L47
Added lines #L44 - L47 were not covered by tests
Line range hint
1-58
: LGTM: Removal ofNewDataverseClient
and integration intoNewClient
.The removal of the
NewDataverseClient
function and the integration of its functionality into the newNewClient
function is a good refactoring decision. It simplifies the client creation process and aligns with the PR objectives.
Line range hint
1-58
: Overall, the changes in this file are well-implemented and align with the PR objectives.The modifications to the
Client
interface, theclient
struct, and the introduction of theNewClient
function effectively integrate the Cognitarium client and improve the governance address retrieval functionality. The code is well-structured and follows good practices.A few minor suggestions have been made regarding error handling and test coverage. Addressing these points will further enhance the robustness and maintainability of the code.
Great job on implementing these changes!
34-47
: Improve error wrapping and consider increasing test coverage.The
NewClient
function looks well-implemented overall. However, there are a couple of points to consider:
Error wrapping: The error returned from
getCognitariumAddr
is already wrapped, so you don't need to wrap it again. Consider simplifying the error handling.Test coverage: The static analysis tool indicates that some lines in this function are not covered by tests.
Consider simplifying the error handling like this:
- if err != nil { - return nil, fmt.Errorf("failed to get cognitarium address: %w", err) - } + if err != nil { + return nil, err + }To address the test coverage issue, we can verify the current test coverage for this function:
If the coverage is indeed low, consider adding more test cases to cover different scenarios, such as:
- Successful client creation
- Failure to create dataverse client
- Failure to get cognitarium address
- Failure to create cognitarium client
Tools
GitHub Check: codecov/patch
[warning] 39-41: dataverse/client.go#L39-L41
Added lines #L39 - L41 were not covered by tests
[warning] 44-47: dataverse/client.go#L44-L47
Added lines #L44 - L47 were not covered by testsdataverse/governance_test.go (3)
1-13
: LGTM: Package declaration and imports.The package declaration and imports are appropriate for a test file. They include necessary standard libraries, internal packages, and third-party testing libraries.
120-156
: LGTM: Test execution loop.The test execution loop is well-structured and follows good testing practices:
- It iterates through all test cases.
- Uses GoConvey for clear test assertions.
- Properly sets up and tears down mocks.
- Creates a client with mocked dependencies.
- Executes the
GetResourceGovAddr
method and verifies the results.
30-30
: False positive: Generic API Key detections.The static analysis tool Gitleaks has flagged several lines as containing "Generic API Keys". These are false positives. The detected strings are examples of DIDs (Decentralized Identifiers) used in test cases, not actual API keys.
No action is required to address these false positives.
Also applies to: 54-54, 62-62, 81-81, 96-96
Tools
Gitleaks
30-30: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
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.
💪 Looks good :)
Implement the
GetResourceGovAddr
method to retrieve the governance contract address of a given resource DID by querying the Cognitarium.It use the
axone-contract-schema
clients generated throughgo-codegen
. Generated code use typealias to represent string and args require pointer to those typealias and require a little hack allowing to avoid create intermediate variable to give the typealias reference (ref
helper).