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

testing: fix TestLatestSigsFromThisNode #2940

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions compactcert/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,17 @@ func TestLatestSigsFromThisNode(t *testing.T) {
// Wait for a compact cert to be formed, so we know the signer thread is caught up.
_ = <-s.txmsg

latestSigs, err := w.LatestSigsFromThisNode()
require.NoError(t, err)
require.Equal(t, len(latestSigs), len(keys))
var latestSigs map[basics.Address]basics.Round
var err error
for x := 0; x < 10; x++ {
latestSigs, err = w.LatestSigsFromThisNode()
require.NoError(t, err)
if len(latestSigs) == len(keys) {
break
}
time.Sleep(256 * time.Millisecond)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather seeing this as an exponential backoff, but it's functionally correct as is.

}
require.Equal(t, len(keys), len(latestSigs))
for _, k := range keys {
require.Equal(t, latestSigs[k.Parent], basics.Round(2*proto.CompactCertRounds))
}
Expand All @@ -398,11 +406,15 @@ func TestLatestSigsFromThisNode(t *testing.T) {
s.mu.Unlock()

// Wait for the builder to discard the signatures.
time.Sleep(time.Second)

latestSigs, err = w.LatestSigsFromThisNode()
require.NoError(t, err)
require.Equal(t, len(latestSigs), 0)
for x := 0; x < 10; x++ {
latestSigs, err = w.LatestSigsFromThisNode()
require.NoError(t, err)
if len(latestSigs) == 0 {
break
}
time.Sleep(256 * time.Millisecond)
}
require.Equal(t, 0, len(latestSigs))
}

func TestWorkerRestart(t *testing.T) {
Expand Down