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

test: re-enable disabled tests #7211

Merged
merged 1 commit into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
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
31 changes: 19 additions & 12 deletions chain/types/electionproof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"math/big"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -129,17 +128,25 @@ func BenchmarkWinCounts(b *testing.B) {
}

func TestWinCounts(t *testing.T) {
t.SkipNow()
totalPower := NewInt(100)
power := NewInt(30)

f, _ := os.Create("output.wins")
fmt.Fprintf(f, "wins\n")
ep := &ElectionProof{VRFProof: nil}
for i := uint64(0); i < 1000000; i++ {
i := i + 1000000
ep.VRFProof = []byte{byte(i), byte(i >> 8), byte(i >> 16), byte(i >> 24), byte(i >> 32)}
j := ep.ComputeWinCount(power, totalPower)
fmt.Fprintf(f, "%d\n", j)
power := NewInt(20)

count := uint64(1000000)
total := uint64(0)
ep := &ElectionProof{VRFProof: make([]byte, 5)}
for i := uint64(0); i < count; i++ {
w := i + count
ep.VRFProof[0] = byte(w)
ep.VRFProof[1] = byte(w >> 8)
ep.VRFProof[2] = byte(w >> 16)
ep.VRFProof[3] = byte(w >> 24)
ep.VRFProof[4] = byte(w >> 32)

total += uint64(ep.ComputeWinCount(power, totalPower))
}
// We have 1/5 of the power, so we expect to win 1 block per epoch on average. Plus or minus
// 1%.
avgWins := float64(total) / float64(count)
assert.GreaterOrEqual(t, avgWins, 1.0-0.01)
assert.LessOrEqual(t, avgWins, 1.0+0.01)
}
3 changes: 0 additions & 3 deletions chain/vectors/vectors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func LoadVector(t *testing.T, f string, out interface{}) {
}

func TestBlockHeaderVectors(t *testing.T) {
t.Skip("we need to regenerate for beacon")
Copy link
Contributor

Choose a reason for hiding this comment

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

Have we done the vector regeneration described here?
Do we even run vector tests any more?

Copy link
Member Author

Choose a reason for hiding this comment

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

The tests pass.

var headers []HeaderVector
LoadVector(t, "block_headers.json", &headers)

Expand Down Expand Up @@ -65,8 +64,6 @@ func TestMessageSigningVectors(t *testing.T) {
}

func TestUnsignedMessageVectors(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Have the vectors been fixed?

Copy link
Member Author

Choose a reason for hiding this comment

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

The tests pass.

Copy link
Member Author

Choose a reason for hiding this comment

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

Although I'm not seeing any updates.

t.Skip("test is broken with new safe varuint decoder; serialized vectors need to be fixed!")

var msvs []UnsignedMessageVector
LoadVector(t, "unsigned_messages.json", &msvs)

Expand Down