Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into ibc-go-sdk-50-mark-2
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Jul 6, 2023
2 parents a6f3e97 + 1fda14d commit 0bebbc1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 44 deletions.
2 changes: 1 addition & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/strangelove-ventures/interchaintest/v7 v7.0.0-20230622193330-220ce33823c0
github.com/stretchr/testify v1.8.4
go.uber.org/zap v1.24.0
golang.org/x/mod v0.11.0
golang.org/x/mod v0.12.0
google.golang.org/grpc v1.56.1
gopkg.in/yaml.v2 v2.4.0
)
Expand Down
4 changes: 2 additions & 2 deletions e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1132,8 +1132,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down
13 changes: 9 additions & 4 deletions modules/apps/27-interchain-accounts/host/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,11 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() {
proposal, err := govv1.NewProposal([]sdk.Msg{proposalMsg}, govtypes.DefaultStartingProposalID, suite.chainA.GetContext().BlockTime(), suite.chainA.GetContext().BlockTime(), "test proposal", "title", "Description", sdk.AccAddress(interchainAccountAddr), false)
suite.Require().NoError(err)

suite.chainB.GetSimApp().GovKeeper.SetProposal(suite.chainB.GetContext(), proposal)
suite.chainB.GetSimApp().GovKeeper.ActivateVotingPeriod(suite.chainB.GetContext(), proposal)
err = suite.chainB.GetSimApp().GovKeeper.SetProposal(suite.chainB.GetContext(), proposal)
suite.Require().NoError(err)

err = suite.chainB.GetSimApp().GovKeeper.ActivateVotingPeriod(suite.chainB.GetContext(), proposal)
suite.Require().NoError(err)

msgBytes := []byte(`{
"messages": [
Expand Down Expand Up @@ -639,8 +642,10 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() {
proposal, err := govv1.NewProposal([]sdk.Msg{proposalMsg}, govtypes.DefaultStartingProposalID, suite.chainA.GetContext().BlockTime(), suite.chainA.GetContext().BlockTime(), "test proposal", "title", "description", sdk.AccAddress(interchainAccountAddr), false)
suite.Require().NoError(err)

suite.chainB.GetSimApp().GovKeeper.SetProposal(suite.chainB.GetContext(), proposal)
suite.chainB.GetSimApp().GovKeeper.ActivateVotingPeriod(suite.chainB.GetContext(), proposal)
err = suite.chainB.GetSimApp().GovKeeper.SetProposal(suite.chainB.GetContext(), proposal)
suite.Require().NoError(err)
err = suite.chainB.GetSimApp().GovKeeper.ActivateVotingPeriod(suite.chainB.GetContext(), proposal)
suite.Require().NoError(err)

msgBytes := []byte(`{
"messages": [
Expand Down
15 changes: 9 additions & 6 deletions modules/core/02-client/keeper/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,31 +149,34 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
updateHeader = createPastUpdateFn(fillHeight, trustedHeight)
}, true, false},
{"valid duplicate update", func() {
clientID := path.EndpointA.ClientID

height1 := clienttypes.NewHeight(1, 1)

// store previous consensus state
prevConsState := &ibctm.ConsensusState{
Timestamp: suite.past,
NextValidatorsHash: suite.chainB.Vals.Hash(),
}
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), clientID, height1, prevConsState)
path.EndpointA.SetConsensusState(prevConsState, height1)

height5 := clienttypes.NewHeight(1, 5)
// store next consensus state to check that trustedHeight does not need to be hightest consensus state before header height
// store next consensus state to check that trustedHeight does not need to be highest consensus state before header height
nextConsState := &ibctm.ConsensusState{
Timestamp: suite.past.Add(time.Minute),
NextValidatorsHash: suite.chainB.Vals.Hash(),
}
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), clientID, height5, nextConsState)
path.EndpointA.SetConsensusState(nextConsState, height5)

// update client state latest height
clientState := path.EndpointA.GetClientState()
clientState.(*ibctm.ClientState).LatestHeight = height5
path.EndpointA.SetClientState(clientState)

