Skip to content

testing: deterministic rand seed for stable unit test#4447

Merged
algorandskiy merged 2 commits into
algorand:masterfrom
brianolson:deterministic_TestSync
Aug 23, 2022
Merged

testing: deterministic rand seed for stable unit test#4447
algorandskiy merged 2 commits into
algorand:masterfrom
brianolson:deterministic_TestSync

Conversation

@brianolson
Copy link
Copy Markdown
Contributor

Summary

Putting random data into a bloom filter would sometimes fail the test. Set the random seed so that we have deterministic psuedo-random data.

Test Plan

Ran this for a while with no errors. Used to fail within a few dozen tries.
go test -c -race -o rpcs.test && while logwrapq ./rpcs.test -test.count 50 -test.timeout 5m -test.v -test.run TestSync; do date; done

@brianolson brianolson requested review from algorandskiy and cce August 22, 2022 20:47
@brianolson brianolson self-assigned this Aug 22, 2022
Comment thread rpcs/txSyncer_test.go Outdated
testRand = rand.New(testSource)
}

func cryptoRandBytes(d []byte) {
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.

mb call it just randBytes ?

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.

changed to testRandBytes()

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 22, 2022

Codecov Report

Merging #4447 (2fe0fd2) into master (e4d6d42) will increase coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #4447      +/-   ##
==========================================
+ Coverage   55.19%   55.21%   +0.01%     
==========================================
  Files         398      398              
  Lines       50165    50165              
==========================================
+ Hits        27689    27698       +9     
+ Misses      20159    20155       -4     
+ Partials     2317     2312       -5     
Impacted Files Coverage Δ
ledger/tracker.go 73.93% <0.00%> (-0.86%) ⬇️
catchup/service.go 68.64% <0.00%> (-0.75%) ⬇️
ledger/acctupdates.go 69.29% <0.00%> (-0.60%) ⬇️
crypto/merkletrie/node.go 93.48% <0.00%> (+1.86%) ⬆️
crypto/merkletrie/trie.go 68.61% <0.00%> (+2.18%) ⬆️
network/wsPeer.go 68.49% <0.00%> (+3.01%) ⬆️

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

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.

2 participants