Skip to content

Commit

Permalink
clean up remaining usages of s.
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitrisJim committed Jul 28, 2023
1 parent f5e140f commit 693c247
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (suite *MigrationsTestSuite) TestMigrateICS27ChannelCapability() {
suite.CreateMockCapabilities()

// create and claim a new capability with ibc/mock for "channel-1"
// note: s.SetupPath() now claims the chanel capability using icacontroller for "channel-0"
// note: suite.SetupPath() now claims the chanel capability using icacontroller for "channel-0"
capName := host.ChannelCapabilityPath(suite.path.EndpointA.ChannelConfig.PortID, channeltypes.FormatChannelIdentifier(1))

capability, err := suite.chainA.GetSimApp().ScopedIBCKeeper.NewCapability(suite.chainA.GetContext(), capName)
Expand Down
42 changes: 21 additions & 21 deletions modules/capability/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,43 @@ import (
"github.com/cosmos/ibc-go/modules/capability/types"
)

func (s *CapabilityTestSuite) TestGenesis() {
func (suite *CapabilityTestSuite) TestGenesis() {
// InitGenesis must be called in order to set the intial index to 1.
capability.InitGenesis(s.ctx, *s.keeper, *types.DefaultGenesis())
capability.InitGenesis(suite.ctx, *suite.keeper, *types.DefaultGenesis())

sk1 := s.keeper.ScopeToModule(banktypes.ModuleName)
sk2 := s.keeper.ScopeToModule(stakingtypes.ModuleName)
sk1 := suite.keeper.ScopeToModule(banktypes.ModuleName)
sk2 := suite.keeper.ScopeToModule(stakingtypes.ModuleName)

cap1, err := sk1.NewCapability(s.ctx, "transfer")
s.Require().NoError(err)
s.Require().NotNil(cap1)
cap1, err := sk1.NewCapability(suite.ctx, "transfer")
suite.Require().NoError(err)
suite.Require().NotNil(cap1)

err = sk2.ClaimCapability(s.ctx, cap1, "transfer")
s.Require().NoError(err)
err = sk2.ClaimCapability(suite.ctx, cap1, "transfer")
suite.Require().NoError(err)

cap2, err := sk2.NewCapability(s.ctx, "ica")
s.Require().NoError(err)
s.Require().NotNil(cap2)
cap2, err := sk2.NewCapability(suite.ctx, "ica")
suite.Require().NoError(err)
suite.Require().NotNil(cap2)

genState := capability.ExportGenesis(s.ctx, *s.keeper)
genState := capability.ExportGenesis(suite.ctx, *suite.keeper)

newKeeper := keeper.NewKeeper(s.cdc, s.storeKey, s.memStoreKey)
newKeeper := keeper.NewKeeper(suite.cdc, suite.storeKey, suite.memStoreKey)
newSk1 := newKeeper.ScopeToModule(banktypes.ModuleName)
newSk2 := newKeeper.ScopeToModule(stakingtypes.ModuleName)
deliverCtx := s.NewTestContext()
deliverCtx := suite.NewTestContext()

capability.InitGenesis(deliverCtx, *newKeeper, *genState)

// check that all previous capabilities exist in new app after InitGenesis
sk1Cap1, ok := newSk1.GetCapability(deliverCtx, "transfer")
s.Require().True(ok, "could not get first capability after genesis on first ScopedKeeper")
s.Require().Equal(*cap1, *sk1Cap1, "capability values not equal on first ScopedKeeper")
suite.Require().True(ok, "could not get first capability after genesis on first ScopedKeeper")
suite.Require().Equal(*cap1, *sk1Cap1, "capability values not equal on first ScopedKeeper")

sk2Cap1, ok := newSk2.GetCapability(deliverCtx, "transfer")
s.Require().True(ok, "could not get first capability after genesis on first ScopedKeeper")
s.Require().Equal(*cap1, *sk2Cap1, "capability values not equal on first ScopedKeeper")
suite.Require().True(ok, "could not get first capability after genesis on first ScopedKeeper")
suite.Require().Equal(*cap1, *sk2Cap1, "capability values not equal on first ScopedKeeper")

sk2Cap2, ok := newSk2.GetCapability(deliverCtx, "ica")
s.Require().True(ok, "could not get second capability after genesis on second ScopedKeeper")
s.Require().Equal(*cap2, *sk2Cap2, "capability values not equal on second ScopedKeeper")
suite.Require().True(ok, "could not get second capability after genesis on second ScopedKeeper")
suite.Require().Equal(*cap2, *sk2Cap2, "capability values not equal on second ScopedKeeper")
}
8 changes: 4 additions & 4 deletions modules/core/02-client/keeper/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
updateHeader *ibctm.Header
)

// Must create header creation functions since s.header gets recreated on each test case
// Must create header creation functions since suite.header gets recreated on each test case
createFutureUpdateFn := func(trustedHeight clienttypes.Height) *ibctm.Header {
header, err := suite.chainA.ConstructUpdateTMClientHeaderWithTrustedHeight(path.EndpointB.Chain, path.EndpointA.ClientID, trustedHeight)
suite.Require().NoError(err)
Expand Down Expand Up @@ -144,7 +144,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
_, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientConsensusState(suite.chainA.GetContext(), path.EndpointA.ClientID, fillHeight)
suite.Require().False(found)

// updateHeader will fill in consensus state between prevConsState and s.consState
// updateHeader will fill in consensus state between prevConsState and suite.consState
// clientState should not be updated
updateHeader = createPastUpdateFn(fillHeight, trustedHeight)
}, true, false},
Expand Down Expand Up @@ -172,7 +172,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
path.EndpointA.SetClientState(clientState)

