Skip to content

Commit

Permalink
don't add tests (reduce diff)
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Jul 10, 2023
1 parent 0dcf5cc commit d87f093
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package keeper_test

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"
)

func (suite *KeeperTestSuite) TestQueryParams() {
ctx := suite.chainA.GetContext()
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
expParams := types.DefaultParams()
res, _ := suite.chainA.GetSimApp().ICAHostKeeper.Params(ctx, &types.QueryParamsRequest{})
suite.Require().Equal(&expParams, res.Params)
Expand Down
28 changes: 8 additions & 20 deletions modules/apps/27-interchain-accounts/host/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() {
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)

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)
suite.chainB.GetSimApp().GovKeeper.SetProposal(suite.chainB.GetContext(), proposal)

Check failure on line 56 in modules/apps/27-interchain-accounts/host/keeper/relay_test.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `.SetProposal` is not checked (errcheck)
suite.chainB.GetSimApp().GovKeeper.ActivateVotingPeriod(suite.chainB.GetContext(), proposal)

Check failure on line 57 in modules/apps/27-interchain-accounts/host/keeper/relay_test.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `.ActivateVotingPeriod` is not checked (errcheck)

msg := &govtypes.MsgVote{
ProposalId: govtypes.DefaultStartingProposalID,
Expand Down Expand Up @@ -222,11 +219,8 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() {
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)

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)
suite.chainB.GetSimApp().GovKeeper.SetProposal(suite.chainB.GetContext(), proposal)

Check failure on line 222 in modules/apps/27-interchain-accounts/host/keeper/relay_test.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `.SetProposal` is not checked (errcheck)
suite.chainB.GetSimApp().GovKeeper.ActivateVotingPeriod(suite.chainB.GetContext(), proposal)

Check failure on line 223 in modules/apps/27-interchain-accounts/host/keeper/relay_test.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `.ActivateVotingPeriod` is not checked (errcheck)

msg := &govtypes.MsgVote{
ProposalId: govtypes.DefaultStartingProposalID,
Expand Down Expand Up @@ -543,11 +537,8 @@ 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)

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)
suite.chainB.GetSimApp().GovKeeper.SetProposal(suite.chainB.GetContext(), proposal)

Check failure on line 540 in modules/apps/27-interchain-accounts/host/keeper/relay_test.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `.SetProposal` is not checked (errcheck)
suite.chainB.GetSimApp().GovKeeper.ActivateVotingPeriod(suite.chainB.GetContext(), proposal)

Check failure on line 541 in modules/apps/27-interchain-accounts/host/keeper/relay_test.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `.ActivateVotingPeriod` is not checked (errcheck)

