2020-04-27 11:04:26 -07:00
|
|
|
package ibc_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/suite"
|
2020-08-14 10:58:53 -07:00
|
|
|
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
2020-04-27 11:04:26 -07:00
|
|
|
tmtypes "github.com/tendermint/tendermint/types"
|
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/simapp"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2020-08-31 10:57:08 -07:00
|
|
|
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
2020-05-13 16:23:33 -07:00
|
|
|
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
2020-04-27 11:04:26 -07:00
|
|
|
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
2020-09-07 14:44:23 -07:00
|
|
|
ibctestingmock "github.com/cosmos/cosmos-sdk/x/ibc/testing/mock"
|
2020-04-27 11:04:26 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2020-08-04 02:05:03 -07:00
|
|
|
chainID = "chainID"
|
|
|
|
|
2020-04-27 11:04:26 -07:00
|
|
|
connectionID = "connectionidone"
|
|
|
|
clientID = "clientidone"
|
|
|
|
connectionID2 = "connectionidtwo"
|
|
|
|
clientID2 = "clientidtwo"
|
|
|
|
|
2020-04-29 06:17:20 -07:00
|
|
|
port1 = "firstport"
|
|
|
|
port2 = "secondport"
|
|
|
|
|
|
|
|
channel1 = "firstchannel"
|
|
|
|
channel2 = "secondchannel"
|
|
|
|
|
2020-05-13 16:23:33 -07:00
|
|
|
channelOrder = channeltypes.ORDERED
|
2020-04-29 06:17:20 -07:00
|
|
|
channelVersion = "1.0"
|
|
|
|
|
2020-08-04 02:05:03 -07:00
|
|
|
height = 10
|
|
|
|
|
2020-04-27 11:04:26 -07:00
|
|
|
trustingPeriod time.Duration = time.Hour * 24 * 7 * 2
|
|
|
|
ubdPeriod time.Duration = time.Hour * 24 * 7 * 3
|
|
|
|
maxClockDrift time.Duration = time.Second * 10
|
|
|
|
)
|
|
|
|
|
2020-08-31 10:57:08 -07:00
|
|
|
var clientHeight = clienttypes.NewHeight(0, 10)
|
|
|
|
|
2020-04-27 11:04:26 -07:00
|
|
|
type IBCTestSuite struct {
|
|
|
|
suite.Suite
|
|
|
|
|
|
|
|
ctx sdk.Context
|
|
|
|
app *simapp.SimApp
|
2020-08-25 07:17:38 -07:00
|
|
|
header *ibctmtypes.Header
|
2020-04-27 11:04:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *IBCTestSuite) SetupTest() {
|
|
|
|
isCheckTx := false
|
|
|
|
suite.app = simapp.Setup(isCheckTx)
|
|
|
|
|
2020-09-07 14:44:23 -07:00
|
|
|
privVal := ibctestingmock.NewPV()
|
2020-04-27 11:04:26 -07:00
|
|
|
pubKey, err := privVal.GetPubKey()
|
|
|
|
suite.Require().NoError(err)
|
|
|
|
|
|
|
|
now := time.Now().UTC()
|
|
|
|
|
|
|
|
val := tmtypes.NewValidator(pubKey, 10)
|
|
|
|
valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{val})
|
|
|
|
|
2020-08-06 01:32:19 -07:00
|
|
|
suite.header = ibctmtypes.CreateTestHeader(chainID, height, height-1, now, valSet, valSet, []tmtypes.PrivValidator{privVal})
|
2020-04-27 11:04:26 -07:00
|
|
|
|
2020-08-14 10:58:53 -07:00
|
|
|
suite.ctx = suite.app.BaseApp.NewContext(isCheckTx, tmproto.Header{})
|
2020-04-27 11:04:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestIBCTestSuite(t *testing.T) {
|
|
|
|
suite.Run(t, new(IBCTestSuite))
|
|
|
|
}
|