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 func to set approved nodes list #1478

Merged
merged 5 commits into from Oct 19, 2021
Merged

Conversation

kc1116
Copy link
Contributor

@kc1116 kc1116 commented Oct 11, 2021

This PR adds a util func to add a node to the approved nodes list. It allows epoch join tests to better mimic the process that happens when a new node is onboarded.

@codecov-commenter
Copy link

codecov-commenter commented Oct 11, 2021

Codecov Report

Merging #1478 (c196885) into master (41f0e35) will decrease coverage by 0.03%.
The diff coverage is 37.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1478      +/-   ##
==========================================
- Coverage   55.12%   55.08%   -0.04%     
==========================================
  Files         517      520       +3     
  Lines       32330    32413      +83     
==========================================
+ Hits        17823    17856      +33     
- Misses      12116    12160      +44     
- Partials     2391     2397       +6     
Flag Coverage Δ
unittests 55.08% <37.93%> (-0.04%) ⬇️

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

Impacted Files Coverage Δ
cmd/node_builder.go 0.00% <0.00%> (ø)
cmd/scaffold.go 0.89% <0.00%> (-0.01%) ⬇️
network/p2p/connManager.go 80.51% <ø> (ø)
network/p2p/middleware.go 0.00% <ø> (ø)
network/p2p/network.go 0.00% <ø> (ø)
network/p2p/compressed/mockStream.go 33.33% <33.33%> (ø)
network/p2p/libp2pNode.go 62.92% <41.17%> (-2.54%) ⬇️
network/p2p/compressed/compressedStream.go 72.00% <72.00%> (ø)
network/compressor/gzipCompressor.go 80.00% <80.00%> (ø)
network/p2p/test_utils.go 100.00% <100.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

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

Copy link
Member

@jordanschalm jordanschalm left a comment

Choose a reason for hiding this comment

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

1 suggestion to verify the updated approved nodes list in this PR as well.

integration/tests/epochs/epoch_test.go Outdated Show resolved Hide resolved
Comment on lines 363 to 364
identities := s.net.Identities().NodeIDs()
identities = append(identities, nodes...)
Copy link
Member

Choose a reason for hiding this comment

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

This is making an assumption that, between calls to SetApprovedNodesScript, either the caller is arranging to add any new identities to s.net (I guess exactly how this will happen is still TBD), or they are arranging to keep track of all nodes added after startup and including them in the nodes argument for each call.

Depending on how this function is used, that's probably a fine assumption to make - but we should document it.

Another approach would just require the caller to pass in the full node ID list each time:

SetApprovedNodesScript(ctx, env, s.net.Identities().NodeIDs().Append(newNode1, newNode2))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 149 to 150
result := s.SetApprovedNodesScript(ctx, env, info.NodeID)
require.NoError(s.T(), result.Error)
Copy link
Member

Choose a reason for hiding this comment

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

It would be great to include the corresponding ReadApprovedNodesScript util so that we can verify the changes as part of this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@jordanschalm jordanschalm left a comment

Choose a reason for hiding this comment

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

One minor suggestion, but LGTM

Comment on lines +152 to +162
// get new approved nodes list and make sure new node was added correctly
approvedNodes := s.ExecuteReadApprovedNodesScript(ctx, env)

found := false
for _, val := range approvedNodes.(cadence.Array).Values {
if string(val.(cadence.String)) == info.NodeID.String() {
found = true
}
}

require.True(s.T(), found, "node id for new node not found in approved list after setting the approved list")
Copy link
Member

Choose a reason for hiding this comment

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

Would be great to make this a helper eg. suite.AssertInApprovedList(ctx, env, expectedNodeID).

Alternatively, you might be able to use assert.Contains(approvedNodes, info.NodeID)

@kc1116
Copy link
Contributor Author

kc1116 commented Oct 19, 2021

bors merge

@bors
Copy link
Contributor

bors bot commented Oct 19, 2021

@bors bors bot merged commit 4233145 into master Oct 19, 2021
@bors bors bot deleted the khalil/1584-add-node-approved-list branch October 19, 2021 21:11
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.

None yet

4 participants