msgBytes := []byte(`{
"messages": [
Expand Down Expand Up @@ -642,11 +633,8 @@ 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)

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)
suite.chainB.GetSimApp().GovKeeper.SetProposal(suite.chainB.GetContext(), proposal)

Check failure on line 636 in modules/apps/27-interchain-accounts/host/keeper/relay_test.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `.SetProposal` is not checked (errcheck)
suite.chainB.GetSimApp().GovKeeper.ActivateVotingPeriod(suite.chainB.GetContext(), proposal)

Check failure on line 637 in modules/apps/27-interchain-accounts/host/keeper/relay_test.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `.ActivateVotingPeriod` is not checked (errcheck)

msgBytes := []byte(`{
"messages": [
Expand Down
16 changes: 9 additions & 7 deletions modules/capability/capability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (suite *CapabilityTestSuite) SetupTest() {
cdc := app.AppCodec()

// create new keeper so we can define custom scoping before init and seal
keeper := keeper.NewKeeper(cdc, app.GetKey(types.StoreKey), app.GetKey(types.MemStoreKey))
keeper := keeper.NewKeeper(cdc, app.GetKey(types.StoreKey), app.GetMemKey(types.MemStoreKey))

suite.app = app
suite.ctx = app.BaseApp.NewContext(checkTx)
Expand All @@ -54,22 +54,23 @@ func (suite *CapabilityTestSuite) TestInitializeMemStore() {
suite.Require().NotNil(cap1)

// mock statesync by creating new keeper that shares persistent state but loses in-memory map
newKeeper := keeper.NewKeeper(suite.cdc, suite.app.GetKey(types.StoreKey), suite.app.GetKey(memStoreKey))
newKeeper := keeper.NewKeeper(suite.cdc, suite.app.GetKey(types.StoreKey), suite.app.GetMemKey(memStoreKey))
newSk1 := newKeeper.ScopeToModule(banktypes.ModuleName)

// Mock App startup
ctx := suite.app.BaseApp.NewUncachedContext(false, tmproto.Header{})
newKeeper.Seal()
suite.Require().False(newKeeper.IsInitialized(ctx), "memstore initialized flag set before BeginBlock")

// Mock app beginblock and ensure that no gas has been consumed and memstore is initialized
// Mock app BeginBlock and ensure that no gas has been consumed and memstore is initialized
ctx = suite.app.BaseApp.NewContext(false)

prevBlockGas := ctx.BlockGasMeter().GasConsumed()
prevGas := ctx.BlockGasMeter().GasConsumed()

restartedModule := capability.NewAppModule(suite.cdc, *newKeeper, true)
restartedModule.BeginBlock(ctx)
err = restartedModule.BeginBlock(ctx)
suite.Require().NoError(err)
gasUsed := ctx.GasMeter().GasConsumed()

suite.Require().True(newKeeper.IsInitialized(ctx), "memstore initialized flag not set")
Expand All @@ -81,8 +82,8 @@ func (suite *CapabilityTestSuite) TestInitializeMemStore() {
// Mock the first transaction getting capability and subsequently failing
// by using a cached context and discarding all cached writes.
cacheCtx, _ := ctx.CacheContext()
capability, ok := newSk1.GetCapability(cacheCtx, "transfer")
suite.Require().NotNil(capability)
transferCapability, ok := newSk1.GetCapability(cacheCtx, "transfer")
suite.Require().NotNil(transferCapability)
suite.Require().True(ok)

// Ensure that the second transaction can still receive capability even if first tx fails.
Expand All @@ -94,7 +95,8 @@ func (suite *CapabilityTestSuite) TestInitializeMemStore() {
// Ensure the capabilities don't get reinitialized on next BeginBlock
// by testing to see if capability returns same pointer
// also check that initialized flag is still set
restartedModule.BeginBlock(ctx)
err = restartedModule.BeginBlock(ctx)
suite.Require().NoError(err)
recap, ok := newSk1.GetCapability(ctx, "transfer")
suite.Require().True(ok)
suite.Require().Equal(cap1, recap, "capabilities got reinitialized after second BeginBlock")
Expand Down
2 changes: 1 addition & 1 deletion modules/capability/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState)
// ExportGenesis returns the capability module's exported genesis.
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
index := k.GetLatestIndex(ctx)
owners := []types.GenesisOwners{}
var owners []types.GenesisOwners

for i := uint64(1); i < index; i++ {
capabilityOwners, ok := k.GetOwners(ctx, i)
Expand Down
3 changes: 1 addition & 2 deletions modules/capability/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ func (suite *KeeperTestSuite) TestAuthenticateCapability() {
suite.Require().False(sk2.AuthenticateCapability(suite.ctx, cap2, "invalid"))
suite.Require().False(sk2.AuthenticateCapability(suite.ctx, cap1, "bond"))

err = sk2.ReleaseCapability(suite.ctx, cap2)
suite.Require().NoError(err)
sk2.ReleaseCapability(suite.ctx, cap2)
suite.Require().False(sk2.AuthenticateCapability(suite.ctx, cap2, "bond"))

badCap := types.NewCapability(100)
Expand Down

0 comments on commit d87f093

Please sign in to comment.