cosmos-sdk/x/ibc/testing/chain_test.go
colin axnér bcb3240d06
Use generated client identifiers (#8034)
* add client identifier generation

* update proto and start fixing tests

* fix ibc tests

* fix auth rest test

* update spec

* fix lint

* add parsing tests and fix bugs

* fix regexp

* add godoc

* address @AdityaSripal review suggestions for identifier parsing

* address rest of @AdityaSripal's review comments

* remove unnecessary comment

* typos

* fix lint

* Apply suggestions from code review

Co-authored-by: Aditya <adityasripal@gmail.com>

* add more heigh tests as per @AdityaSripal suggestion

Co-authored-by: Aditya <adityasripal@gmail.com>
2020-11-30 15:52:45 +00:00

48 lines
1.3 KiB
Go

package ibctesting_test
import (
"testing"
"github.com/stretchr/testify/require"
tmtypes "github.com/tendermint/tendermint/types"
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
"github.com/cosmos/cosmos-sdk/x/ibc/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)
}