Skip to content

Commit

Permalink
Merge branch 'main' into likhita/remove-randomizedParams
Browse files Browse the repository at this point in the history
  • Loading branch information
likhita-809 committed Aug 10, 2022
2 parents d4a4c80 + f7e46ae commit beb3801
Show file tree
Hide file tree
Showing 12 changed files with 283 additions and 81 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ require (
github.com/magiconair/properties v1.8.6
github.com/mattn/go-isatty v0.0.14
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.12.2
github.com/prometheus/client_golang v1.13.0
github.com/prometheus/common v0.37.0
github.com/rakyll/statik v0.1.7
github.com/regen-network/cosmos-proto v0.3.1
Expand Down Expand Up @@ -216,7 +216,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/quasilyte/go-ruleguard v0.3.16-0.20220213074421-6aa060fab41a // indirect
github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1116,8 +1116,9 @@ github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34=
github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU=
github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand All @@ -1143,8 +1144,9 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
github.com/pseudomuto/protoc-gen-doc v1.3.2/go.mod h1:y5+P6n3iGrbKG+9O04V5ld71in3v/bX88wUwgt+U8EA=
github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q=
github.com/quasilyte/go-ruleguard v0.3.1-0.20210203134552-1b5a410e1cc8/go.mod h1:KsAh3x0e7Fkpgs+Q9pNLS5XpFSvYCEVl5gP9Pp1xp30=
Expand Down
1 change: 1 addition & 0 deletions scripts/mockgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ $mockgen_cmd -source=x/params/proposal_handler_test.go -package testutil -destin
$mockgen_cmd -source=x/crisis/types/expected_keepers.go -package testutil -destination x/crisis/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/auth/types/expected_keepers.go -package testutil -destination x/auth/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/auth/ante/expected_keepers.go -package testutil -destination x/auth/ante/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/authz/expected_keepers.go -package testutil -destination x/authz/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/bank/types/expected_keepers.go -package testutil -destination x/bank/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/evidence/types/expected_keepers.go -package testutil -destination x/evidence/testutil/expected_keepers_mocks.go
42 changes: 33 additions & 9 deletions x/authz/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,55 @@ import (
"time"

"github.com/stretchr/testify/suite"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/authz/keeper"
"github.com/cosmos/cosmos-sdk/x/authz/testutil"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
authztestutil "github.com/cosmos/cosmos-sdk/x/authz/testutil"
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/golang/mock/gomock"
)

type GenesisTestSuite struct {
suite.Suite

ctx sdk.Context
keeper keeper.Keeper
ctx sdk.Context
keeper keeper.Keeper
baseApp *baseapp.BaseApp
accountKeeper *authztestutil.MockAccountKeeper
encCfg moduletestutil.TestEncodingConfig
}

func (suite *GenesisTestSuite) SetupTest() {
app, err := simtestutil.Setup(
testutil.AppConfig,
&suite.keeper,
key := sdk.NewKVStoreKey(keeper.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, sdk.NewTransientStoreKey("transient_test"))
suite.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{Height: 1})
suite.encCfg = moduletestutil.MakeTestEncodingConfig(authzmodule.AppModuleBasic{})

// gomock initializations
ctrl := gomock.NewController(suite.T())
suite.accountKeeper = authztestutil.NewMockAccountKeeper(ctrl)

suite.baseApp = baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
suite.encCfg.TxConfig.TxDecoder(),
)
suite.Require().NoError(err)
suite.baseApp.SetCMS(testCtx.CMS)

bank.RegisterInterfaces(suite.encCfg.InterfaceRegistry)

msr := suite.baseApp.MsgServiceRouter()
msr.SetInterfaceRegistry(suite.encCfg.InterfaceRegistry)

suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1})
suite.keeper = keeper.NewKeeper(key, suite.encCfg.Codec, msr, suite.accountKeeper)
}

