/
types.go
44 lines (40 loc) · 1.61 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package ibctesting
import (
channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
)
// TestConnection is a testing helper struct to keep track of the connectionID, source clientID,
// counterparty clientID, and the next channel version used in creating and interacting with a
// connection.
type TestConnection struct {
ID string
ClientID string
CounterpartyClientID string
NextChannelVersion string
Channels []TestChannel
}
// 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(portID string) TestChannel {
if len(conn.Channels) > 0 {
return conn.Channels[0]
}
return TestChannel{
PortID: portID,
ID: channeltypes.FormatChannelIdentifier(0),
ClientID: conn.ClientID,
CounterpartyClientID: conn.CounterpartyClientID,
Version: conn.NextChannelVersion,
}
}
// TestChannel is a testing helper struct to keep track of the portID and channelID
// 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 {
PortID string
ID string
ClientID string
CounterpartyClientID string
Version string
}