height3 := clienttypes.NewHeight(1, 3)
// updateHeader will fill in consensus state between prevConsState and s.consState
// 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
Expand All @@ -198,7 +198,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), clientID, height5, nextConsState)

height3 := clienttypes.NewHeight(1, 3)
// updateHeader will fill in consensus state between prevConsState and s.consState
// updateHeader will fill in consensus state between prevConsState and suite.consState
// clientState should not be updated
updateHeader = createPastUpdateFn(height3, height1)
// set conflicting consensus state in store to create misbehaviour scenario
Expand Down
36 changes: 18 additions & 18 deletions modules/core/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,44 +177,44 @@ func (suite *AnteTestSuite) createUpdateClientMessage() sdk.Msg {
func (suite *AnteTestSuite) TestAnteDecorator() {
testCases := []struct {
name string
malleate func(antesuite *AnteTestSuite) []sdk.Msg
malleate func(suite *AnteTestSuite) []sdk.Msg
expPass bool
}{
{
"success on one new RecvPacket message",
func(anteantesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
// the RecvPacket message has not been submitted to the chain yet, so it will succeed
return []sdk.Msg{suite.createRecvPacketMessage(false)}
},
true,
},
{
"success on one new Acknowledgement message",
func(anteantesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
// the Acknowledgement message has not been submitted to the chain yet, so it will succeed
return []sdk.Msg{suite.createAcknowledgementMessage(false)}
},
true,
},
{
"success on one new Timeout message",
func(anteantesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
// the Timeout message has not been submitted to the chain yet, so it will succeed
return []sdk.Msg{suite.createTimeoutMessage(false)}
},
true,
},
{
"success on one new TimeoutOnClose message",
func(anteantesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
// the TimeoutOnClose message has not been submitted to the chain yet, so it will succeed
return []sdk.Msg{suite.createTimeoutOnCloseMessage(false)}
},
true,
},
{
"success on three new messages of each type",
func(antesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
var msgs []sdk.Msg

// none of the messages of each type has been submitted to the chain yet,
Expand Down Expand Up @@ -243,7 +243,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() {
},
{
"success on three redundant messages of RecvPacket, Acknowledgement and TimeoutOnClose, and one new Timeout message",
func(antesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
var msgs []sdk.Msg

// we pass three messages of RecvPacket, Acknowledgement and TimeoutOnClose that
Expand Down Expand Up @@ -273,7 +273,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() {
},
{
"success on one new message and two redundant messages of each type",
func(antesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
var msgs []sdk.Msg

// For each type there is a new message and two messages that are redundant
Expand Down Expand Up @@ -303,21 +303,21 @@ func (suite *AnteTestSuite) TestAnteDecorator() {
},
{
"success on one new UpdateClient message",
func(antesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
return []sdk.Msg{suite.createUpdateClientMessage()}
},
true,
},
{
"success on three new UpdateClient messages",
func(antesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
return []sdk.Msg{suite.createUpdateClientMessage(), suite.createUpdateClientMessage(), suite.createUpdateClientMessage()}
},
true,
},
{
"success on three new Updateclient messages and one new RecvPacket message",
func(antesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
return []sdk.Msg{
suite.createUpdateClientMessage(),
suite.createUpdateClientMessage(),
Expand All @@ -329,7 +329,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() {
},
{
"success on three redundant RecvPacket messages and one SubmitMisbehaviour message",
func(antesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
msgs := []sdk.Msg{suite.createUpdateClientMessage()}

for i := 1; i <= 3; i++ {
Expand All @@ -344,14 +344,14 @@ func (suite *AnteTestSuite) TestAnteDecorator() {
},
{
"no success on one redundant RecvPacket message",
func(antesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
return []sdk.Msg{suite.createRecvPacketMessage(true)}
},
false,
},
{
"no success on three redundant messages of each type",
func(antesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
var msgs []sdk.Msg

// from A to B
Expand All @@ -376,7 +376,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() {
},
{
"no success on one new UpdateClient message and three redundant RecvPacket messages",
func(antesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
msgs := []sdk.Msg{&clienttypes.MsgUpdateClient{}}

for i := 1; i <= 3; i++ {
Expand All @@ -389,7 +389,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() {
},
{
"no success on three new UpdateClient messages and three redundant messages of each type",
func(antesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
msgs := []sdk.Msg{suite.createUpdateClientMessage(), suite.createUpdateClientMessage(), suite.createUpdateClientMessage()}

// from A to B
Expand All @@ -414,7 +414,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() {
},
{
"no success on one new message and one invalid message",
func(antesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
packet := channeltypes.NewPacket(ibctesting.MockPacketData, 2,
suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID,
suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID,
Expand All @@ -429,7 +429,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() {
},
{
"no success on one new message and one redundant message in the same block",
func(antesuite *AnteTestSuite) []sdk.Msg {
func(suite *AnteTestSuite) []sdk.Msg {
msg := suite.createRecvPacketMessage(false)

// We want to be able to run check tx with the non-redundant message without
Expand Down
8 changes: 4 additions & 4 deletions modules/light-clients/07-tendermint/tendermint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ func getAltSigners(altVal *tmtypes.Validator, altPrivVal tmtypes.PrivValidator)
return map[string]tmtypes.PrivValidator{altVal.Address.String(): altPrivVal}
}

func getBothSigners(s *TendermintTestSuite, altVal *tmtypes.Validator, altPrivVal tmtypes.PrivValidator) (*tmtypes.ValidatorSet, map[string]tmtypes.PrivValidator) {
func getBothSigners(suite *TendermintTestSuite, altVal *tmtypes.Validator, altPrivVal tmtypes.PrivValidator) (*tmtypes.ValidatorSet, map[string]tmtypes.PrivValidator) {
// Create bothValSet with both suite validator and altVal. Would be valid update
bothValSet := tmtypes.NewValidatorSet(append(s.valSet.Validators, altVal))
bothValSet := tmtypes.NewValidatorSet(append(suite.valSet.Validators, altVal))
// Create signer array and ensure it is in same order as bothValSet
_, suiteVal := s.valSet.GetByIndex(0)
_, suiteVal := suite.valSet.GetByIndex(0)
bothSigners := map[string]tmtypes.PrivValidator{
suiteVal.Address.String(): s.privVal,
suiteVal.Address.String(): suite.privVal,
altVal.Address.String(): altPrivVal,
}
return bothValSet, bothSigners
Expand Down

0 comments on commit 693c247

Please sign in to comment.