var (
Expand Down
4 changes: 2 additions & 2 deletions x/authz/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (suite *TestSuite) TestGRPCQueryAuthorization() {
func(require *require.Assertions, res *authz.QueryGrantsResponse) {
var auth authz.Authorization
require.Equal(1, len(res.Grants))
err := suite.interfaceRegistry.UnpackAny(res.Grants[0].Authorization, &auth)
err := suite.encCfg.InterfaceRegistry.UnpackAny(res.Grants[0].Authorization, &auth)
require.NoError(err)
require.NotNil(auth)
require.Equal(auth.String(), expAuthorization.String())
Expand Down Expand Up @@ -135,7 +135,7 @@ func (suite *TestSuite) TestGRPCQueryAuthorizations() {
func(res *authz.QueryGrantsResponse) {
var auth authz.Authorization
suite.Require().Equal(1, len(res.Grants))
err := suite.interfaceRegistry.UnpackAny(res.Grants[0].Authorization, &auth)
err := suite.encCfg.InterfaceRegistry.UnpackAny(res.Grants[0].Authorization, &auth)
suite.Require().NoError(err)
suite.Require().NotNil(auth)
suite.Require().Equal(auth.String(), expAuthorization.String())
Expand Down
65 changes: 37 additions & 28 deletions x/authz/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@ import (
"testing"
"time"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/suite"
tmtime "github.com/tendermint/tendermint/libs/time"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/baseapp"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/authz"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
"github.com/cosmos/cosmos-sdk/x/authz/testutil"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
authztestutil "github.com/cosmos/cosmos-sdk/x/authz/testutil"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/tendermint/tendermint/libs/log"
)

var (
Expand All @@ -34,34 +36,46 @@ type TestSuite struct {
ctx sdk.Context
addrs []sdk.AccAddress
authzKeeper authzkeeper.Keeper
bankKeeper bankkeeper.Keeper
accountKeeper *authztestutil.MockAccountKeeper
bankKeeper *authztestutil.MockBankKeeper
interfaceRegistry codectypes.InterfaceRegistry
baseApp *baseapp.BaseApp
encCfg moduletestutil.TestEncodingConfig
queryClient authz.QueryClient
}

func (s *TestSuite) SetupTest() {
var stakingKeeper *stakingkeeper.Keeper

app, err := simtestutil.Setup(
testutil.AppConfig,
&s.bankKeeper,
&stakingKeeper,
&s.authzKeeper,
&s.interfaceRegistry,
key := sdk.NewKVStoreKey(authzkeeper.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test"))
s.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: tmtime.Now()})
s.encCfg = moduletestutil.MakeTestEncodingConfig(authzmodule.AppModuleBasic{})

s.baseApp = baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
s.encCfg.TxConfig.TxDecoder(),
)
s.Require().NoError(err)
s.baseApp.SetCMS(testCtx.CMS)
s.baseApp.SetInterfaceRegistry(s.encCfg.InterfaceRegistry)

ctx := app.BaseApp.NewContext(false, tmproto.Header{})
now := tmtime.Now()
ctx = ctx.WithBlockHeader(tmproto.Header{Time: now})
queryHelper := baseapp.NewQueryServerTestHelper(ctx, s.interfaceRegistry)
s.addrs = simtestutil.CreateIncrementalAccounts(3)

// gomock initializations
ctrl := gomock.NewController(s.T())
s.accountKeeper = authztestutil.NewMockAccountKeeper(ctrl)
s.bankKeeper = authztestutil.NewMockBankKeeper(ctrl)
banktypes.RegisterInterfaces(s.encCfg.InterfaceRegistry)
banktypes.RegisterMsgServer(s.baseApp.MsgServiceRouter(), s.bankKeeper)

s.authzKeeper = authzkeeper.NewKeeper(key, s.encCfg.Codec, s.baseApp.MsgServiceRouter(), s.accountKeeper)

queryHelper := baseapp.NewQueryServerTestHelper(s.ctx, s.encCfg.InterfaceRegistry)
authz.RegisterQueryServer(queryHelper, s.authzKeeper)
queryClient := authz.NewQueryClient(queryHelper)
s.queryClient = queryClient

s.ctx = ctx
s.queryClient = queryClient
s.addrs = simtestutil.AddTestAddrsIncremental(s.bankKeeper, stakingKeeper, ctx, 3, sdk.NewInt(30000000))
}

func (s *TestSuite) TestKeeper() {
Expand Down Expand Up @@ -147,8 +161,6 @@ func (s *TestSuite) TestDispatchAction() {
recipientAddr := addrs[2]
a := banktypes.NewSendAuthorization(coins100, nil)

require.NoError(banktestutil.FundAccount(s.bankKeeper, s.ctx, granterAddr, coins1000))

testCases := []struct {
name string
req authz.MsgExec
Expand Down Expand Up @@ -291,7 +303,6 @@ func (s *TestSuite) TestDispatchedEvents() {
granterAddr := addrs[0]
granteeAddr := addrs[1]
recipientAddr := addrs[2]
require.NoError(banktestutil.FundAccount(s.bankKeeper, s.ctx, granterAddr, coins1000))
expiration := s.ctx.BlockTime().Add(1 * time.Second) // must be in the future

msgs := authz.NewMsgExec(granteeAddr, []sdk.Msg{
Expand Down Expand Up @@ -321,13 +332,11 @@ func (s *TestSuite) TestDispatchedEvents() {
events := s.ctx.EventManager().Events()

// get last 5 events (events that occur *after* the grant)
events = events[len(events)-5:]
events = events[len(events)-2:]

requiredEvents := map[string]bool{
"coin_spent": false,
"coin_received": false,
"transfer": false,
"message": false,
"cosmos.authz.v1beta1.EventGrant": true,
"cosmos.authz.v1beta1.EventRevoke": true,
}
for _, e := range events {
requiredEvents[e.Type] = true
Expand Down
53 changes: 34 additions & 19 deletions x/authz/module/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,42 @@ import (
"time"

"github.com/cosmos/cosmos-sdk/baseapp"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/authz"
"github.com/cosmos/cosmos-sdk/x/authz/keeper"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
"github.com/cosmos/cosmos-sdk/x/authz/testutil"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
authztestutil "github.com/cosmos/cosmos-sdk/x/authz/testutil"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"

"github.com/tendermint/tendermint/proto/tendermint/types"
)

func TestExpiredGrantsQueue(t *testing.T) {
var interfaceRegistry codectypes.InterfaceRegistry
var authzKeeper keeper.Keeper
var bankKeeper bankkeeper.Keeper
var stakingKeeper *stakingkeeper.Keeper

app, err := simtestutil.Setup(
testutil.AppConfig,
&interfaceRegistry,
&authzKeeper,
&bankKeeper,
&stakingKeeper,

key := sdk.NewKVStoreKey(keeper.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModuleBasic{})
ctx := testCtx.Ctx.WithBlockHeader(types.Header{})

baseApp := baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
encCfg.TxConfig.TxDecoder(),
)
require.NoError(t, err)
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)

ctx := app.BaseApp.NewContext(false, types.Header{})
addrs := simtestutil.AddTestAddrsIncremental(bankKeeper, stakingKeeper, ctx, 5, sdk.NewInt(30000000))
banktypes.RegisterInterfaces(encCfg.InterfaceRegistry)

addrs := simtestutil.CreateIncrementalAccounts(5)
granter := addrs[0]
grantee1 := addrs[1]
grantee2 := addrs[2]
Expand All @@ -46,6 +51,16 @@ func TestExpiredGrantsQueue(t *testing.T) {
smallCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 10))
sendAuthz := banktypes.NewSendAuthorization(smallCoins, nil)

ctrl := gomock.NewController(t)
accountKeeper := authztestutil.NewMockAccountKeeper(ctrl)
accountKeeper.EXPECT().GetAccount(gomock.Any(), granter).Return(authtypes.NewBaseAccountWithAddress(granter)).AnyTimes()
accountKeeper.EXPECT().GetAccount(gomock.Any(), grantee1).Return(authtypes.NewBaseAccountWithAddress(grantee1)).AnyTimes()
accountKeeper.EXPECT().GetAccount(gomock.Any(), grantee2).Return(authtypes.NewBaseAccountWithAddress(grantee2)).AnyTimes()
accountKeeper.EXPECT().GetAccount(gomock.Any(), grantee3).Return(authtypes.NewBaseAccountWithAddress(grantee3)).AnyTimes()
accountKeeper.EXPECT().GetAccount(gomock.Any(), grantee4).Return(authtypes.NewBaseAccountWithAddress(grantee4)).AnyTimes()

authzKeeper := keeper.NewKeeper(key, encCfg.Codec, baseApp.MsgServiceRouter(), accountKeeper)

save := func(grantee sdk.AccAddress, exp *time.Time) {
err := authzKeeper.SaveGrant(ctx, grantee, granter, sendAuthz, exp)
require.NoError(t, err, "Grant from %s", grantee.String())
Expand All @@ -55,7 +70,7 @@ func TestExpiredGrantsQueue(t *testing.T) {
save(grantee3, &expiration2)
save(grantee4, nil)

queryHelper := baseapp.NewQueryServerTestHelper(ctx, interfaceRegistry)
queryHelper := baseapp.NewQueryServerTestHelper(ctx, encCfg.InterfaceRegistry)
authz.RegisterQueryServer(queryHelper, authzKeeper)
queryClient := authz.NewQueryClient(queryHelper)

Expand Down
14 changes: 7 additions & 7 deletions x/authz/simulation/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ import (

"github.com/stretchr/testify/require"

"cosmossdk.io/depinject"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/cosmos/cosmos-sdk/x/authz"
"github.com/cosmos/cosmos-sdk/x/authz/keeper"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
"github.com/cosmos/cosmos-sdk/x/authz/simulation"
"github.com/cosmos/cosmos-sdk/x/authz/testutil"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
)

func TestDecodeStore(t *testing.T) {
var cdc codec.Codec
depinject.Inject(testutil.AppConfig, &cdc)
encCfg := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModuleBasic{})
banktypes.RegisterInterfaces(encCfg.InterfaceRegistry)

dec := simulation.NewDecodeStore(cdc)
dec := simulation.NewDecodeStore(encCfg.Codec)

now := time.Now().UTC()
e := now.Add(1)
sendAuthz := banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewInt64Coin("foo", 123)), nil)
grant, _ := authz.NewGrant(now, sendAuthz, &e)
grantBz, err := cdc.Marshal(&grant)
grantBz, err := encCfg.Codec.Marshal(&grant)
require.NoError(t, err)
kvPairs := kv.Pairs{
Pairs: []kv.Pair{
Expand Down
Loading

0 comments on commit beb3801

Please sign in to comment.