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

refactor: Merge node into net and improve coverage #1593

Merged

Conversation

fredcarle
Copy link
Collaborator

Relevant issue(s)

Resolves #906
Resolves #1123
Resolves #1127
Resolves #1063

Description

This PR does a refactor of the net package by merging into it the node package. There is a considerable improvement of the test coverage and github.com/gogo/protobuf is replaced with github.com/planetscale/vtprotobuf.

This PR looks bigger than it is as the generated files for the protobufs makeup most of the line changes.

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

make test

Specify the platform(s) on which this was tested:

  • MacOS

@fredcarle fredcarle added refactor This issue specific to or requires *notable* refactoring of existing codebases and components area/network Related to internal/external network components labels Jun 27, 2023
@fredcarle fredcarle requested a review from a team June 27, 2023 00:44
@fredcarle fredcarle self-assigned this Jun 27, 2023
@codecov
Copy link

codecov bot commented Jun 27, 2023

Codecov Report

Patch coverage: 86.39% and project coverage change: +2.33 🎉

Comparison is base (5e35e00) 73.67% compared to head (b88591f) 76.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1593      +/-   ##
===========================================
+ Coverage    73.67%   76.00%   +2.33%     
===========================================
  Files          193      192       -1     
  Lines        19953    19852     -101     
===========================================
+ Hits         14699    15088     +389     
+ Misses        4160     3728     -432     
+ Partials      1094     1036      -58     
Flag Coverage Δ
all-tests 76.00% <86.39%> (+2.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
config/config.go 74.17% <ø> (+0.87%) ⬆️
net/server.go 74.77% <47.06%> (+11.65%) ⬆️
net/peer.go 74.29% <84.95%> (+25.32%) ⬆️
net/config.go 95.77% <86.96%> (ø)
cli/start.go 60.81% <100.00%> (-0.26%) ⬇️
net/api/client/client.go 13.64% <100.00%> (+2.01%) ⬆️
net/client.go 100.00% <100.00%> (+21.43%) ⬆️
net/dag.go 100.00% <100.00%> (+11.11%) ⬆️
net/dialer.go 100.00% <100.00%> (+43.75%) ⬆️
net/errors.go 100.00% <100.00%> (ø)
... and 2 more

... and 7 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5e35e00...b88591f. Read the comment docs.

Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

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

I think the review could have been easier if the first commit was split into more smaller commits (i.e. autogen proto stuff separated, etc).

Praise for the tests, left some questions

@@ -262,7 +262,7 @@ func TestListenAddrs_WithListenP2PAddrStrings_NoError(t *testing.T) {
)
require.NoError(t, err)

require.Contains(t, n.ListenAddrs()[0].String(), "/ip4/127.0.0.1/tcp/")
require.Contains(t, n.ListenAddrs()[0].String(), "/tcp/")
Copy link
Member

Choose a reason for hiding this comment

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

question: What prompted this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test didn't actually exist before. If you look at the old node_test.go file, there is no such require contains. So that might be between 2 commits. It was passing locally but failing on the CI due to the IP being different every time.

net/dialer.go Show resolved Hide resolved
net/pb/custom.txt Outdated Show resolved Hide resolved
net/peer.go Outdated Show resolved Hide resolved
tests/integration/net/order/utils.go Outdated Show resolved Hide resolved
Copy link
Contributor

@islamaliev islamaliev left a comment

Choose a reason for hiding this comment

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

Looks great. This PR increases the code coverage by a lot. Thanks.

I just have some minor comments and improvement suggestions.

net/client_test.go Show resolved Hide resolved
net/client_test.go Outdated Show resolved Hide resolved
net/client_test.go Outdated Show resolved Hide resolved
net/dag_test.go Show resolved Hide resolved
net/node_test.go Outdated Show resolved Hide resolved
net/pb/net.proto Outdated Show resolved Hide resolved
net/peer_test.go Show resolved Hide resolved
net/peer_test.go Show resolved Hide resolved
@fredcarle fredcarle force-pushed the fredcarle/refactor/node-to-net branch from 26c2b72 to b88591f Compare July 11, 2023 20:28
Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

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

Cheers! Excited to see the coverage bump

@fredcarle fredcarle merged commit 80c22b2 into sourcenetwork:develop Jul 11, 2023
@fredcarle fredcarle deleted the fredcarle/refactor/node-to-net branch July 11, 2023 20:48
@fredcarle fredcarle added this to the DefraDB v0.6 milestone Jul 22, 2023
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
…#1593)

## Relevant issue(s)

Resolves sourcenetwork#906
Resolves sourcenetwork#1123 
Resolves sourcenetwork#1127
Resolves sourcenetwork#1063

## Description

This PR does a refactor of the `net` package by merging into it the
`node` package. There is a considerable improvement of the test coverage
and `github.com/gogo/protobuf` is replaced with
`github.com/planetscale/vtprotobuf`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/network Related to internal/external network components refactor This issue specific to or requires *notable* refactoring of existing codebases and components
Projects
None yet
3 participants