Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage for: api/gin + addressGroup #5175

Merged
merged 12 commits into from Apr 28, 2023
Merged

Coverage for: api/gin + addressGroup #5175

merged 12 commits into from Apr 28, 2023

Conversation

sstanculeanu
Copy link
Contributor

Reasoning behind the pull request

  • increase code coverage

Proposed changes

  • added unittests for api/gin + api/groups/addressGroup

Testing procedure

  • standard system test

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

@sstanculeanu sstanculeanu self-assigned this Apr 18, 2023
@sstanculeanu sstanculeanu changed the title extended coverage on api/gin and api/groups/addressGroup [DO NOT MERGE YET] Coverage for: api/gin + addressGroup Apr 18, 2023
@codecov
Copy link

codecov bot commented Apr 18, 2023

Codecov Report

Patch coverage: 89.18% and project coverage change: +0.27 🎉

Comparison is base (741ac82) 78.47% compared to head (44673d4) 78.75%.

❗ Current head 44673d4 differs from pull request most recent head a354a35. Consider uploading reports for the commit a354a35 to get more accurate results

Additional details and impacted files
@@              Coverage Diff              @@
##           rc/v1.6.0    #5175      +/-   ##
=============================================
+ Coverage      78.47%   78.75%   +0.27%     
=============================================
  Files            680      680              
  Lines          88162    88133      -29     
=============================================
+ Hits           69187    69406     +219     
+ Misses         13740    13502     -238     
+ Partials        5235     5225      -10     
Impacted Files Coverage Δ
api/groups/addressGroup.go 96.30% <86.44%> (+23.66%) ⬆️
api/gin/common.go 67.50% <100.00%> (+36.54%) ⬆️
api/gin/httpServer.go 100.00% <100.00%> (+76.19%) ⬆️
api/gin/webServer.go 77.21% <100.00%> (+77.21%) ⬆️

... and 5 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@bogdan-rosianu bogdan-rosianu self-requested a review April 19, 2023 11:04
var ErrGetESDTTokensWithRole = errors.New("getting esdt tokens with role error")

// ErrNFTTokenIDsRegistered signals an error in getting the nft token ids registered by the given address
var ErrNFTTokenIDsRegistered = errors.New("getting nft token ids registered error")
Copy link
Contributor

Choose a reason for hiding this comment

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

registered token ids

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pushed

bogdan-rosianu
bogdan-rosianu previously approved these changes Apr 19, 2023
@sstanculeanu sstanculeanu changed the base branch from rc/v1.5.0 to rc/v1.6.0 April 24, 2023 17:26
@sstanculeanu sstanculeanu dismissed bogdan-rosianu’s stale review April 24, 2023 17:26

The base branch was changed.

@sstanculeanu sstanculeanu changed the title [DO NOT MERGE YET] Coverage for: api/gin + addressGroup Coverage for: api/gin + addressGroup Apr 24, 2023
@iulianpascalau iulianpascalau self-requested a review April 25, 2023 07:36
@@ -40,7 +40,7 @@ func checkArgs(args ArgsNewWebServer) error {
}

if check.IfNil(args.Facade) {
return errHandler("nil facade")
return errHandler(apiErrors.ErrNilFacadeHandler.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

let's remove the err handler usage and have this as:

if check.IfNil(args.Facade) {
    return fmt.Errorf("%w: %s", apiErrors.ErrCannotCreateGinWebServer, apiErrors.ErrNilFacadeHandler.Error())
}

@@ -424,30 +424,30 @@ func (ag *addressGroup) getESDTsRoles(c *gin.Context) {
func (ag *addressGroup) getESDTTokensWithRole(c *gin.Context) {
addr := c.Param("address")
if addr == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

we can have L427 - L446 extracted in a function. If that function errors, we can treat only once the returned error by calling shared.RespondWithValidationError

@@ -458,19 +458,19 @@ func (ag *addressGroup) getESDTTokensWithRole(c *gin.Context) {
func (ag *addressGroup) getNFTTokenIDsRegisteredByAddress(c *gin.Context) {
addr := c.Param("address")
if addr == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

also here, L460-L475 can be a new function so the error handling is done once

require.Equal(t, api.AccountQueryOptions{}, options)

options, err = parseAccountQueryOptions(testscommon.CreateGinContextWithRawQuery("onStartOfEpoch=test"))
require.Error(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to test the errors? At least at string level.


emptyAddress := ""
addrGroup, err := groups.NewAddressGroup(&facade)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we reuse L293-L304? I think we can have a common function out of this and also reused on L232 and other places.

Copy link
Collaborator

@gabi-vuls gabi-vuls left a comment

Choose a reason for hiding this comment

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

System test passed.
@@ Log scanner @@

api_tests

================================================================================

  • Known Warnings 9
  • New Warnings 1
  • Known Errors 0
  • New Errors 3
  • Panics 0
    ================================================================================
  • block hash does not match 13847
  • wrong nonce in block 5298
  • miniblocks does not match 0
  • num miniblocks does not match 0
  • miniblock hash does not match 0
  • block bodies does not match 0
  • receipts hash missmatch 0
    ================================================================================
  • No jailed nodes on the testnet
    ================================================================================

@sstanculeanu sstanculeanu merged commit 7e264a2 into rc/v1.6.0 Apr 28, 2023
5 checks passed
@sstanculeanu sstanculeanu deleted the api_tests branch April 28, 2023 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants