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

test: add unit test for module blockdao #4182

Merged
merged 3 commits into from
Mar 19, 2024
Merged

test: add unit test for module blockdao #4182

merged 3 commits into from
Mar 19, 2024

Conversation

saitofun
Copy link
Contributor

Description

add unit test for module blockchain/blockdao

Fixes #4121

Type of change

Please delete options that are not relevant.

  • Code refactor or improvement

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • make test

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link

codecov bot commented Mar 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.55%. Comparing base (e1f0636) to head (3c3180c).
Report is 206 commits behind head on master.

❗ Current head 3c3180c differs from pull request most recent head 7ee4cd9. Consider uploading reports for the commit 7ee4cd9 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4182      +/-   ##
==========================================
+ Coverage   75.38%   76.55%   +1.17%     
==========================================
  Files         303      340      +37     
  Lines       25923    29165    +3242     
==========================================
+ Hits        19541    22327    +2786     
- Misses       5360     5734     +374     
- Partials     1022     1104      +82     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

// p := gomonkey.NewPatches()
// defer p.Reset()

// p.ApplyMethodReturn(&BlockIndexerChecker{}, "CheckIndexer", nil)
Copy link
Member

Choose a reason for hiding this comment

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

remove

p.ApplyPrivateMethod(&blockDAO{}, "checkIndexers", func(*blockDAO, context.Context) error { return nil })

err := blockdao.Start(context.Background())
r.Nil(err)
Copy link
Member

Choose a reason for hiding this comment

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

let's use r.NoError() for consistency

mockblockdao.EXPECT().GetBlockByHeight(gomock.Any()).Return(&block.Block{}, nil).Times(1)

err := blockdao.checkIndexers(ctx)
r.Nil(err)
Copy link
Member

Choose a reason for hiding this comment

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

let's use r.NoError() for consistency

Copy link

sonarcloud bot commented Mar 18, 2024

Quality Gate Passed Quality Gate passed

Issues
18 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@saitofun saitofun merged commit 5fcccd8 into master Mar 19, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add unit tests for blockchain/blockdao/blockdao.go
3 participants