github.com/phillinzzz/newBsc@v1.1.6/consensus/parlia/snapshot_test.go (about)

     1  package parlia
     2  
     3  import (
     4  	"bytes"
     5  	"sort"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  
    10  	"github.com/phillinzzz/newBsc/common"
    11  )
    12  
    13  func TestValidatorSetSort(t *testing.T) {
    14  	size := 100
    15  	validators := make([]common.Address, size)
    16  	for i := 0; i < size; i++ {
    17  		validators[i] = randomAddress()
    18  	}
    19  	sort.Sort(validatorsAscending(validators))
    20  	for i := 0; i < size-1; i++ {
    21  		assert.True(t, bytes.Compare(validators[i][:], validators[i+1][:]) < 0)
    22  	}
    23  }