height3 := clienttypes.NewHeight(1, 3)
// updateHeader will fill in consensus state between prevConsState and suite.consState
// clientState should not be updated
updateHeader = createPastUpdateFn(height3, height1)
// set updateHeader's consensus state in store to create duplicate UpdateClient scenario
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), clientID, updateHeader.GetHeight(), updateHeader.ConsensusState())
path.EndpointA.SetConsensusState(updateHeader.ConsensusState(), updateHeader.GetHeight())
}, true, false},
{"misbehaviour detection: conflicting header", func() {
clientID := path.EndpointA.ClientID
Expand Down
31 changes: 0 additions & 31 deletions modules/core/02-client/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ const (
testClientID2 = "tendermint-1"
testClientID3 = "tendermint-2"

height = 5

trustingPeriod time.Duration = time.Hour * 24 * 7 * 2
ubdPeriod time.Duration = time.Hour * 24 * 7 * 3
maxClockDrift time.Duration = time.Second * 10
Expand All @@ -61,7 +59,6 @@ type KeeperTestSuite struct {
ctx sdk.Context
keeper *keeper.Keeper
consensusState *ibctm.ConsensusState
header *ibctm.Header
valSet *tmtypes.ValidatorSet
valSetHash tmbytes.HexBytes
privVal tmtypes.PrivValidator
Expand All @@ -81,7 +78,6 @@ func (suite *KeeperTestSuite) SetupTest() {
isCheckTx := false
suite.now = time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC)
suite.past = time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)
now2 := suite.now.Add(time.Hour)
app := simapp.Setup(suite.T(), isCheckTx)

suite.cdc = app.AppCodec()
Expand All @@ -91,16 +87,13 @@ func (suite *KeeperTestSuite) SetupTest() {
pubKey, err := suite.privVal.GetPubKey()
suite.Require().NoError(err)

testClientHeightMinus1 := types.NewHeight(0, height-1)

validator := tmtypes.NewValidator(pubKey, 1)
suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})
suite.valSetHash = suite.valSet.Hash()

suite.signers = make(map[string]tmtypes.PrivValidator, 1)
suite.signers[validator.Address.String()] = suite.privVal

suite.header = suite.chainA.CreateTMClientHeader(testChainID, int64(testClientHeight.RevisionHeight), testClientHeightMinus1, now2, suite.valSet, suite.valSet, suite.valSet, suite.signers)
suite.consensusState = ibctm.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot([]byte("hash")), suite.valSetHash)

var validators stakingtypes.Validators
Expand Down Expand Up @@ -308,30 +301,6 @@ func (suite KeeperTestSuite) TestGetConsensusState() { //nolint:govet // this is
}
}

func (suite KeeperTestSuite) TestConsensusStateHelpers() { //nolint:govet // this is a test, we are okay with copying locks
// initial setup
clientState := ibctm.NewClientState(testChainID, ibctm.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath)

suite.keeper.SetClientState(suite.ctx, testClientID, clientState)
suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight, suite.consensusState)

nextState := ibctm.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot([]byte("next")), suite.valSetHash)

testClientHeightPlus5 := types.NewHeight(0, height+5)

header := suite.chainA.CreateTMClientHeader(testClientID, int64(testClientHeightPlus5.RevisionHeight), testClientHeight, suite.header.Header.Time.Add(time.Minute),
suite.valSet, suite.valSet, suite.valSet, suite.signers)

// mock update functionality
clientState.LatestHeight = header.GetHeight().(types.Height)
suite.keeper.SetClientConsensusState(suite.ctx, testClientID, header.GetHeight(), nextState)
suite.keeper.SetClientState(suite.ctx, testClientID, clientState)

latest, ok := suite.keeper.GetLatestClientConsensusState(suite.ctx, testClientID)
suite.Require().True(ok)
suite.Require().Equal(nextState, latest, "Latest client not returned correctly")
}

// 2 clients in total are created on chainA. The first client is updated so it contains an initial consensus state
// and a consensus state at the update height.
func (suite KeeperTestSuite) TestGetAllConsensusStates() { //nolint:govet // this is a test, we are okay with copying locks
Expand Down

0 comments on commit 0bebbc1

Please sign in to comment.