github.com/koko1123/flow-go-1@v0.29.6/consensus/hotstuff/committee_test.go (about) 1 package hotstuff_test 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 8 "github.com/koko1123/flow-go-1/consensus/hotstuff" 9 ) 10 11 // Test_ComputeWeightThreshold tests computing the HotStuff safety threshold. 12 func Test_ComputeWeightThreshold(t *testing.T) { 13 // testing lowest values 14 for i := 1; i <= 302; i++ { 15 threshold := hotstuff.ComputeWeightThresholdForBuildingQC(uint64(i)) 16 17 boundaryValue := float64(i) * 2.0 / 3.0 18 assert.True(t, boundaryValue < float64(threshold)) 19 assert.False(t, boundaryValue < float64(threshold-1)) 20 } 21 }