test proposer frequencies#3155
Conversation
Codecov Report
@@ Coverage Diff @@
## 2960_normalize_prios #3155 +/- ##
========================================================
+ Coverage 62.78% 62.82% +0.03%
========================================================
Files 212 212
Lines 17468 17468
========================================================
+ Hits 10968 10974 +6
+ Misses 5572 5570 -2
+ Partials 928 924 -4
|
| // i.e. threshold should always be > 0 | ||
| if diff > threshold && threshold > 0 { | ||
|
|
||
| for diff > threshold && threshold > 0 { |
There was a problem hiding this comment.
This is guaranteed to terminate, right?
There was a problem hiding this comment.
I think so as the rescaling / normalisation should guarantee that after a finite (a few) number of iterations we reach diff <= thresold. I'd assume in the case of non-random prios, this should happen after one iter even almost always.
| for j := 0; j < N; j++ { | ||
| votePower := int64(cmn.RandInt() % maxPower) | ||
| privVal := types.NewMockPV() | ||
| pubKey := privVal.GetPubKey() |
There was a problem hiding this comment.
Nit (as this is only a test): but why do we use the MockPV here to generate a pub key while below we use ed25519.GenPrivKey().PubKey()?
| } | ||
| diff := max - min | ||
| return diff | ||
| return int64(math.Abs(float64(diff))) |
|
Thanks so much @ebuchman! |
| {[]int64{5, 100}}, | ||
| {[]int64{50, 50}}, | ||
| {[]int64{50, 100}}, | ||
| {[]int64{1, 1000}}, |
There was a problem hiding this comment.
It would be cool to have a test with voting power close to MaxTotalVotingPower/2 or alike. Unfortunately, it would run forever.
Add test to check that proposers are selected at the frequency we expect.
The following fixes needed to be made: