x/ibc: Implement Timeout Timestamp (#6022)
* add timeout timestamp to packet and timestamp to consensus state * add timeout timestamp event attribute * update various issues with adding timestamp * fix tests, add default timeout timestamp * add unit test and minor fixes * remove unnecessary code * code review fix * Update x/ibc/03-connection/keeper/keeper.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/ibc/02-client/exported/exported.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/ibc/04-channel/types/packet.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/ibc/07-tendermint/types/consensus_state.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * return time.Time in error message Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
parent
61753c8cf1
commit
f6e9ee7623
|
@ -103,6 +103,9 @@ type ConsensusState interface {
|
||||||
// which is used for key-value pair verification.
|
// which is used for key-value pair verification.
|
||||||
GetRoot() commitmentexported.Root
|
GetRoot() commitmentexported.Root
|
||||||
|
|
||||||
|
// GetTimestamp returns the timestamp (in nanoseconds) of the consensus state
|
||||||
|
GetTimestamp() uint64
|
||||||
|
|
||||||
ValidateBasic() error
|
ValidateBasic() error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,23 @@ func (k Keeper) SetConnection(ctx sdk.Context, connectionID string, connection t
|
||||||
store.Set(ibctypes.KeyConnection(connectionID), bz)
|
store.Set(ibctypes.KeyConnection(connectionID), bz)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetTimestampAtHeight returns the timestamp in nanoseconds of the consensus state at the
|
||||||
|
// given height.
|
||||||
|
func (k Keeper) GetTimestampAtHeight(ctx sdk.Context, connection types.ConnectionEnd, height uint64) (uint64, error) {
|
||||||
|
consensusState, found := k.clientKeeper.GetClientConsensusState(
|
||||||
|
ctx, connection.GetClientID(), height,
|
||||||
|
)
|
||||||
|
|
||||||
|
if !found {
|
||||||
|
return 0, sdkerrors.Wrapf(
|
||||||
|
clienttypes.ErrConsensusStateNotFound,
|
||||||
|
"clientID (%s), height (%d)", connection.GetClientID(), height,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return consensusState.GetTimestamp(), nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetClientConnectionPaths returns all the connection paths stored under a
|
// GetClientConnectionPaths returns all the connection paths stored under a
|
||||||
// particular client
|
// particular client
|
||||||
func (k Keeper) GetClientConnectionPaths(ctx sdk.Context, clientID string) ([]string, bool) {
|
func (k Keeper) GetClientConnectionPaths(ctx sdk.Context, clientID string) ([]string, bool) {
|
||||||
|
|
|
@ -37,6 +37,12 @@ const (
|
||||||
trustingPeriod time.Duration = time.Hour * 24 * 7 * 2
|
trustingPeriod time.Duration = time.Hour * 24 * 7 * 2
|
||||||
ubdPeriod time.Duration = time.Hour * 24 * 7 * 3
|
ubdPeriod time.Duration = time.Hour * 24 * 7 * 3
|
||||||
maxClockDrift time.Duration = time.Second * 10
|
maxClockDrift time.Duration = time.Second * 10
|
||||||
|
|
||||||
|
nextTimestamp = 10 // increment used for the next header's timestamp
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
timestamp = time.Now() // starting timestamp for the client test chain
|
||||||
)
|
)
|
||||||
|
|
||||||
type KeeperTestSuite struct {
|
type KeeperTestSuite struct {
|
||||||
|
@ -124,6 +130,42 @@ func (suite KeeperTestSuite) TestGetAllConnections() {
|
||||||
suite.Require().ElementsMatch(expConnections, connections)
|
suite.Require().ElementsMatch(expConnections, connections)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestGetTimestampAtHeight verifies if the clients on each chain return the correct timestamp
|
||||||
|
// for the other chain.
|
||||||
|
func (suite *KeeperTestSuite) TestGetTimestampAtHeight() {
|
||||||
|
cases := []struct {
|
||||||
|
msg string
|
||||||
|
malleate func()
|
||||||
|
expPass bool
|
||||||
|
}{
|
||||||
|
{"verification success", func() {
|
||||||
|
suite.chainA.CreateClient(suite.chainB)
|
||||||
|
}, true},
|
||||||
|
{"client state not found", func() {}, false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, tc := range cases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||||
|
suite.SetupTest() // reset
|
||||||
|
|
||||||
|
tc.malleate()
|
||||||
|
// create and store a connection to chainB on chainA
|
||||||
|
connection := suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, exported.OPEN)
|
||||||
|
|
||||||
|
actualTimestamp, err := suite.chainA.App.IBCKeeper.ConnectionKeeper.GetTimestampAtHeight(
|
||||||
|
suite.chainA.GetContext(), connection, uint64(suite.chainB.Header.Height),
|
||||||
|
)
|
||||||
|
|
||||||
|
if tc.expPass {
|
||||||
|
suite.Require().NoError(err, "valid test case %d failed: %s", i, tc.msg)
|
||||||
|
suite.Require().EqualValues(uint64(suite.chainB.Header.Time.UnixNano()), actualTimestamp)
|
||||||
|
} else {
|
||||||
|
suite.Require().Error(err, "invalid test case %d passed: %s", i, tc.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TestChain is a testing struct that wraps a simapp with the latest Header, Vals and Signers
|
// TestChain is a testing struct that wraps a simapp with the latest Header, Vals and Signers
|
||||||
// It also contains a field called ClientID. This is the clientID that *other* chains use
|
// It also contains a field called ClientID. This is the clientID that *other* chains use
|
||||||
// to refer to this TestChain. For simplicity's sake it is also the chainID on the TestChain Header
|
// to refer to this TestChain. For simplicity's sake it is also the chainID on the TestChain Header
|
||||||
|
@ -146,9 +188,8 @@ func NewTestChain(clientID string) *TestChain {
|
||||||
validator := tmtypes.NewValidator(pubKey, 1)
|
validator := tmtypes.NewValidator(pubKey, 1)
|
||||||
valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})
|
valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})
|
||||||
signers := []tmtypes.PrivValidator{privVal}
|
signers := []tmtypes.PrivValidator{privVal}
|
||||||
now := time.Now()
|
|
||||||
|
|
||||||
header := ibctmtypes.CreateTestHeader(clientID, 1, now, valSet, signers)
|
header := ibctmtypes.CreateTestHeader(clientID, 1, timestamp, valSet, signers)
|
||||||
|
|
||||||
return &TestChain{
|
return &TestChain{
|
||||||
ClientID: clientID,
|
ClientID: clientID,
|
||||||
|
@ -321,7 +362,7 @@ func (chain *TestChain) createChannel(
|
||||||
|
|
||||||
func nextHeader(chain *TestChain) ibctmtypes.Header {
|
func nextHeader(chain *TestChain) ibctmtypes.Header {
|
||||||
return ibctmtypes.CreateTestHeader(chain.Header.ChainID, chain.Header.Height+1,
|
return ibctmtypes.CreateTestHeader(chain.Header.ChainID, chain.Header.Height+1,
|
||||||
time.Now(), chain.Vals, chain.Signers)
|
chain.Header.Time.Add(nextTimestamp), chain.Vals, chain.Signers)
|
||||||
}
|
}
|
||||||
|
|
||||||
func prefixedClientKey(clientID string, key []byte) []byte {
|
func prefixedClientKey(clientID string, key []byte) []byte {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
// QueryPacket returns a packet from the store
|
// QueryPacket returns a packet from the store
|
||||||
func QueryPacket(
|
func QueryPacket(
|
||||||
ctx context.CLIContext, portID, channelID string,
|
ctx context.CLIContext, portID, channelID string,
|
||||||
sequence, timeout uint64, prove bool,
|
sequence, timeoutHeight, timeoutTimestamp uint64, prove bool,
|
||||||
) (types.PacketResponse, error) {
|
) (types.PacketResponse, error) {
|
||||||
req := abci.RequestQuery{
|
req := abci.RequestQuery{
|
||||||
Path: "store/ibc/key",
|
Path: "store/ibc/key",
|
||||||
|
@ -39,7 +39,8 @@ func QueryPacket(
|
||||||
channelID,
|
channelID,
|
||||||
destPortID,
|
destPortID,
|
||||||
destChannelID,
|
destChannelID,
|
||||||
timeout,
|
timeoutHeight,
|
||||||
|
timeoutTimestamp,
|
||||||
)
|
)
|
||||||
|
|
||||||
// FIXME: res.Height+1 is hack, fix later
|
// FIXME: res.Height+1 is hack, fix later
|
||||||
|
|
|
@ -27,6 +27,7 @@ type CounterpartyI interface {
|
||||||
type PacketI interface {
|
type PacketI interface {
|
||||||
GetSequence() uint64
|
GetSequence() uint64
|
||||||
GetTimeoutHeight() uint64
|
GetTimeoutHeight() uint64
|
||||||
|
GetTimeoutTimestamp() uint64
|
||||||
GetSourcePort() string
|
GetSourcePort() string
|
||||||
GetSourceChannel() string
|
GetSourceChannel() string
|
||||||
GetDestPort() string
|
GetDestPort() string
|
||||||
|
|
|
@ -47,6 +47,11 @@ const (
|
||||||
trustingPeriod time.Duration = time.Hour * 24 * 7 * 2
|
trustingPeriod time.Duration = time.Hour * 24 * 7 * 2
|
||||||
ubdPeriod time.Duration = time.Hour * 24 * 7 * 3
|
ubdPeriod time.Duration = time.Hour * 24 * 7 * 3
|
||||||
maxClockDrift time.Duration = time.Second * 10
|
maxClockDrift time.Duration = time.Second * 10
|
||||||
|
|
||||||
|
timeoutHeight = 100
|
||||||
|
timeoutTimestamp = 100
|
||||||
|
disabledTimeoutTimestamp = 0
|
||||||
|
disabledTimeoutHeight = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
type KeeperTestSuite struct {
|
type KeeperTestSuite struct {
|
||||||
|
@ -194,6 +199,12 @@ func commitNBlocks(chain *TestChain, n int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// commit current block and start the next block with the provided time
|
||||||
|
func commitBlockWithNewTimestamp(chain *TestChain, timestamp int64) {
|
||||||
|
chain.App.Commit()
|
||||||
|
chain.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: chain.App.LastBlockHeight() + 1, Time: time.Unix(timestamp, 0)}})
|
||||||
|
}
|
||||||
|
|
||||||
// nolint: unused
|
// nolint: unused
|
||||||
func queryProof(chain *TestChain, key []byte) (commitmenttypes.MerkleProof, uint64) {
|
func queryProof(chain *TestChain, key []byte) (commitmenttypes.MerkleProof, uint64) {
|
||||||
res := chain.App.Query(abci.RequestQuery{
|
res := chain.App.Query(abci.RequestQuery{
|
||||||
|
|
|
@ -3,6 +3,7 @@ package keeper
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
|
@ -77,8 +78,24 @@ func (k Keeper) SendPacket(
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if packet timeouted on the receiving chain
|
// check if packet timeouted on the receiving chain
|
||||||
if clientState.GetLatestHeight() >= packet.GetTimeoutHeight() {
|
latestHeight := clientState.GetLatestHeight()
|
||||||
return sdkerrors.Wrap(types.ErrPacketTimeout, "timeout already passed ond the receiving chain")
|
if packet.GetTimeoutHeight() != 0 && latestHeight >= packet.GetTimeoutHeight() {
|
||||||
|
return sdkerrors.Wrapf(
|
||||||
|
types.ErrPacketTimeout,
|
||||||
|
"receiving chain block height >= packet timeout height (%d >= %d)", latestHeight, packet.GetTimeoutHeight(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
latestTimestamp, err := k.connectionKeeper.GetTimestampAtHeight(ctx, connectionEnd, latestHeight)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if packet.GetTimeoutTimestamp() != 0 && latestTimestamp >= packet.GetTimeoutTimestamp() {
|
||||||
|
return sdkerrors.Wrapf(
|
||||||
|
types.ErrPacketTimeout,
|
||||||
|
"receiving chain block timestamp >= packet timeout timestamp (%s >= %s)", time.Unix(0, int64(latestTimestamp)), time.Unix(0, int64(packet.GetTimeoutTimestamp())),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
nextSequenceSend, found := k.GetNextSequenceSend(ctx, packet.GetSourcePort(), packet.GetSourceChannel())
|
nextSequenceSend, found := k.GetNextSequenceSend(ctx, packet.GetSourcePort(), packet.GetSourceChannel())
|
||||||
|
@ -103,7 +120,8 @@ func (k Keeper) SendPacket(
|
||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
types.EventTypeSendPacket,
|
types.EventTypeSendPacket,
|
||||||
sdk.NewAttribute(types.AttributeKeyData, string(packet.GetData())),
|
sdk.NewAttribute(types.AttributeKeyData, string(packet.GetData())),
|
||||||
sdk.NewAttribute(types.AttributeKeyTimeout, fmt.Sprintf("%d", packet.GetTimeoutHeight())),
|
sdk.NewAttribute(types.AttributeKeyTimeoutHeight, fmt.Sprintf("%d", packet.GetTimeoutHeight())),
|
||||||
|
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())),
|
||||||
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())),
|
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())),
|
||||||
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()),
|
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()),
|
||||||
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()),
|
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()),
|
||||||
|
@ -167,8 +185,19 @@ func (k Keeper) RecvPacket(
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if packet timeouted by comparing it with the latest height of the chain
|
// check if packet timeouted by comparing it with the latest height of the chain
|
||||||
if uint64(ctx.BlockHeight()) >= packet.GetTimeoutHeight() {
|
if packet.GetTimeoutHeight() != 0 && uint64(ctx.BlockHeight()) >= packet.GetTimeoutHeight() {
|
||||||
return nil, types.ErrPacketTimeout
|
return nil, sdkerrors.Wrapf(
|
||||||
|
types.ErrPacketTimeout,
|
||||||
|
"block height >= packet timeout height (%d >= %d)", uint64(ctx.BlockHeight()), packet.GetTimeoutHeight(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if packet timeouted by comparing it with the latest timestamp of the chain
|
||||||
|
if packet.GetTimeoutTimestamp() != 0 && uint64(ctx.BlockTime().UnixNano()) >= packet.GetTimeoutTimestamp() {
|
||||||
|
return nil, sdkerrors.Wrapf(
|
||||||
|
types.ErrPacketTimeout,
|
||||||
|
"block timestamp >= packet timeout timestamp (%s >= %s)", ctx.BlockTime(), time.Unix(0, int64(packet.GetTimeoutTimestamp())),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := k.connectionKeeper.VerifyPacketCommitment(
|
if err := k.connectionKeeper.VerifyPacketCommitment(
|
||||||
|
@ -243,7 +272,8 @@ func (k Keeper) PacketExecuted(
|
||||||
types.EventTypeRecvPacket,
|
types.EventTypeRecvPacket,
|
||||||
sdk.NewAttribute(types.AttributeKeyData, string(packet.GetData())),
|
sdk.NewAttribute(types.AttributeKeyData, string(packet.GetData())),
|
||||||
sdk.NewAttribute(types.AttributeKeyAck, string(acknowledgement)),
|
sdk.NewAttribute(types.AttributeKeyAck, string(acknowledgement)),
|
||||||
sdk.NewAttribute(types.AttributeKeyTimeout, fmt.Sprintf("%d", packet.GetTimeoutHeight())),
|
sdk.NewAttribute(types.AttributeKeyTimeoutHeight, fmt.Sprintf("%d", packet.GetTimeoutHeight())),
|
||||||
|
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())),
|
||||||
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())),
|
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())),
|
||||||
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()),
|
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()),
|
||||||
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()),
|
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()),
|
||||||
|
@ -330,7 +360,8 @@ func (k Keeper) AcknowledgePacket(
|
||||||
ctx.EventManager().EmitEvents(sdk.Events{
|
ctx.EventManager().EmitEvents(sdk.Events{
|
||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
types.EventTypeAcknowledgePacket,
|
types.EventTypeAcknowledgePacket,
|
||||||
sdk.NewAttribute(types.AttributeKeyTimeout, fmt.Sprintf("%d", packet.GetTimeoutHeight())),
|
sdk.NewAttribute(types.AttributeKeyTimeoutHeight, fmt.Sprintf("%d", packet.GetTimeoutHeight())),
|
||||||
|
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())),
|
||||||
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())),
|
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())),
|
||||||
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()),
|
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()),
|
||||||
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()),
|
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()),
|
||||||
|
@ -445,7 +476,8 @@ func (k Keeper) CleanupPacket(
|
||||||
ctx.EventManager().EmitEvents(sdk.Events{
|
ctx.EventManager().EmitEvents(sdk.Events{
|
||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
types.EventTypeCleanupPacket,
|
types.EventTypeCleanupPacket,
|
||||||
sdk.NewAttribute(types.AttributeKeyTimeout, fmt.Sprintf("%d", packet.GetTimeoutHeight())),
|
sdk.NewAttribute(types.AttributeKeyTimeoutHeight, fmt.Sprintf("%d", packet.GetTimeoutHeight())),
|
||||||
|
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())),
|
||||||
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())),
|
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())),
|
||||||
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()),
|
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()),
|
||||||
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()),
|
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()),
|
||||||
|
|
|
@ -19,66 +19,73 @@ func (suite *KeeperTestSuite) TestSendPacket() {
|
||||||
var channelCap *capability.Capability
|
var channelCap *capability.Capability
|
||||||
testCases := []testCase{
|
testCases := []testCase{
|
||||||
{"success", func() {
|
{"success", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.CreateClient(suite.chainA)
|
suite.chainB.CreateClient(suite.chainA)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainB.GetContext(), testPort1, testChannel1, 1)
|
suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainB.GetContext(), testPort1, testChannel1, 1)
|
||||||
}, true},
|
}, true},
|
||||||
{"packet basic validation failed", func() {
|
{"packet basic validation failed", func() {
|
||||||
packet = types.NewPacket(mockFailPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockFailPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
}, false},
|
}, false},
|
||||||
{"channel not found", func() {
|
{"channel not found", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
}, false},
|
}, false},
|
||||||
{"channel closed", func() {
|
{"channel closed", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet dest port ≠ channel counterparty port", func() {
|
{"packet dest port ≠ channel counterparty port", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, testPort3, counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, testPort3, counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet dest channel ID ≠ channel counterparty channel ID", func() {
|
{"packet dest channel ID ≠ channel counterparty channel ID", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), testChannel3, 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), testChannel3, timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"connection not found", func() {
|
{"connection not found", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"connection is UNINITIALIZED", func() {
|
{"connection is UNINITIALIZED", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.UNINITIALIZED)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.UNINITIALIZED)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"client state not found", func() {
|
{"client state not found", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"timeout height passed", func() {
|
{"timeout height passed", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
commitNBlocks(suite.chainB, 10)
|
commitNBlocks(suite.chainB, 10)
|
||||||
suite.chainB.CreateClient(suite.chainA)
|
suite.chainB.CreateClient(suite.chainA)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
|
{"timeout timestamp passed", func() {
|
||||||
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), disabledTimeoutHeight, timeoutTimestamp)
|
||||||
|
commitBlockWithNewTimestamp(suite.chainB, timeoutTimestamp)
|
||||||
|
suite.chainB.CreateClient(suite.chainA)
|
||||||
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
|
}, false},
|
||||||
{"next sequence send not found", func() {
|
{"next sequence send not found", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.CreateClient(suite.chainA)
|
suite.chainB.CreateClient(suite.chainA)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"next sequence wrong", func() {
|
{"next sequence wrong", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.CreateClient(suite.chainA)
|
suite.chainB.CreateClient(suite.chainA)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainB.GetContext(), testPort1, testChannel1, 5)
|
suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainB.GetContext(), testPort1, testChannel1, 5)
|
||||||
}, false},
|
}, false},
|
||||||
{"channel capability not found", func() {
|
{"channel capability not found", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.CreateClient(suite.chainA)
|
suite.chainB.CreateClient(suite.chainA)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
|
@ -125,40 +132,46 @@ func (suite *KeeperTestSuite) TestRecvPacket() {
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDB)
|
suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDB)
|
||||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainA.GetContext(), testPort2, testChannel2, 1)
|
suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainA.GetContext(), testPort2, testChannel2, 1)
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort2, testChannel2, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort2, testChannel2, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), testPort2, testChannel2, 1, types.CommitPacket(packet))
|
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), testPort2, testChannel2, 1, types.CommitPacket(packet))
|
||||||
|
|
||||||
}, true},
|
}, true},
|
||||||
{"channel not found", func() {}, false},
|
{"channel not found", func() {}, false},
|
||||||
{"channel not open", func() {
|
{"channel not open", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.INIT, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.INIT, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet source port ≠ channel counterparty port", func() {
|
{"packet source port ≠ channel counterparty port", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort2, testChannel2, testPort3, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort2, testChannel2, testPort3, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet source channel ID ≠ channel counterparty channel ID", func() {
|
{"packet source channel ID ≠ channel counterparty channel ID", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"connection not found", func() {
|
{"connection not found", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"connection not OPEN", func() {
|
{"connection not OPEN", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.INIT)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.INIT)
|
||||||
suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"timeout passed", func() {
|
{"timeout height passed", func() {
|
||||||
commitNBlocks(suite.chainB, 10)
|
commitNBlocks(suite.chainB, 10)
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
|
suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
|
}, false},
|
||||||
|
{"timeout timestamp passed", func() {
|
||||||
|
commitBlockWithNewTimestamp(suite.chainB, timeoutTimestamp)
|
||||||
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), disabledTimeoutHeight, timeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"validation failed", func() {
|
{"validation failed", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
|
@ -196,31 +209,31 @@ func (suite *KeeperTestSuite) TestPacketExecuted() {
|
||||||
var channelCap *capability.Capability
|
var channelCap *capability.Capability
|
||||||
testCases := []testCase{
|
testCases := []testCase{
|
||||||
{"success: UNORDERED", func() {
|
{"success: UNORDERED", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.UNORDERED, testConnectionIDA)
|
suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.UNORDERED, testConnectionIDA)
|
||||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), testPort2, testChannel2, 1)
|
suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), testPort2, testChannel2, 1)
|
||||||
}, true},
|
}, true},
|
||||||
{"success: ORDERED", func() {
|
{"success: ORDERED", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), testPort2, testChannel2, 1)
|
suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), testPort2, testChannel2, 1)
|
||||||
}, true},
|
}, true},
|
||||||
{"channel not found", func() {}, false},
|
{"channel not found", func() {}, false},
|
||||||
{"channel not OPEN", func() {
|
{"channel not OPEN", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.CLOSED, exported.ORDERED, testConnectionIDA)
|
suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.CLOSED, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"next sequence receive not found", func() {
|
{"next sequence receive not found", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet sequence ≠ next sequence receive", func() {
|
{"packet sequence ≠ next sequence receive", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), testPort2, testChannel2, 5)
|
suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), testPort2, testChannel2, 5)
|
||||||
}, false},
|
}, false},
|
||||||
{"capability not found", func() {
|
{"capability not found", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.UNORDERED, testConnectionIDA)
|
suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.UNORDERED, testConnectionIDA)
|
||||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), testPort2, testChannel2, 1)
|
suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), testPort2, testChannel2, 1)
|
||||||
channelCap = capability.NewCapability(3)
|
channelCap = capability.NewCapability(3)
|
||||||
|
@ -260,7 +273,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
|
||||||
|
|
||||||
testCases := []testCase{
|
testCases := []testCase{
|
||||||
{"success", func() {
|
{"success", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.CreateClient(suite.chainA)
|
suite.chainB.CreateClient(suite.chainA)
|
||||||
suite.chainA.CreateClient(suite.chainB)
|
suite.chainA.CreateClient(suite.chainB)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
|
@ -272,33 +285,33 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
|
||||||
}, true},
|
}, true},
|
||||||
{"channel not found", func() {}, false},
|
{"channel not found", func() {}, false},
|
||||||
{"channel not open", func() {
|
{"channel not open", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet source port ≠ channel counterparty port", func() {
|
{"packet source port ≠ channel counterparty port", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet source channel ID ≠ channel counterparty channel ID", func() {
|
{"packet source channel ID ≠ channel counterparty channel ID", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"connection not found", func() {
|
{"connection not found", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"connection not OPEN", func() {
|
{"connection not OPEN", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.INIT)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.INIT)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet hasn't been sent", func() {
|
{"packet hasn't been sent", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet ack verification failed", func() {
|
{"packet ack verification failed", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 1, types.CommitPacket(packet))
|
suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 1, types.CommitPacket(packet))
|
||||||
|
@ -342,7 +355,7 @@ func (suite *KeeperTestSuite) TestCleanupPacket() {
|
||||||
testCases := []testCase{
|
testCases := []testCase{
|
||||||
{"success", func() {
|
{"success", func() {
|
||||||
nextSeqRecv = 10
|
nextSeqRecv = 10
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainA.CreateClient(suite.chainB)
|
suite.chainA.CreateClient(suite.chainB)
|
||||||
suite.chainB.CreateClient(suite.chainA)
|
suite.chainB.CreateClient(suite.chainA)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
|
@ -354,47 +367,47 @@ func (suite *KeeperTestSuite) TestCleanupPacket() {
|
||||||
}, true},
|
}, true},
|
||||||
{"channel not found", func() {}, false},
|
{"channel not found", func() {}, false},
|
||||||
{"channel not open", func() {
|
{"channel not open", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet source port ≠ channel counterparty port", func() {
|
{"packet source port ≠ channel counterparty port", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet source channel ID ≠ channel counterparty channel ID", func() {
|
{"packet source channel ID ≠ channel counterparty channel ID", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"connection not found", func() {
|
{"connection not found", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"connection not OPEN", func() {
|
{"connection not OPEN", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.INIT)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.INIT)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet already received ", func() {
|
{"packet already received ", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 10, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 10, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet hasn't been sent", func() {
|
{"packet hasn't been sent", func() {
|
||||||
nextSeqRecv = 10
|
nextSeqRecv = 10
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"next seq receive verification failed", func() {
|
{"next seq receive verification failed", func() {
|
||||||
nextSeqRecv = 10
|
nextSeqRecv = 10
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 1, types.CommitPacket(packet))
|
suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 1, types.CommitPacket(packet))
|
||||||
}, false},
|
}, false},
|
||||||
{"packet ack verification failed", func() {
|
{"packet ack verification failed", func() {
|
||||||
nextSeqRecv = 10
|
nextSeqRecv = 10
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA)
|
||||||
suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 1, types.CommitPacket(packet))
|
suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 1, types.CommitPacket(packet))
|
||||||
|
|
|
@ -66,9 +66,15 @@ func (k Keeper) TimeoutPacket(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that timeout height has passed on the other end
|
// check that timeout height or timeout timestamp has passed on the other end
|
||||||
if proofHeight < packet.GetTimeoutHeight() {
|
proofTimestamp, err := k.connectionKeeper.GetTimestampAtHeight(ctx, connectionEnd, proofHeight)
|
||||||
return nil, types.ErrPacketTimeout
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packet.GetTimeoutHeight() == 0 || proofHeight < packet.GetTimeoutHeight()) &&
|
||||||
|
(packet.GetTimeoutTimestamp() == 0 || proofTimestamp < packet.GetTimeoutTimestamp()) {
|
||||||
|
return nil, sdkerrors.Wrap(types.ErrPacketTimeout, "packet timeout has not been reached for height or timestamp")
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that packet has not been received
|
// check that packet has not been received
|
||||||
|
@ -83,7 +89,6 @@ func (k Keeper) TimeoutPacket(
|
||||||
return nil, sdkerrors.Wrap(types.ErrInvalidPacket, "packet hasn't been sent")
|
return nil, sdkerrors.Wrap(types.ErrInvalidPacket, "packet hasn't been sent")
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
|
||||||
switch channel.Ordering {
|
switch channel.Ordering {
|
||||||
case exported.ORDERED:
|
case exported.ORDERED:
|
||||||
// check that the recv sequence is as claimed
|
// check that the recv sequence is as claimed
|
||||||
|
@ -110,7 +115,8 @@ func (k Keeper) TimeoutPacket(
|
||||||
ctx.EventManager().EmitEvents(sdk.Events{
|
ctx.EventManager().EmitEvents(sdk.Events{
|
||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
types.EventTypeTimeoutPacket,
|
types.EventTypeTimeoutPacket,
|
||||||
sdk.NewAttribute(types.AttributeKeyTimeout, fmt.Sprintf("%d", packet.GetTimeoutHeight())),
|
sdk.NewAttribute(types.AttributeKeyTimeoutHeight, fmt.Sprintf("%d", packet.GetTimeoutHeight())),
|
||||||
|
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())),
|
||||||
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())),
|
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())),
|
||||||
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()),
|
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()),
|
||||||
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()),
|
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()),
|
||||||
|
@ -247,7 +253,8 @@ func (k Keeper) TimeoutOnClose(
|
||||||
ctx.EventManager().EmitEvents(sdk.Events{
|
ctx.EventManager().EmitEvents(sdk.Events{
|
||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
types.EventTypeTimeoutPacket,
|
types.EventTypeTimeoutPacket,
|
||||||
sdk.NewAttribute(types.AttributeKeyTimeout, fmt.Sprintf("%d", packet.GetTimeoutHeight())),
|
sdk.NewAttribute(types.AttributeKeyTimeoutHeight, fmt.Sprintf("%d", packet.GetTimeoutHeight())),
|
||||||
|
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())),
|
||||||
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())),
|
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())),
|
||||||
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()),
|
sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()),
|
||||||
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()),
|
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()),
|
||||||
|
|
|
@ -21,7 +21,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() {
|
||||||
testCases := []testCase{
|
testCases := []testCase{
|
||||||
{"success", func() {
|
{"success", func() {
|
||||||
nextSeqRecv = 1
|
nextSeqRecv = 1
|
||||||
packet = types.NewPacket(newMockTimeoutPacket().GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 1)
|
packet = types.NewPacket(newMockTimeoutPacket().GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 1, disabledTimeoutTimestamp)
|
||||||
suite.chainB.CreateClient(suite.chainA)
|
suite.chainB.CreateClient(suite.chainA)
|
||||||
suite.chainA.CreateClient(suite.chainB)
|
suite.chainA.CreateClient(suite.chainB)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
|
@ -32,48 +32,48 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() {
|
||||||
}, true},
|
}, true},
|
||||||
{"channel not found", func() {}, false},
|
{"channel not found", func() {}, false},
|
||||||
{"channel not open", func() {
|
{"channel not open", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet source port ≠ channel counterparty port", func() {
|
{"packet source port ≠ channel counterparty port", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet source channel ID ≠ channel counterparty channel ID", func() {
|
{"packet source channel ID ≠ channel counterparty channel ID", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"connection not found", func() {
|
{"connection not found", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"timeout", func() {
|
{"timeout", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 10, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 10, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet already received ", func() {
|
{"packet already received ", func() {
|
||||||
nextSeqRecv = 2
|
nextSeqRecv = 2
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet hasn't been sent", func() {
|
{"packet hasn't been sent", func() {
|
||||||
nextSeqRecv = 1
|
nextSeqRecv = 1
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"next seq receive verification failed", func() {
|
{"next seq receive verification failed", func() {
|
||||||
nextSeqRecv = 1
|
nextSeqRecv = 1
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 2, types.CommitPacket(packet))
|
suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 2, types.CommitPacket(packet))
|
||||||
}, false},
|
}, false},
|
||||||
{"packet ack verification failed", func() {
|
{"packet ack verification failed", func() {
|
||||||
nextSeqRecv = 1
|
nextSeqRecv = 1
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA)
|
||||||
suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 2, types.CommitPacket(packet))
|
suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 2, types.CommitPacket(packet))
|
||||||
|
@ -111,12 +111,12 @@ func (suite *KeeperTestSuite) TestTimeoutExecuted() {
|
||||||
var chanCap *capability.Capability
|
var chanCap *capability.Capability
|
||||||
testCases := []testCase{
|
testCases := []testCase{
|
||||||
{"success ORDERED", func() {
|
{"success ORDERED", func() {
|
||||||
packet = types.NewPacket(newMockTimeoutPacket().GetBytes(), 1, testPort1, testChannel1, testPort2, testChannel2, 3)
|
packet = types.NewPacket(newMockTimeoutPacket().GetBytes(), 1, testPort1, testChannel1, testPort2, testChannel2, 3, disabledTimeoutTimestamp)
|
||||||
suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, true},
|
}, true},
|
||||||
{"channel not found", func() {}, false},
|
{"channel not found", func() {}, false},
|
||||||
{"incorrect capability", func() {
|
{"incorrect capability", func() {
|
||||||
packet = types.NewPacket(newMockTimeoutPacket().GetBytes(), 1, testPort1, testChannel1, testPort2, testChannel2, 3)
|
packet = types.NewPacket(newMockTimeoutPacket().GetBytes(), 1, testPort1, testChannel1, testPort2, testChannel2, 3, disabledTimeoutTimestamp)
|
||||||
suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
chanCap = capability.NewCapability(1)
|
chanCap = capability.NewCapability(1)
|
||||||
}, false},
|
}, false},
|
||||||
|
@ -157,7 +157,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() {
|
||||||
|
|
||||||
testCases := []testCase{
|
testCases := []testCase{
|
||||||
{"success", func() {
|
{"success", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.CreateClient(suite.chainA)
|
suite.chainB.CreateClient(suite.chainA)
|
||||||
suite.chainA.CreateClient(suite.chainB)
|
suite.chainA.CreateClient(suite.chainB)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
|
@ -169,24 +169,24 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() {
|
||||||
}, true},
|
}, true},
|
||||||
{"channel not found", func() {}, false},
|
{"channel not found", func() {}, false},
|
||||||
{"packet dest port ≠ channel counterparty port", func() {
|
{"packet dest port ≠ channel counterparty port", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet dest channel ID ≠ channel counterparty channel ID", func() {
|
{"packet dest channel ID ≠ channel counterparty channel ID", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"connection not found", func() {
|
{"connection not found", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet hasn't been sent", func() {
|
{"packet hasn't been sent", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
}, false},
|
}, false},
|
||||||
{"channel verification failed", func() {
|
{"channel verification failed", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.CreateClient(suite.chainA)
|
suite.chainB.CreateClient(suite.chainA)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA)
|
||||||
|
@ -194,7 +194,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() {
|
||||||
suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainB.GetContext(), testPort1, testChannel1, nextSeqRecv)
|
suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainB.GetContext(), testPort1, testChannel1, nextSeqRecv)
|
||||||
}, false},
|
}, false},
|
||||||
{"next seq receive verification failed", func() {
|
{"next seq receive verification failed", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.CreateClient(suite.chainA)
|
suite.chainB.CreateClient(suite.chainA)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA)
|
||||||
|
@ -202,7 +202,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() {
|
||||||
suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainB.GetContext(), testPort1, testChannel1, nextSeqRecv)
|
suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainB.GetContext(), testPort1, testChannel1, nextSeqRecv)
|
||||||
}, false},
|
}, false},
|
||||||
{"packet ack verification failed", func() {
|
{"packet ack verification failed", func() {
|
||||||
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 100)
|
packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp)
|
||||||
suite.chainB.CreateClient(suite.chainA)
|
suite.chainB.CreateClient(suite.chainA)
|
||||||
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN)
|
||||||
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA)
|
suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA)
|
||||||
|
|
|
@ -22,7 +22,8 @@ const (
|
||||||
|
|
||||||
AttributeKeyData = "packet_data"
|
AttributeKeyData = "packet_data"
|
||||||
AttributeKeyAck = "packet_ack"
|
AttributeKeyAck = "packet_ack"
|
||||||
AttributeKeyTimeout = "packet_timeout"
|
AttributeKeyTimeoutHeight = "packet_timeout_height"
|
||||||
|
AttributeKeyTimeoutTimestamp = "packet_timeout_timestamp"
|
||||||
AttributeKeySequence = "packet_sequence"
|
AttributeKeySequence = "packet_sequence"
|
||||||
AttributeKeySrcPort = "packet_src_port"
|
AttributeKeySrcPort = "packet_src_port"
|
||||||
AttributeKeySrcChannel = "packet_src_channel"
|
AttributeKeySrcChannel = "packet_src_channel"
|
||||||
|
|
|
@ -18,6 +18,11 @@ type ClientKeeper interface {
|
||||||
// ConnectionKeeper expected account IBC connection keeper
|
// ConnectionKeeper expected account IBC connection keeper
|
||||||
type ConnectionKeeper interface {
|
type ConnectionKeeper interface {
|
||||||
GetConnection(ctx sdk.Context, connectionID string) (connectiontypes.ConnectionEnd, bool)
|
GetConnection(ctx sdk.Context, connectionID string) (connectiontypes.ConnectionEnd, bool)
|
||||||
|
GetTimestampAtHeight(
|
||||||
|
ctx sdk.Context,
|
||||||
|
connection connectiontypes.ConnectionEnd,
|
||||||
|
height uint64,
|
||||||
|
) (uint64, error)
|
||||||
VerifyChannelState(
|
VerifyChannelState(
|
||||||
ctx sdk.Context,
|
ctx sdk.Context,
|
||||||
connection connectionexported.ConnectionI,
|
connection connectionexported.ConnectionI,
|
||||||
|
|
|
@ -354,13 +354,15 @@ func (suite *MsgTestSuite) TestMsgChannelCloseConfirm() {
|
||||||
|
|
||||||
// define variables used for testing
|
// define variables used for testing
|
||||||
var (
|
var (
|
||||||
timeout = uint64(100)
|
timeoutHeight = uint64(100)
|
||||||
|
timeoutTimestamp = uint64(100)
|
||||||
|
disabledTimeout = uint64(0)
|
||||||
validPacketData = []byte("testdata")
|
validPacketData = []byte("testdata")
|
||||||
unknownPacketData = []byte("unknown")
|
unknownPacketData = []byte("unknown")
|
||||||
invalidAckData = []byte("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890")
|
invalidAckData = []byte("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890")
|
||||||
|
|
||||||
packet = NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, 100)
|
packet = NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp)
|
||||||
unknownPacket = NewPacket(unknownPacketData, 0, portid, chanid, cpportid, cpchanid, 100)
|
unknownPacket = NewPacket(unknownPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp)
|
||||||
invalidAck = invalidAckData
|
invalidAck = invalidAckData
|
||||||
|
|
||||||
emptyProof = commitmenttypes.MerkleProof{Proof: nil}
|
emptyProof = commitmenttypes.MerkleProof{Proof: nil}
|
||||||
|
@ -425,7 +427,7 @@ func TestMsgPacketGetSignBytes(t *testing.T) {
|
||||||
res := msg.GetSignBytes()
|
res := msg.GetSignBytes()
|
||||||
|
|
||||||
expected := fmt.Sprintf(
|
expected := fmt.Sprintf(
|
||||||
`{"type":"ibc/channel/MsgPacket","value":{"packet":{"data":%s,"destination_channel":"testcpchannel","destination_port":"testcpport","sequence":"1","source_channel":"testchannel","source_port":"testportid","timeout_height":"100"},"proof":{"type":"ibc/commitment/MerkleProof","value":{"proof":{"ops":[]}}},"proof_height":"1","signer":"cosmos1w3jhxarpv3j8yvg4ufs4x"}}`,
|
`{"type":"ibc/channel/MsgPacket","value":{"packet":{"data":%s,"destination_channel":"testcpchannel","destination_port":"testcpport","sequence":"1","source_channel":"testchannel","source_port":"testportid","timeout_height":"100","timeout_timestamp":"100"},"proof":{"type":"ibc/commitment/MerkleProof","value":{"proof":{"ops":[]}}},"proof_height":"1","signer":"cosmos1w3jhxarpv3j8yvg4ufs4x"}}`,
|
||||||
string(msg.GetDataSignBytes()),
|
string(msg.GetDataSignBytes()),
|
||||||
)
|
)
|
||||||
require.Equal(t, expected, string(res))
|
require.Equal(t, expected, string(res))
|
||||||
|
|
|
@ -35,6 +35,7 @@ type Packet struct {
|
||||||
DestinationPort string `json:"destination_port" yaml:"destination_port"` // identifies the port on the receiving chain.
|
DestinationPort string `json:"destination_port" yaml:"destination_port"` // identifies the port on the receiving chain.
|
||||||
DestinationChannel string `json:"destination_channel" yaml:"destination_channel"` // identifies the channel end on the receiving chain.
|
DestinationChannel string `json:"destination_channel" yaml:"destination_channel"` // identifies the channel end on the receiving chain.
|
||||||
TimeoutHeight uint64 `json:"timeout_height" yaml:"timeout_height"` // block height after which the packet times out
|
TimeoutHeight uint64 `json:"timeout_height" yaml:"timeout_height"` // block height after which the packet times out
|
||||||
|
TimeoutTimestamp uint64 `json:"timeout_timestamp" yaml:"timeout_timestamp"` // block timestamp (in nanoseconds) after which the packet times out
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPacket creates a new Packet instance
|
// NewPacket creates a new Packet instance
|
||||||
|
@ -42,7 +43,7 @@ func NewPacket(
|
||||||
data []byte,
|
data []byte,
|
||||||
sequence uint64, sourcePort, sourceChannel,
|
sequence uint64, sourcePort, sourceChannel,
|
||||||
destinationPort, destinationChannel string,
|
destinationPort, destinationChannel string,
|
||||||
timeoutHeight uint64,
|
timeoutHeight uint64, timeoutTimestamp uint64,
|
||||||
) Packet {
|
) Packet {
|
||||||
return Packet{
|
return Packet{
|
||||||
Data: data,
|
Data: data,
|
||||||
|
@ -52,6 +53,7 @@ func NewPacket(
|
||||||
DestinationPort: destinationPort,
|
DestinationPort: destinationPort,
|
||||||
DestinationChannel: destinationChannel,
|
DestinationChannel: destinationChannel,
|
||||||
TimeoutHeight: timeoutHeight,
|
TimeoutHeight: timeoutHeight,
|
||||||
|
TimeoutTimestamp: timeoutTimestamp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +78,9 @@ func (p Packet) GetData() []byte { return p.Data }
|
||||||
// GetTimeoutHeight implements PacketI interface
|
// GetTimeoutHeight implements PacketI interface
|
||||||
func (p Packet) GetTimeoutHeight() uint64 { return p.TimeoutHeight }
|
func (p Packet) GetTimeoutHeight() uint64 { return p.TimeoutHeight }
|
||||||
|
|
||||||
|
// GetTimeoutTimestamp implements PacketI interface
|
||||||
|
func (p Packet) GetTimeoutTimestamp() uint64 { return p.TimeoutTimestamp }
|
||||||
|
|
||||||
// ValidateBasic implements PacketI interface
|
// ValidateBasic implements PacketI interface
|
||||||
func (p Packet) ValidateBasic() error {
|
func (p Packet) ValidateBasic() error {
|
||||||
if err := host.DefaultPortIdentifierValidator(p.SourcePort); err != nil {
|
if err := host.DefaultPortIdentifierValidator(p.SourcePort); err != nil {
|
||||||
|
@ -105,8 +110,8 @@ func (p Packet) ValidateBasic() error {
|
||||||
if p.Sequence == 0 {
|
if p.Sequence == 0 {
|
||||||
return sdkerrors.Wrap(ErrInvalidPacket, "packet sequence cannot be 0")
|
return sdkerrors.Wrap(ErrInvalidPacket, "packet sequence cannot be 0")
|
||||||
}
|
}
|
||||||
if p.TimeoutHeight == 0 {
|
if p.TimeoutHeight == 0 && p.TimeoutTimestamp == 0 {
|
||||||
return sdkerrors.Wrap(ErrInvalidPacket, "packet timeout cannot be 0")
|
return sdkerrors.Wrap(ErrInvalidPacket, "packet timeout height and packet timeout timestamp cannot both be 0")
|
||||||
}
|
}
|
||||||
if len(p.Data) == 0 {
|
if len(p.Data) == 0 {
|
||||||
return sdkerrors.Wrap(ErrInvalidPacket, "packet data bytes cannot be empty")
|
return sdkerrors.Wrap(ErrInvalidPacket, "packet data bytes cannot be empty")
|
||||||
|
|
|
@ -12,13 +12,16 @@ func TestPacketValidateBasic(t *testing.T) {
|
||||||
expPass bool
|
expPass bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
{NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeout), true, ""},
|
{NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""},
|
||||||
{NewPacket(validPacketData, 0, portid, chanid, cpportid, cpchanid, timeout), false, "invalid sequence"},
|
{NewPacket(validPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid sequence"},
|
||||||
{NewPacket(validPacketData, 1, invalidPort, chanid, cpportid, cpchanid, timeout), false, "invalid source port"},
|
{NewPacket(validPacketData, 1, invalidPort, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid source port"},
|
||||||
{NewPacket(validPacketData, 1, portid, invalidChannel, cpportid, cpchanid, timeout), false, "invalid source channel"},
|
{NewPacket(validPacketData, 1, portid, invalidChannel, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid source channel"},
|
||||||
{NewPacket(validPacketData, 1, portid, chanid, invalidPort, cpchanid, timeout), false, "invalid destination port"},
|
{NewPacket(validPacketData, 1, portid, chanid, invalidPort, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid destination port"},
|
||||||
{NewPacket(validPacketData, 1, portid, chanid, cpportid, invalidChannel, timeout), false, "invalid destination channel"},
|
{NewPacket(validPacketData, 1, portid, chanid, cpportid, invalidChannel, timeoutHeight, timeoutTimestamp), false, "invalid destination channel"},
|
||||||
{NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeout), true, ""},
|
{NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, disabledTimeout), false, "disabled both timeout height and timestamp"},
|
||||||
|
{NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, timeoutTimestamp), true, "disabled timeout height, valid timeout timestamp"},
|
||||||
|
{NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, disabledTimeout), true, "disabled timeout timestamp, valid timeout height"},
|
||||||
|
{NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range testCases {
|
for i, tc := range testCases {
|
||||||
|
|
|
@ -34,9 +34,9 @@ func (cs ConsensusState) GetHeight() uint64 {
|
||||||
return cs.Height
|
return cs.Height
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTimestamp returns block time at which the consensus state was stored
|
// GetTimestamp returns block time in nanoseconds at which the consensus state was stored
|
||||||
func (cs ConsensusState) GetTimestamp() time.Time {
|
func (cs ConsensusState) GetTimestamp() uint64 {
|
||||||
return cs.Timestamp
|
return uint64(cs.Timestamp.UnixNano())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateBasic defines a basic validation for the tendermint consensus state.
|
// ValidateBasic defines a basic validation for the tendermint consensus state.
|
||||||
|
@ -53,5 +53,8 @@ func (cs ConsensusState) ValidateBasic() error {
|
||||||
if cs.Timestamp.IsZero() {
|
if cs.Timestamp.IsZero() {
|
||||||
return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "timestamp cannot be zero Unix time")
|
return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "timestamp cannot be zero Unix time")
|
||||||
}
|
}
|
||||||
|
if cs.Timestamp.UnixNano() < 0 {
|
||||||
|
return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "timestamp cannot be negative Unix time")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DefaultPacketTimeout = keeper.DefaultPacketTimeout
|
DefaultPacketTimeoutHeight = keeper.DefaultPacketTimeoutHeight
|
||||||
|
DefaultPacketTimeoutTimestamp = keeper.DefaultPacketTimeoutTimestamp
|
||||||
EventTypeTimeout = types.EventTypeTimeout
|
EventTypeTimeout = types.EventTypeTimeout
|
||||||
EventTypePacket = types.EventTypePacket
|
EventTypePacket = types.EventTypePacket
|
||||||
EventTypeChannelClose = types.EventTypeChannelClose
|
EventTypeChannelClose = types.EventTypeChannelClose
|
||||||
|
|
|
@ -17,9 +17,14 @@ import (
|
||||||
ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types"
|
ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultPacketTimeout is the default packet timeout relative to the current block height
|
|
||||||
const (
|
const (
|
||||||
DefaultPacketTimeout = 1000 // NOTE: in blocks
|
// DefaultPacketTimeoutHeight is the default packet timeout height relative
|
||||||
|
// to the current block height. The timeout is disabled when set to 0.
|
||||||
|
DefaultPacketTimeoutHeight = 1000 // NOTE: in blocks
|
||||||
|
|
||||||
|
// DefaultPacketTimeoutTimestamp is the default packet timeout timestamp relative
|
||||||
|
// to the current block timestamp. The timeout is disabled when set to 0.
|
||||||
|
DefaultPacketTimeoutTimestamp = 0 // NOTE: in nanoseconds
|
||||||
)
|
)
|
||||||
|
|
||||||
// Keeper defines the IBC transfer keeper
|
// Keeper defines the IBC transfer keeper
|
||||||
|
|
|
@ -134,7 +134,8 @@ func (k Keeper) createOutgoingPacket(
|
||||||
sourceChannel,
|
sourceChannel,
|
||||||
destinationPort,
|
destinationPort,
|
||||||
destinationChannel,
|
destinationChannel,
|
||||||
destHeight+DefaultPacketTimeout,
|
destHeight+DefaultPacketTimeoutHeight,
|
||||||
|
DefaultPacketTimeoutTimestamp,
|
||||||
)
|
)
|
||||||
|
|
||||||
return k.channelKeeper.SendPacket(ctx, channelCap, packet)
|
return k.channelKeeper.SendPacket(ctx, channelCap, packet)
|
||||||
|
|
|
@ -141,7 +141,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() {
|
||||||
}, true},
|
}, true},
|
||||||
}
|
}
|
||||||
|
|
||||||
packet := channeltypes.NewPacket(data.GetBytes(), 1, testPort1, testChannel1, testPort2, testChannel2, 100)
|
packet := channeltypes.NewPacket(data.GetBytes(), 1, testPort1, testChannel1, testPort2, testChannel2, 100, 0)
|
||||||
|
|
||||||
for i, tc := range testCases {
|
for i, tc := range testCases {
|
||||||
tc := tc
|
tc := tc
|
||||||
|
@ -196,7 +196,7 @@ func (suite *KeeperTestSuite) TestOnAcknowledgementPacket() {
|
||||||
}, false, false},
|
}, false, false},
|
||||||
}
|
}
|
||||||
|
|
||||||
packet := channeltypes.NewPacket(data.GetBytes(), 1, testPort1, testChannel1, testPort2, testChannel2, 100)
|
packet := channeltypes.NewPacket(data.GetBytes(), 1, testPort1, testChannel1, testPort2, testChannel2, 100, 0)
|
||||||
|
|
||||||
for i, tc := range testCases {
|
for i, tc := range testCases {
|
||||||
tc := tc
|
tc := tc
|
||||||
|
@ -266,7 +266,7 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacket() {
|
||||||
}, true, false},
|
}, true, false},
|
||||||
}
|
}
|
||||||
|
|
||||||
packet := channeltypes.NewPacket(data.GetBytes(), 1, testPort1, testChannel1, testPort2, testChannel2, 100)
|
packet := channeltypes.NewPacket(data.GetBytes(), 1, testPort1, testChannel1, testPort2, testChannel2, 100, 0)
|
||||||
|
|
||||||
for i, tc := range testCases {
|
for i, tc := range testCases {
|
||||||
tc := tc
|
tc := tc
|
||||||
|
|
|
@ -87,7 +87,7 @@ func (suite *HandlerTestSuite) TestHandleMsgPacketOrdered() {
|
||||||
suite.chainA.App.IBCKeeper.ChannelKeeper,
|
suite.chainA.App.IBCKeeper.ChannelKeeper,
|
||||||
))
|
))
|
||||||
|
|
||||||
packet := channel.NewPacket(newPacket(12345).GetData(), 1, portid, chanid, cpportid, cpchanid, 100)
|
packet := channel.NewPacket(newPacket(12345).GetData(), 1, portid, chanid, cpportid, cpchanid, 100, 0)
|
||||||
|
|
||||||
ctx := suite.chainA.GetContext()
|
ctx := suite.chainA.GetContext()
|
||||||
cctx, _ := ctx.CacheContext()
|
cctx, _ := ctx.CacheContext()
|
||||||
|
@ -146,7 +146,7 @@ func (suite *HandlerTestSuite) TestHandleMsgPacketUnordered() {
|
||||||
|
|
||||||
var packet channeltypes.Packet
|
var packet channeltypes.Packet
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
packet = channel.NewPacket(newPacket(uint64(i)).GetData(), uint64(i), portid, chanid, cpportid, cpchanid, 100)
|
packet = channel.NewPacket(newPacket(uint64(i)).GetData(), uint64(i), portid, chanid, cpportid, cpchanid, 100, 0)
|
||||||
suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), packet.SourcePort, packet.SourceChannel, uint64(i), channeltypes.CommitPacket(packet))
|
suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), packet.SourcePort, packet.SourceChannel, uint64(i), channeltypes.CommitPacket(packet))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ func (suite *HandlerTestSuite) TestHandleMsgPacketUnordered() {
|
||||||
|
|
||||||
for i := 10; i >= 0; i-- {
|
for i := 10; i >= 0; i-- {
|
||||||
cctx, write := suite.chainA.GetContext().CacheContext()
|
cctx, write := suite.chainA.GetContext().CacheContext()
|
||||||
packet = channel.NewPacket(newPacket(uint64(i)).GetData(), uint64(i), portid, chanid, cpportid, cpchanid, 100)
|
packet = channel.NewPacket(newPacket(uint64(i)).GetData(), uint64(i), portid, chanid, cpportid, cpchanid, 100, 0)
|
||||||
packetCommitmentPath := ibctypes.PacketCommitmentPath(packet.SourcePort, packet.SourceChannel, uint64(i))
|
packetCommitmentPath := ibctypes.PacketCommitmentPath(packet.SourcePort, packet.SourceChannel, uint64(i))
|
||||||
proof, proofHeight := queryProof(suite.chainB, packetCommitmentPath)
|
proof, proofHeight := queryProof(suite.chainB, packetCommitmentPath)
|
||||||
msg := channel.NewMsgPacket(packet, proof, uint64(proofHeight), addr1)
|
msg := channel.NewMsgPacket(packet, proof, uint64(proofHeight), addr1)
|
||||||
|
|
Loading…
Reference in New Issue