cosmos-sdk/x/ibc/02-client/abci_test.go

52 lines
1.4 KiB
Go
Raw Normal View History

package client_test
import (
"testing"
"github.com/stretchr/testify/suite"
client "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
)
type ClientTestSuite struct {
suite.Suite
coordinator *ibctesting.Coordinator
chainA *ibctesting.TestChain
chainB *ibctesting.TestChain
}
func (suite *ClientTestSuite) SetupTest() {
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2)
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0))
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1))
}
func TestClientTestSuite(t *testing.T) {
suite.Run(t, new(ClientTestSuite))
}
func (suite *ClientTestSuite) TestBeginBlocker() {
prevHeight := suite.chainA.GetContext().BlockHeight()
localHostClient := suite.chainA.GetClientState(exported.ClientTypeLocalHost)
suite.Require().Equal(prevHeight, int64(localHostClient.GetLatestHeight()))
for i := 0; i < 10; i++ {
// increment height
suite.coordinator.CommitBlock(suite.chainA, suite.chainB)
suite.Require().NotPanics(func() {
client.BeginBlocker(suite.chainA.GetContext(), suite.chainA.App.IBCKeeper.ClientKeeper)
}, "BeginBlocker shouldn't panic")
localHostClient = suite.chainA.GetClientState(exported.ClientTypeLocalHost)
suite.Require().Equal(prevHeight+1, int64(localHostClient.GetLatestHeight()))
prevHeight = int64(localHostClient.GetLatestHeight())
}
}