github.com/ava-labs/avalanchego@v1.11.11/vms/proposervm/proposer/validators_test.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package proposer
     5  
     6  import (
     7  	"fmt"
     8  	"testing"
     9  
    10  	"github.com/stretchr/testify/require"
    11  
    12  	"github.com/ava-labs/avalanchego/ids"
    13  )
    14  
    15  func TestValidatorDataCompare(t *testing.T) {
    16  	tests := []struct {
    17  		a        validatorData
    18  		b        validatorData
    19  		expected int
    20  	}{
    21  		{
    22  			a:        validatorData{},
    23  			b:        validatorData{},
    24  			expected: 0,
    25  		},
    26  		{
    27  			a: validatorData{
    28  				id: ids.BuildTestNodeID([]byte{1}),
    29  			},
    30  			b:        validatorData{},
    31  			expected: 1,
    32  		},
    33  	}
    34  	for _, test := range tests {
    35  		t.Run(fmt.Sprintf("%s_%s_%d", test.a.id, test.b.id, test.expected), func(t *testing.T) {
    36  			require := require.New(t)
    37  
    38  			require.Equal(test.expected, test.a.Compare(test.b))
    39  			require.Equal(-test.expected, test.b.Compare(test.a))
    40  		})
    41  	}
    42  }