// Test if all tallies have equal value and the value is higher than alpha.
// This is impossible because of the way the tally calculation works, total sum of the tallies will equal to 1.
//
// Nevertheless, because of the way the snowball is implemented, if this happens, the snowball will prefer the first vote.
Test if all tallies have equal value and the value is higher than alpha.
This is impossible because of the way the tally calculation works, total sum of the tallies will equal to 1.

Nevertheless, because of the way the snowball is implemented, if this happens, the snowball will prefer the first vote.
// Test if all tallies have equal value and the value is higher than alpha . // This is impossible because of the way the tally calculation works total sum of the tallies will equal to 1 . // // Nevertheless because of the way the snowball is implemented if this happens the snowball will prefer the first vote .
func TestSnowball_EqualTally_HigherThanAlpha(t *testing.T) {
	snowballBeta := 10
	defaultBeta := conf.GetSnowballBeta()
	conf.Update(conf.WithSnowballBeta(snowballBeta))
	defer func() {
		conf.Update(conf.WithSnowballBeta(defaultBeta))
	}()
	snowballK := 10
	snowball := NewSnowball()
	var votes []Vote
	for i := 0; i < snowballK; i++ {
		votes = append(votes, newTestVote(i, 0.2, getRandomID(t), nil))
	}
	firstVote := votes[0].(*testVote)
	for i := 0; i < snowballBeta+1; i++ {
		assert.False(t, snowball.Decided())
		snowball.Tick(votes)
		assert.Equal(t, *firstVote, *snowball.Preferred().(*testVote))
	}
	assert.True(t, snowball.Decided())
	snowball.Reset()
	last := votes[len(votes)-1].(*testVote)
	snowball.Prefer(last)
	for i := 0; i < snowballBeta+1; i++ {
		assert.False(t, snowball.Decided())
		snowball.Tick(votes)
		assert.Equal(t, *firstVote, *snowball.Preferred().(*testVote))
	}
	assert.True(t, snowball.Decided())
}
func TestSnowball_EqualTally_HigherThanAlpha ( t * testing . T ) { snowballBeta := 10 defaultBeta := conf . GetSnowballBeta ( ) conf . Update ( conf . WithSnowballBeta ( snowballBeta ) ) defer func ( ) { conf . Update ( conf . WithSnowballBeta ( defaultBeta ) ) } ( ) snowballK := 10 snowball := NewSnowball ( ) var votes [ ] Vote for i := 0 ; i < snowballK ; i ++ { votes = append ( votes , newTestVote ( i , 0.2 , getRandomID ( t ) , nil ) ) } firstVote := votes [ 0 ] . ( * testVote ) for i := 0 ; i < snowballBeta + 1 ; i ++ { assert . False ( t , snowball . Decided ( ) ) snowball . Tick ( votes ) assert . Equal ( t , * firstVote , * snowball . Preferred ( ) . ( * testVote ) ) } assert . True ( t , snowball . Decided ( ) ) snowball . Reset ( ) last := votes [ len ( votes ) - 1 ] . ( * testVote ) snowball . Prefer ( last ) for i := 0 ; i < snowballBeta + 1 ; i ++ { assert . False ( t , snowball . Decided ( ) ) snowball . Tick ( votes ) assert . Equal ( t , * firstVote , * snowball . Preferred ( ) . ( * testVote ) ) } assert . True ( t , snowball . Decided ( ) ) }
Test if all tallies have equal value and the value is higher than alpha.
Test if all tallies have equal value and the value is higher than alpha .
// Case 1: the snowball does not have preferred. // The snowball should prefer the first vote. // Case 2: the snowball already has preferred. // The snowball should prefer the first vote.