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

Add genesis tests to increase coverage #653

Merged
merged 1 commit into from
Jan 16, 2024

Conversation

MakisChristou
Copy link
Member

This PR addresses this issue, by including test cases that increase the genesis coverage from an initial

builder -> 80%
customnet -> 0%
devnet -> 0%
genesis -> 60%
mainnet -> 0%
testnet -> 70.6%

to

builder -> 90%
customnet -> 75%
devnet -> 75.7%
genesis -> 73.3%
mainnet -> 76.4%
testnet -> 70.6%

The lack of 80% coverage across all files is due to the fact that some parts of the code are unreachable. For example see the below snippet. To my understanding we are setting some global hardcoded values to the state and we have some error checking code. Since the value is constant and valid, the error case is never executed thus showing up as uncovered code.

// setup builtin contracts
if err := state.SetCode(builtin.Authority.Address, builtin.Authority.RuntimeBytecodes()); err != nil {
        return err
}

Let me know if I am missing something or if this is indeed coverable code.

@libotony Regarding the unused function its actually used to increase coverage in TestNewDevnetCustomTimestamp

@MakisChristou MakisChristou requested a review from a team as a code owner January 12, 2024 07:16
@codecov-commenter
Copy link

codecov-commenter commented Jan 12, 2024

Codecov Report

Attention: 23 lines in your changes are missing coverage. Please review.

Comparison is base (dbe9923) 55.09% compared to head (e3da2a7) 56.56%.

Files Patch % Lines
genesis/devnet.go 46.51% 15 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #653      +/-   ##
==========================================
+ Coverage   55.09%   56.56%   +1.46%     
==========================================
  Files         179      179              
  Lines       20665    20708      +43     
==========================================
+ Hits        11386    11713     +327     
+ Misses       8442     8105     -337     
- Partials      837      890      +53     

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

@libotony
Copy link
Member

@libotony Regarding the unused function its actually used to increase coverage in TestNewDevnetCustomTimestamp

If I remember correctly, the function NewDevnetCustomTimestamp was introduced for txpool tests in #636 and we didn't use it at the end, so I am suggesting remove both NewDevnetCustomTimestamp and TestNewDevnetCustomTimestamp, since TestNewDevnetCustomTimestamp is not used in the code base.

@libotony
Copy link
Member

The lack of 80% coverage across all files is due to the fact that some parts of the code are unreachable. For example see the below snippet. To my understanding we are setting some global hardcoded values to the state and we have some error checking code. Since the value is constant and valid, the error case is never executed thus showing up as uncovered code.

// setup builtin contracts
if err := state.SetCode(builtin.Authority.Address, builtin.Authority.RuntimeBytecodes()); err != nil {
        return err
}

I would consider this acceptable, otherwise you might need to make a customized stateDB implementation that always throws error for setCode @nwbrettski we can discuss this during our standups.

@nwbrettski
Copy link
Contributor

I agree @libotony this is acceptable. It is an improvement. We can always take another look to improve further at a later date if required.

@libotony libotony merged commit 728dde8 into vechain:master Jan 16, 2024
6 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.

4 participants