Skip to content

node: Fix disabled node tests#4824

Merged
algorandskiy merged 4 commits intoalgorand:masterfrom
Eric-Warehime:fix-node-tests
Nov 29, 2022
Merged

node: Fix disabled node tests#4824
algorandskiy merged 4 commits intoalgorand:masterfrom
Eric-Warehime:fix-node-tests

Conversation

@Eric-Warehime
Copy link
Copy Markdown
Contributor

Summary

These node tests look like they've been disabled for a very long time--some of them since the initial commit.

I've fixed these tests with some caveats.

  • They take a long time to run so I've allowed us to opt into skipping them with -short
  • I had to add phonebook's ExtendPeerList method to the GossipNode. The tests originally required this which wasn't an issue because the phonebook was located in the mode, but when it got moved out we lost the ability to update the phonebook peers manually.

Test Plan

Unit tests.

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 21, 2022

Codecov Report

Merging #4824 (3449e1c) into master (9791d64) will decrease coverage by 0.45%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #4824      +/-   ##
==========================================
- Coverage   54.64%   54.18%   -0.46%     
==========================================
  Files         416      416              
  Lines       53710    53710              
==========================================
- Hits        29350    29105     -245     
- Misses      21928    22159     +231     
- Partials     2432     2446      +14     
Impacted Files Coverage Δ
network/requestLogger.go 0.00% <0.00%> (-72.73%) ⬇️
util/metrics/reporter.go 39.80% <0.00%> (-16.51%) ⬇️
cmd/algoh/blockWatcher.go 67.16% <0.00%> (-8.96%) ⬇️
rpcs/blockService.go 55.86% <0.00%> (-8.93%) ⬇️
ledger/ledgercore/catchpointlabel.go 91.42% <0.00%> (-8.58%) ⬇️
ledger/internal/appcow.go 67.04% <0.00%> (-7.45%) ⬇️
cmd/tealdbg/cdtSession.go 59.90% <0.00%> (-6.92%) ⬇️
ledger/apply/payment.go 13.04% <0.00%> (-6.53%) ⬇️
catchup/peerSelector.go 93.19% <0.00%> (-5.76%) ⬇️
daemon/algod/api/server/v2/utils.go 8.16% <0.00%> (-4.77%) ⬇️
... and 20 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Copy Markdown
Contributor

@algonautshant algonautshant left a comment

Choose a reason for hiding this comment

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

Great to have these tests come back online.
Some comments about the sad return of ExtedPeerList.

Comment thread network/wsNetwork.go Outdated
Comment thread network/wsNetwork.go Outdated
Copy link
Copy Markdown
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

This looks great! Please fix MakeFull and this good to go.

Comment thread node/node_test.go Outdated
require.NoError(t, err)

node, err := MakeFull(logging.Base().With("source", t.Name()+strconv.Itoa(i)), rootDirectory, cfg, []string{}, g)
node, err := MakeFull(logging.Base().With("source", t.Name()+strconv.Itoa(i)), rootDirectory, cfg, append(neighbors[:i], neighbors[i+1:]...), g)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I do not think this works as intended - it keeps copying into the same slice:

func main() {
	a := []int{1, 2, 3, 4, 5, 6, 7}
	b := append(a[:2], a[3:]...)
	c := append(a[:3], a[4:]...)
	fmt.Printf("%v\n", a)
	fmt.Printf("%v\n", b)
	fmt.Printf("%v\n", c)
}

Output

[1 2 4 6 7 7 7]
[1 2 4 6 7 7]
[1 2 4 6 7 7]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the most recent patch. Thanks for pointing this out. Let me know if you know of a better way to do this than what I've done which is just copy and append.

Copy link
Copy Markdown
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

Please remove redundant copy. LGTM

Comment thread node/node_test.go Outdated

for i := range nodes {
var nodeNeighbors []string
copy(nodeNeighbors, neighbors)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nodeNeighbors has length 0 so nothing copied.

		copied := copy(nodeNeighbors, neighbors)
		fmt.Printf("copied = %d\n", copied)

copied = 0

so simple appending as below is fine

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.

3 participants