-
Notifications
You must be signed in to change notification settings - Fork 656
/
Copy pathchain_test.go
47 lines (34 loc) · 1.29 KB
/
chain_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package ibctesting_test
import (
"testing"
"github.com/stretchr/testify/require"
tmtypes "github.com/tendermint/tendermint/types"
ibctesting "github.com/cosmos/ibc-go/v3/testing"
"github.com/cosmos/ibc-go/v3/testing/mock"
)
func TestCreateSortedSignerArray(t *testing.T) {
privVal1 := mock.NewPV()
pubKey1, err := privVal1.GetPubKey()
require.NoError(t, err)
privVal2 := mock.NewPV()
pubKey2, err := privVal2.GetPubKey()
require.NoError(t, err)
validator1 := tmtypes.NewValidator(pubKey1, 1)
validator2 := tmtypes.NewValidator(pubKey2, 2)
expected := []tmtypes.PrivValidator{privVal2, privVal1}
actual := ibctesting.CreateSortedSignerArray(privVal1, privVal2, validator1, validator2)
require.Equal(t, expected, actual)
// swap order
actual = ibctesting.CreateSortedSignerArray(privVal2, privVal1, validator2, validator1)
require.Equal(t, expected, actual)
// smaller address
validator1.Address = []byte{1}
validator2.Address = []byte{2}
validator2.VotingPower = 1
expected = []tmtypes.PrivValidator{privVal1, privVal2}
actual = ibctesting.CreateSortedSignerArray(privVal1, privVal2, validator1, validator2)
require.Equal(t, expected, actual)
// swap order
actual = ibctesting.CreateSortedSignerArray(privVal2, privVal1, validator2, validator1)
require.Equal(t, expected, actual)
}