cosmos-sdk/x/ibc/testing/types.go

63 lines
2.4 KiB
Go
Raw Normal View History

package testing
Refactor 04-channel/keeper tests to ibc testing pkg (#6400) * update testing pkg and first keeper test * fix version bug * add more helper testing funcs * move create header to testing pkg * fix connection state bug * add staking genesis state * update simapp with setting validator helper func * update simapp with valset helper * fix app hash issue * update to query from correct iavl proof height * first keeper test passing * second test passing :tada: * fix build * update tests in all keeper_test * fix lint * begin refactoring querier test * update first querier test and update testing helpers * finish updating rest of querier tests * rename ChannelID in TestChannel to ID * remove usage of chain id for calling helper funcs * update openinit and opentry tests * finish opening channel handshake tests * finish handshake tests * general testing pkg cleanup * finish packetsend refactor * update recvpacket * packet executed refactored * finish packet test :tada: * all tests passing * cleanup and increase code cov * remove todos in favor of opened issue #6509 * bump invalid id to meet validation requirements * bubble up proof height + 1 * Apply suggestions from code review Co-authored-by: Aditya <adityasripal@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * fix uninit conn test * fix compile and address various pr review issues * Update x/ibc/04-channel/keeper/handshake_test.go Co-authored-by: Aditya <adityasripal@gmail.com> * Update x/ibc/04-channel/keeper/handshake_test.go Co-authored-by: Aditya <adityasripal@gmail.com> * address @AdityaSripal comments and increase cov Co-authored-by: Aditya <adityasripal@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
2020-06-26 09:36:04 -07:00
import (
"fmt"
)
// TestConnections is a testing helper struct to keep track of the connectionID, source clientID,
// and counterparty clientID used in creating and interacting with a connection.
type TestConnection struct {
ID string
ClientID string
CounterpartyClientID string
Refactor 04-channel/keeper tests to ibc testing pkg (#6400) * update testing pkg and first keeper test * fix version bug * add more helper testing funcs * move create header to testing pkg * fix connection state bug * add staking genesis state * update simapp with setting validator helper func * update simapp with valset helper * fix app hash issue * update to query from correct iavl proof height * first keeper test passing * second test passing :tada: * fix build * update tests in all keeper_test * fix lint * begin refactoring querier test * update first querier test and update testing helpers * finish updating rest of querier tests * rename ChannelID in TestChannel to ID * remove usage of chain id for calling helper funcs * update openinit and opentry tests * finish opening channel handshake tests * finish handshake tests * general testing pkg cleanup * finish packetsend refactor * update recvpacket * packet executed refactored * finish packet test :tada: * all tests passing * cleanup and increase code cov * remove todos in favor of opened issue #6509 * bump invalid id to meet validation requirements * bubble up proof height + 1 * Apply suggestions from code review Co-authored-by: Aditya <adityasripal@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * fix uninit conn test * fix compile and address various pr review issues * Update x/ibc/04-channel/keeper/handshake_test.go Co-authored-by: Aditya <adityasripal@gmail.com> * Update x/ibc/04-channel/keeper/handshake_test.go Co-authored-by: Aditya <adityasripal@gmail.com> * address @AdityaSripal comments and increase cov Co-authored-by: Aditya <adityasripal@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
2020-06-26 09:36:04 -07:00
Channels []TestChannel
}
// AddTestChannel appends a new TestChannel which contains references to the port and channel ID
// used for channel creation and interaction.
//
// channel ID format: connectionid-<channel-index>
// the port is set to "transfer" to be compatible with the ICS-transfer module, this should
// eventually be updated as described in the issue: https://github.com/cosmos/cosmos-sdk/issues/6509
func (conn *TestConnection) AddTestChannel() TestChannel {
channel := conn.NextTestChannel()
conn.Channels = append(conn.Channels, channel)
return channel
}
// NextTestChannel returns the next test channel to be created on this connection, but does not
// add it to the list of created channels. This function is expected to be used when the caller
// has not created the associated channel in app state, but would still like to refer to the
// non-existent channel usually to test for its non-existence.
func (conn *TestConnection) NextTestChannel() TestChannel {
portID := "transfer"
channelID := fmt.Sprintf("%s-%d", conn.ID, len(conn.Channels))
return TestChannel{
PortID: portID,
ID: channelID,
ClientID: conn.ClientID,
CounterpartyClientID: conn.CounterpartyClientID,
}
}
// FirstOrNextTestChannel returns the first test channel if it exists, otherwise it
// returns the next test channel to be created. This function is expected to be used
// when the caller does not know if the channel has or has not been created in app
// state, but would still like to refer to it to test existence or non-existence.
func (conn *TestConnection) FirstOrNextTestChannel() TestChannel {
if len(conn.Channels) > 0 {
return conn.Channels[0]
}
return conn.NextTestChannel()
}
// TestChannel is a testing helper struct to keep track of the portID and channelID
Refactor 04-channel/keeper tests to ibc testing pkg (#6400) * update testing pkg and first keeper test * fix version bug * add more helper testing funcs * move create header to testing pkg * fix connection state bug * add staking genesis state * update simapp with setting validator helper func * update simapp with valset helper * fix app hash issue * update to query from correct iavl proof height * first keeper test passing * second test passing :tada: * fix build * update tests in all keeper_test * fix lint * begin refactoring querier test * update first querier test and update testing helpers * finish updating rest of querier tests * rename ChannelID in TestChannel to ID * remove usage of chain id for calling helper funcs * update openinit and opentry tests * finish opening channel handshake tests * finish handshake tests * general testing pkg cleanup * finish packetsend refactor * update recvpacket * packet executed refactored * finish packet test :tada: * all tests passing * cleanup and increase code cov * remove todos in favor of opened issue #6509 * bump invalid id to meet validation requirements * bubble up proof height + 1 * Apply suggestions from code review Co-authored-by: Aditya <adityasripal@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * fix uninit conn test * fix compile and address various pr review issues * Update x/ibc/04-channel/keeper/handshake_test.go Co-authored-by: Aditya <adityasripal@gmail.com> * Update x/ibc/04-channel/keeper/handshake_test.go Co-authored-by: Aditya <adityasripal@gmail.com> * address @AdityaSripal comments and increase cov Co-authored-by: Aditya <adityasripal@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
2020-06-26 09:36:04 -07:00
// used in creating and interacting with a channel. The clientID and counterparty
// client ID are also tracked to cut down on querying and argument passing.
type TestChannel struct {
Refactor 04-channel/keeper tests to ibc testing pkg (#6400) * update testing pkg and first keeper test * fix version bug * add more helper testing funcs * move create header to testing pkg * fix connection state bug * add staking genesis state * update simapp with setting validator helper func * update simapp with valset helper * fix app hash issue * update to query from correct iavl proof height * first keeper test passing * second test passing :tada: * fix build * update tests in all keeper_test * fix lint * begin refactoring querier test * update first querier test and update testing helpers * finish updating rest of querier tests * rename ChannelID in TestChannel to ID * remove usage of chain id for calling helper funcs * update openinit and opentry tests * finish opening channel handshake tests * finish handshake tests * general testing pkg cleanup * finish packetsend refactor * update recvpacket * packet executed refactored * finish packet test :tada: * all tests passing * cleanup and increase code cov * remove todos in favor of opened issue #6509 * bump invalid id to meet validation requirements * bubble up proof height + 1 * Apply suggestions from code review Co-authored-by: Aditya <adityasripal@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * fix uninit conn test * fix compile and address various pr review issues * Update x/ibc/04-channel/keeper/handshake_test.go Co-authored-by: Aditya <adityasripal@gmail.com> * Update x/ibc/04-channel/keeper/handshake_test.go Co-authored-by: Aditya <adityasripal@gmail.com> * address @AdityaSripal comments and increase cov Co-authored-by: Aditya <adityasripal@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
2020-06-26 09:36:04 -07:00
PortID string
ID string
ClientID string
CounterpartyClientID string
}