add zero height (#7270)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
ec74416276
commit
d84296a5fc
@ -42,7 +42,7 @@ func (suite *KeeperTestSuite) TestQueryClientState() {
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.Height{}, commitmenttypes.GetSDKSpecs(), false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), false, false)
|
||||
suite.keeper.SetClientState(suite.ctx, testClientID, clientState)
|
||||
|
||||
var err error
|
||||
|
||||
@ -112,7 +112,7 @@ func TestKeeperTestSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestSetClientState() {
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.Height{}, commitmenttypes.GetSDKSpecs(), false, false)
|
||||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), false, false)
|
||||
suite.keeper.SetClientState(suite.ctx, testClientID, clientState)
|
||||
|
||||
retrievedState, found := suite.keeper.GetClientState(suite.ctx, testClientID)
|
||||
@ -210,9 +210,9 @@ func (suite KeeperTestSuite) TestGetAllClients() {
|
||||
testClientID2, testClientID3, testClientID,
|
||||
}
|
||||
expClients := []exported.ClientState{
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.Height{}, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.Height{}, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.Height{}, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), false, false),
|
||||
}
|
||||
|
||||
for i := range expClients {
|
||||
@ -234,9 +234,9 @@ func (suite KeeperTestSuite) TestGetAllGenesisClients() {
|
||||
testClientID2, testClientID3, testClientID,
|
||||
}
|
||||
expClients := []exported.ClientState{
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.Height{}, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.Height{}, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.Height{}, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), false, false),
|
||||
ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), false, false),
|
||||
}
|
||||
|
||||
expGenClients := make([]types.IdentifiedClientState, len(expClients))
|
||||
@ -263,7 +263,7 @@ func (suite KeeperTestSuite) TestGetConsensusState() {
|
||||
height types.Height
|
||||
expPass bool
|
||||
}{
|
||||
{"zero height", types.Height{}, false},
|
||||
{"zero height", types.ZeroHeight(), false},
|
||||
{"height > latest height", types.NewHeight(0, uint64(suite.ctx.BlockHeight())+1), false},
|
||||
{"latest height - 1", types.NewHeight(0, uint64(suite.ctx.BlockHeight())-1), true},
|
||||
{"latest height", types.GetSelfHeight(suite.ctx), true},
|
||||
|
||||
@ -104,7 +104,7 @@ func TestValidateGenesis(t *testing.T) {
|
||||
types.NewIdentifiedClientState(
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
),
|
||||
types.NewIdentifiedClientState(exported.ClientTypeLocalHost, localhosttypes.NewClientState("chaindID", types.Height{})),
|
||||
types.NewIdentifiedClientState(exported.ClientTypeLocalHost, localhosttypes.NewClientState("chaindID", types.ZeroHeight())),
|
||||
},
|
||||
nil,
|
||||
true,
|
||||
@ -127,7 +127,7 @@ func TestValidateGenesis(t *testing.T) {
|
||||
"(CLIENTID2)",
|
||||
[]exported.ConsensusState{
|
||||
ibctmtypes.NewConsensusState(
|
||||
header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), types.Height{}, header.Header.NextValidatorsHash,
|
||||
header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), types.ZeroHeight(), header.Header.NextValidatorsHash,
|
||||
),
|
||||
},
|
||||
),
|
||||
@ -152,7 +152,7 @@ func TestValidateGenesis(t *testing.T) {
|
||||
clientID,
|
||||
[]exported.ConsensusState{
|
||||
ibctmtypes.NewConsensusState(
|
||||
header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), types.Height{}, header.Header.NextValidatorsHash,
|
||||
header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), types.ZeroHeight(), header.Header.NextValidatorsHash,
|
||||
),
|
||||
},
|
||||
),
|
||||
|
||||
@ -12,6 +12,11 @@ import (
|
||||
|
||||
var _ exported.Height = (*Height)(nil)
|
||||
|
||||
// ZeroHeight is a helper function which returns an uninitialized height.
|
||||
func ZeroHeight() Height {
|
||||
return Height{}
|
||||
}
|
||||
|
||||
// NewHeight is a constructor for the IBC height type
|
||||
func NewHeight(epochNumber, epochHeight uint64) Height {
|
||||
return Height{
|
||||
|
||||
@ -7,6 +7,10 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestZeroHeight(t *testing.T) {
|
||||
require.Equal(t, types.Height{}, types.ZeroHeight())
|
||||
}
|
||||
|
||||
func TestCompareHeights(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
@ -50,7 +54,7 @@ func TestDecrement(t *testing.T) {
|
||||
invalidDecrement := types.NewHeight(3, 0)
|
||||
actual, success = invalidDecrement.Decrement()
|
||||
|
||||
require.Equal(t, types.Height{}, actual, "invalid decrement returned non-zero height: %s", actual)
|
||||
require.Equal(t, types.ZeroHeight(), actual, "invalid decrement returned non-zero height: %s", actual)
|
||||
require.False(t, success, "invalid decrement passed")
|
||||
}
|
||||
|
||||
|
||||
@ -198,7 +198,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
|
||||
|
||||
suite.Run(tc.msg, func() {
|
||||
suite.SetupTest() // reset
|
||||
consensusHeight = clienttypes.Height{} // must be explicitly changed in malleate
|
||||
consensusHeight = clienttypes.ZeroHeight() // must be explicitly changed in malleate
|
||||
versions = types.GetCompatibleEncodedVersions() // must be explicitly changed in malleate
|
||||
|
||||
tc.malleate()
|
||||
@ -447,7 +447,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
suite.Run(tc.msg, func() {
|
||||
suite.SetupTest() // reset
|
||||
version = types.GetCompatibleEncodedVersions()[0] // must be explicitly changed in malleate
|
||||
consensusHeight = clienttypes.Height{} // must be explicitly changed in malleate
|
||||
consensusHeight = clienttypes.ZeroHeight() // must be explicitly changed in malleate
|
||||
|
||||
tc.malleate()
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() {
|
||||
|
||||
// invalidClientState fails validateBasic
|
||||
invalidClient := ibctmtypes.NewClientState(
|
||||
chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), false, false,
|
||||
chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), false, false,
|
||||
)
|
||||
|
||||
testMsgs := []*types.MsgConnectionOpenTry{
|
||||
@ -135,8 +135,8 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() {
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []string{ibctesting.ConnectionVersion}, emptyProof, suite.proof, suite.proof, clientHeight, clientHeight, signer),
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []string{ibctesting.ConnectionVersion}, suite.proof, emptyProof, suite.proof, clientHeight, clientHeight, signer),
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []string{ibctesting.ConnectionVersion}, suite.proof, suite.proof, emptyProof, clientHeight, clientHeight, signer),
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []string{ibctesting.ConnectionVersion}, suite.proof, suite.proof, suite.proof, clienttypes.Height{}, clientHeight, signer),
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []string{ibctesting.ConnectionVersion}, suite.proof, suite.proof, suite.proof, clientHeight, clienttypes.Height{}, signer),
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []string{ibctesting.ConnectionVersion}, suite.proof, suite.proof, suite.proof, clienttypes.ZeroHeight(), clientHeight, signer),
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []string{ibctesting.ConnectionVersion}, suite.proof, suite.proof, suite.proof, clientHeight, clienttypes.ZeroHeight(), signer),
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []string{ibctesting.ConnectionVersion}, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, nil),
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []string{ibctesting.ConnectionVersion}, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer),
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []string{"(invalid version)"}, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer),
|
||||
@ -190,7 +190,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() {
|
||||
|
||||
// invalidClientState fails validateBasic
|
||||
invalidClient := ibctmtypes.NewClientState(
|
||||
chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), false, false,
|
||||
chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), false, false,
|
||||
)
|
||||
|
||||
testMsgs := []*types.MsgConnectionOpenAck{
|
||||
@ -201,8 +201,8 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() {
|
||||
types.NewMsgConnectionOpenAck("ibcconntest", clientState, emptyProof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer),
|
||||
types.NewMsgConnectionOpenAck("ibcconntest", clientState, suite.proof, emptyProof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer),
|
||||
types.NewMsgConnectionOpenAck("ibcconntest", clientState, suite.proof, suite.proof, emptyProof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer),
|
||||
types.NewMsgConnectionOpenAck("ibcconntest", clientState, suite.proof, suite.proof, suite.proof, clienttypes.Height{}, clientHeight, ibctesting.ConnectionVersion, signer),
|
||||
types.NewMsgConnectionOpenAck("ibcconntest", clientState, suite.proof, suite.proof, suite.proof, clientHeight, clienttypes.Height{}, ibctesting.ConnectionVersion, signer),
|
||||
types.NewMsgConnectionOpenAck("ibcconntest", clientState, suite.proof, suite.proof, suite.proof, clienttypes.ZeroHeight(), clientHeight, ibctesting.ConnectionVersion, signer),
|
||||
types.NewMsgConnectionOpenAck("ibcconntest", clientState, suite.proof, suite.proof, suite.proof, clientHeight, clienttypes.ZeroHeight(), ibctesting.ConnectionVersion, signer),
|
||||
types.NewMsgConnectionOpenAck("ibcconntest", clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, "", signer),
|
||||
types.NewMsgConnectionOpenAck("ibcconntest", clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, nil),
|
||||
types.NewMsgConnectionOpenAck("ibcconntest", clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer),
|
||||
@ -242,7 +242,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() {
|
||||
testMsgs := []*types.MsgConnectionOpenConfirm{
|
||||
types.NewMsgConnectionOpenConfirm("test/conn1", suite.proof, clientHeight, signer),
|
||||
types.NewMsgConnectionOpenConfirm("ibcconntest", emptyProof, clientHeight, signer),
|
||||
types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, clienttypes.Height{}, signer),
|
||||
types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, clienttypes.ZeroHeight(), signer),
|
||||
types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, clientHeight, nil),
|
||||
types.NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, clientHeight, signer),
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ import (
|
||||
var (
|
||||
validPacketData = []byte("VALID PACKET DATA")
|
||||
disabledTimeoutTimestamp = uint64(0)
|
||||
disabledTimeoutHeight = clienttypes.Height{}
|
||||
disabledTimeoutHeight = clienttypes.ZeroHeight()
|
||||
timeoutHeight = clienttypes.NewHeight(0, 100)
|
||||
|
||||
// for when the testing package cannot be used
|
||||
|
||||
@ -40,7 +40,7 @@ var (
|
||||
height = clienttypes.NewHeight(0, 1)
|
||||
timeoutHeight = clienttypes.NewHeight(0, 100)
|
||||
timeoutTimestamp = uint64(100)
|
||||
disabledTimeout = clienttypes.Height{}
|
||||
disabledTimeout = clienttypes.ZeroHeight()
|
||||
validPacketData = []byte("testdata")
|
||||
unknownPacketData = []byte("unknown")
|
||||
|
||||
@ -166,7 +166,7 @@ func (suite *TypesTestSuite) TestMsgChannelOpenTry() {
|
||||
types.NewMsgChannelOpenTry("testportid", invalidLongChannel, "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, height, addr), // too long channel id
|
||||
types.NewMsgChannelOpenTry("testportid", invalidChannel, "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, height, addr), // channel id contains non-alpha
|
||||
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "", suite.proof, height, addr), // empty counterparty version
|
||||
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, clienttypes.Height{}, addr), // suite.proof height is zero
|
||||
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, clienttypes.ZeroHeight(), addr), // suite.proof height is zero
|
||||
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.Order(4), connHops, "testcpport", "testcpchannel", "1.0", suite.proof, height, addr), // invalid channel order
|
||||
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, invalidConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, height, addr), // connection hops more than 1
|
||||
types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, invalidShortConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, height, addr), // too short connection id
|
||||
@ -216,16 +216,16 @@ func (suite *TypesTestSuite) TestMsgChannelOpenTry() {
|
||||
// TestMsgChannelOpenAck tests ValidateBasic for MsgChannelOpenAck
|
||||
func (suite *TypesTestSuite) TestMsgChannelOpenAck() {
|
||||
testMsgs := []*types.MsgChannelOpenAck{
|
||||
types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, height, addr), // valid msg
|
||||
types.NewMsgChannelOpenAck(invalidShortPort, "testchannel", "1.0", suite.proof, height, addr), // too short port id
|
||||
types.NewMsgChannelOpenAck(invalidLongPort, "testchannel", "1.0", suite.proof, height, addr), // too long port id
|
||||
types.NewMsgChannelOpenAck(invalidPort, "testchannel", "1.0", suite.proof, height, addr), // port id contains non-alpha
|
||||
types.NewMsgChannelOpenAck("testportid", invalidShortChannel, "1.0", suite.proof, height, addr), // too short channel id
|
||||
types.NewMsgChannelOpenAck("testportid", invalidLongChannel, "1.0", suite.proof, height, addr), // too long channel id
|
||||
types.NewMsgChannelOpenAck("testportid", invalidChannel, "1.0", suite.proof, height, addr), // channel id contains non-alpha
|
||||
types.NewMsgChannelOpenAck("testportid", "testchannel", "", suite.proof, height, addr), // empty counterparty version
|
||||
types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", emptyProof, height, addr), // empty proof
|
||||
types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, clienttypes.Height{}, addr), // proof height is zero
|
||||
types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, height, addr), // valid msg
|
||||
types.NewMsgChannelOpenAck(invalidShortPort, "testchannel", "1.0", suite.proof, height, addr), // too short port id
|
||||
types.NewMsgChannelOpenAck(invalidLongPort, "testchannel", "1.0", suite.proof, height, addr), // too long port id
|
||||
types.NewMsgChannelOpenAck(invalidPort, "testchannel", "1.0", suite.proof, height, addr), // port id contains non-alpha
|
||||
types.NewMsgChannelOpenAck("testportid", invalidShortChannel, "1.0", suite.proof, height, addr), // too short channel id
|
||||
types.NewMsgChannelOpenAck("testportid", invalidLongChannel, "1.0", suite.proof, height, addr), // too long channel id
|
||||
types.NewMsgChannelOpenAck("testportid", invalidChannel, "1.0", suite.proof, height, addr), // channel id contains non-alpha
|
||||
types.NewMsgChannelOpenAck("testportid", "testchannel", "", suite.proof, height, addr), // empty counterparty version
|
||||
types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", emptyProof, height, addr), // empty proof
|
||||
types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, clienttypes.ZeroHeight(), addr), // proof height is zero
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
@ -258,15 +258,15 @@ func (suite *TypesTestSuite) TestMsgChannelOpenAck() {
|
||||
// TestMsgChannelOpenConfirm tests ValidateBasic for MsgChannelOpenConfirm
|
||||
func (suite *TypesTestSuite) TestMsgChannelOpenConfirm() {
|
||||
testMsgs := []*types.MsgChannelOpenConfirm{
|
||||
types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, height, addr), // valid msg
|
||||
types.NewMsgChannelOpenConfirm(invalidShortPort, "testchannel", suite.proof, height, addr), // too short port id
|
||||
types.NewMsgChannelOpenConfirm(invalidLongPort, "testchannel", suite.proof, height, addr), // too long port id
|
||||
types.NewMsgChannelOpenConfirm(invalidPort, "testchannel", suite.proof, height, addr), // port id contains non-alpha
|
||||
types.NewMsgChannelOpenConfirm("testportid", invalidShortChannel, suite.proof, height, addr), // too short channel id
|
||||
types.NewMsgChannelOpenConfirm("testportid", invalidLongChannel, suite.proof, height, addr), // too long channel id
|
||||
types.NewMsgChannelOpenConfirm("testportid", invalidChannel, suite.proof, height, addr), // channel id contains non-alpha
|
||||
types.NewMsgChannelOpenConfirm("testportid", "testchannel", emptyProof, height, addr), // empty proof
|
||||
types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, clienttypes.Height{}, addr), // proof height is zero
|
||||
types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, height, addr), // valid msg
|
||||
types.NewMsgChannelOpenConfirm(invalidShortPort, "testchannel", suite.proof, height, addr), // too short port id
|
||||
types.NewMsgChannelOpenConfirm(invalidLongPort, "testchannel", suite.proof, height, addr), // too long port id
|
||||
types.NewMsgChannelOpenConfirm(invalidPort, "testchannel", suite.proof, height, addr), // port id contains non-alpha
|
||||
types.NewMsgChannelOpenConfirm("testportid", invalidShortChannel, suite.proof, height, addr), // too short channel id
|
||||
types.NewMsgChannelOpenConfirm("testportid", invalidLongChannel, suite.proof, height, addr), // too long channel id
|
||||
types.NewMsgChannelOpenConfirm("testportid", invalidChannel, suite.proof, height, addr), // channel id contains non-alpha
|
||||
types.NewMsgChannelOpenConfirm("testportid", "testchannel", emptyProof, height, addr), // empty proof
|
||||
types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, clienttypes.ZeroHeight(), addr), // proof height is zero
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
@ -334,15 +334,15 @@ func (suite *TypesTestSuite) TestMsgChannelCloseInit() {
|
||||
// TestMsgChannelCloseConfirm tests ValidateBasic for MsgChannelCloseConfirm
|
||||
func (suite *TypesTestSuite) TestMsgChannelCloseConfirm() {
|
||||
testMsgs := []*types.MsgChannelCloseConfirm{
|
||||
types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, height, addr), // valid msg
|
||||
types.NewMsgChannelCloseConfirm(invalidShortPort, "testchannel", suite.proof, height, addr), // too short port id
|
||||
types.NewMsgChannelCloseConfirm(invalidLongPort, "testchannel", suite.proof, height, addr), // too long port id
|
||||
types.NewMsgChannelCloseConfirm(invalidPort, "testchannel", suite.proof, height, addr), // port id contains non-alpha
|
||||
types.NewMsgChannelCloseConfirm("testportid", invalidShortChannel, suite.proof, height, addr), // too short channel id
|
||||
types.NewMsgChannelCloseConfirm("testportid", invalidLongChannel, suite.proof, height, addr), // too long channel id
|
||||
types.NewMsgChannelCloseConfirm("testportid", invalidChannel, suite.proof, height, addr), // channel id contains non-alpha
|
||||
types.NewMsgChannelCloseConfirm("testportid", "testchannel", emptyProof, height, addr), // empty proof
|
||||
types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, clienttypes.Height{}, addr), // proof height is zero
|
||||
types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, height, addr), // valid msg
|
||||
types.NewMsgChannelCloseConfirm(invalidShortPort, "testchannel", suite.proof, height, addr), // too short port id
|
||||
types.NewMsgChannelCloseConfirm(invalidLongPort, "testchannel", suite.proof, height, addr), // too long port id
|
||||
types.NewMsgChannelCloseConfirm(invalidPort, "testchannel", suite.proof, height, addr), // port id contains non-alpha
|
||||
types.NewMsgChannelCloseConfirm("testportid", invalidShortChannel, suite.proof, height, addr), // too short channel id
|
||||
types.NewMsgChannelCloseConfirm("testportid", invalidLongChannel, suite.proof, height, addr), // too long channel id
|
||||
types.NewMsgChannelCloseConfirm("testportid", invalidChannel, suite.proof, height, addr), // channel id contains non-alpha
|
||||
types.NewMsgChannelCloseConfirm("testportid", "testchannel", emptyProof, height, addr), // empty proof
|
||||
types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, clienttypes.ZeroHeight(), addr), // proof height is zero
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
@ -381,11 +381,11 @@ func (suite *TypesTestSuite) TestMsgRecvPacketType() {
|
||||
// TestMsgRecvPacketValidation tests ValidateBasic for MsgRecvPacket
|
||||
func (suite *TypesTestSuite) TestMsgRecvPacketValidation() {
|
||||
testMsgs := []*types.MsgRecvPacket{
|
||||
types.NewMsgRecvPacket(packet, suite.proof, height, addr1), // valid msg
|
||||
types.NewMsgRecvPacket(packet, suite.proof, clienttypes.Height{}, addr1), // proof height is zero
|
||||
types.NewMsgRecvPacket(packet, emptyProof, height, addr1), // empty proof
|
||||
types.NewMsgRecvPacket(packet, suite.proof, height, emptyAddr), // missing signer address
|
||||
types.NewMsgRecvPacket(invalidPacket, suite.proof, height, addr1), // unknown packet
|
||||
types.NewMsgRecvPacket(packet, suite.proof, height, addr1), // valid msg
|
||||
types.NewMsgRecvPacket(packet, suite.proof, clienttypes.ZeroHeight(), addr1), // proof height is zero
|
||||
types.NewMsgRecvPacket(packet, emptyProof, height, addr1), // empty proof
|
||||
types.NewMsgRecvPacket(packet, suite.proof, height, emptyAddr), // missing signer address
|
||||
types.NewMsgRecvPacket(invalidPacket, suite.proof, height, addr1), // unknown packet
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
@ -435,7 +435,7 @@ func (suite *TypesTestSuite) TestMsgRecvPacketGetSigners() {
|
||||
func (suite *TypesTestSuite) TestMsgTimeout() {
|
||||
testMsgs := []*types.MsgTimeout{
|
||||
types.NewMsgTimeout(packet, 1, suite.proof, height, addr),
|
||||
types.NewMsgTimeout(packet, 1, suite.proof, clienttypes.Height{}, addr),
|
||||
types.NewMsgTimeout(packet, 1, suite.proof, clienttypes.ZeroHeight(), addr),
|
||||
types.NewMsgTimeout(packet, 1, suite.proof, height, emptyAddr),
|
||||
types.NewMsgTimeout(packet, 1, emptyProof, height, addr),
|
||||
types.NewMsgTimeout(invalidPacket, 1, suite.proof, height, addr),
|
||||
@ -473,7 +473,7 @@ func (suite *TypesTestSuite) TestMsgTimeoutOnClose() {
|
||||
{"success", types.NewMsgTimeoutOnClose(packet, 1, suite.proof, suite.proof, height, addr), true},
|
||||
{"empty proof", types.NewMsgTimeoutOnClose(packet, 1, emptyProof, suite.proof, height, addr), false},
|
||||
{"empty proof close", types.NewMsgTimeoutOnClose(packet, 1, suite.proof, emptyProof, height, addr), false},
|
||||
{"proof height is zero", types.NewMsgTimeoutOnClose(packet, 1, suite.proof, suite.proof, clienttypes.Height{}, addr), false},
|
||||
{"proof height is zero", types.NewMsgTimeoutOnClose(packet, 1, suite.proof, suite.proof, clienttypes.ZeroHeight(), addr), false},
|
||||
{"signer address is empty", types.NewMsgTimeoutOnClose(packet, 1, suite.proof, suite.proof, height, emptyAddr), false},
|
||||
{"invalid packet", types.NewMsgTimeoutOnClose(invalidPacket, 1, suite.proof, suite.proof, height, addr), false},
|
||||
}
|
||||
@ -497,7 +497,7 @@ func (suite *TypesTestSuite) TestMsgTimeoutOnClose() {
|
||||
func (suite *TypesTestSuite) TestMsgAcknowledgement() {
|
||||
testMsgs := []*types.MsgAcknowledgement{
|
||||
types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, height, addr),
|
||||
types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, clienttypes.Height{}, addr),
|
||||
types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, clienttypes.ZeroHeight(), addr),
|
||||
types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, height, emptyAddr),
|
||||
types.NewMsgAcknowledgement(packet, packet.GetData(), emptyProof, height, addr),
|
||||
types.NewMsgAcknowledgement(invalidPacket, packet.GetData(), suite.proof, height, addr),
|
||||
|
||||
@ -34,7 +34,7 @@ func NewClientState(
|
||||
UnbondingPeriod: ubdPeriod,
|
||||
MaxClockDrift: maxClockDrift,
|
||||
LatestHeight: latestHeight,
|
||||
FrozenHeight: clienttypes.Height{},
|
||||
FrozenHeight: clienttypes.ZeroHeight(),
|
||||
ProofSpecs: specs,
|
||||
AllowUpdateAfterExpiry: allowUpdateAfterExpiry,
|
||||
AllowUpdateAfterMisbehaviour: allowUpdateAfterMisbehaviour,
|
||||
|
||||
@ -62,7 +62,7 @@ func (suite *TendermintTestSuite) TestValidate() {
|
||||
},
|
||||
{
|
||||
name: "invalid height",
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), false, false),
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
|
||||
@ -35,7 +35,7 @@ func (h Header) ConsensusState() *ConsensusState {
|
||||
// TODO: return clienttypes.Height once interface changes
|
||||
func (h Header) GetHeight() exported.Height {
|
||||
if h.Header == nil {
|
||||
return clienttypes.Height{}
|
||||
return clienttypes.ZeroHeight()
|
||||
}
|
||||
|
||||
// Enforce clienttypes.Height to use 0 epoch number
|
||||
|
||||
@ -15,7 +15,7 @@ func (suite *TendermintTestSuite) TestGetHeight() {
|
||||
suite.Require().NotEqual(uint64(0), header.GetHeight())
|
||||
|
||||
header.Header = nil
|
||||
suite.Require().Equal(clienttypes.Height{}, header.GetHeight())
|
||||
suite.Require().Equal(clienttypes.ZeroHeight(), header.GetHeight())
|
||||
}
|
||||
|
||||
func (suite *TendermintTestSuite) TestGetTime() {
|
||||
|
||||
@ -48,7 +48,7 @@ func (cs ClientState) CheckProposedHeaderAndUpdateState(
|
||||
}
|
||||
|
||||
// unfreeze the client
|
||||
cs.FrozenHeight = clienttypes.Height{}
|
||||
cs.FrozenHeight = clienttypes.ZeroHeight()
|
||||
|
||||
// if the client is expired we unexpire the client using softer validation, otherwise
|
||||
// full validation on the header is performed.
|
||||
|
||||
@ -224,7 +224,7 @@ func (suite *TendermintTestSuite) TestCheckProposedHeaderAndUpdateState() {
|
||||
|
||||
if tc.expPassUnfreeze {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().Equal(clienttypes.Height{}, cs.GetFrozenHeight())
|
||||
suite.Require().Equal(clienttypes.ZeroHeight(), cs.GetFrozenHeight())
|
||||
suite.Require().NotNil(consState)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
@ -236,7 +236,7 @@ func (suite *TendermintTestSuite) TestCheckProposedHeaderAndUpdateState() {
|
||||
// and validators. Update chainB time so header won't be expired.
|
||||
unexpireClientHeader, err := suite.chainA.ConstructUpdateTMClientHeader(suite.chainB, clientA)
|
||||
suite.Require().NoError(err)
|
||||
unexpireClientHeader.TrustedHeight = clienttypes.Height{}
|
||||
unexpireClientHeader.TrustedHeight = clienttypes.ZeroHeight()
|
||||
unexpireClientHeader.TrustedValidators = nil
|
||||
|
||||
clientStore = suite.chainA.App.IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), clientA)
|
||||
@ -334,7 +334,7 @@ func (suite *TendermintTestSuite) TestCheckProposedHeader() {
|
||||
// and validators.
|
||||
header, err = suite.chainA.ConstructUpdateTMClientHeader(suite.chainB, clientA)
|
||||
suite.Require().NoError(err)
|
||||
header.TrustedHeight = clienttypes.Height{}
|
||||
header.TrustedHeight = clienttypes.ZeroHeight()
|
||||
header.TrustedValidators = nil
|
||||
|
||||
tc.malleate()
|
||||
|
||||
@ -50,7 +50,7 @@ func (cs ClientState) IsFrozen() bool {
|
||||
|
||||
// GetFrozenHeight returns an uninitialized IBC Height.
|
||||
func (cs ClientState) GetFrozenHeight() exported.Height {
|
||||
return clienttypes.Height{}
|
||||
return clienttypes.ZeroHeight()
|
||||
}
|
||||
|
||||
// Validate performs a basic validation of the client state fields.
|
||||
|
||||
@ -35,7 +35,7 @@ func (suite *LocalhostTestSuite) TestValidate() {
|
||||
},
|
||||
{
|
||||
name: "invalid height",
|
||||
clientState: types.NewClientState("chainID", clienttypes.Height{}),
|
||||
clientState: types.NewClientState("chainID", clienttypes.ZeroHeight()),
|
||||
expPass: false,
|
||||
},
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
|
||||
clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), false, false),
|
||||
),
|
||||
clienttypes.NewIdentifiedClientState(
|
||||
exported.ClientTypeLocalHost, localhosttypes.NewClientState("(chaindID)", clienttypes.Height{}),
|
||||
exported.ClientTypeLocalHost, localhosttypes.NewClientState("(chaindID)", clienttypes.ZeroHeight()),
|
||||
),
|
||||
},
|
||||
nil,
|
||||
|
||||
@ -19,7 +19,7 @@ const (
|
||||
|
||||
var (
|
||||
prefix = commitmenttypes.NewMerklePrefix([]byte("ibc"))
|
||||
consensusHeight = clienttypes.Height{}
|
||||
consensusHeight = clienttypes.ZeroHeight()
|
||||
)
|
||||
|
||||
func (suite *SoloMachineTestSuite) TestClientStateValidateBasic() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user