mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 18:15:19 +00:00
ffef832d45
- Upgrade cosmos-sdk to v0.44.5 from v0.39.2 - Add Legacy Tx Endpoint for backwards compatibility - Add IBC v1.2.3 Support Co-authored-by: DracoLi <draco@dracoli.com> Co-authored-by: drklee3 <derrick@dlee.dev> Co-authored-by: denalimarsh <denalimarsh@gmail.com> Co-authored-by: Draco Li <draco@kava.io> Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com> Co-authored-by: Kevin Davis <karzak@users.noreply.github.com> Co-authored-by: Denali Marsh <denali@kava.io>
116 lines
2.2 KiB
Go
116 lines
2.2 KiB
Go
package keeper_test
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/kava-labs/kava/x/kavadist/types"
|
|
)
|
|
|
|
func (suite *keeperTestSuite) TestGRPCParams() {
|
|
ctx, keeper, queryClient := suite.Ctx, suite.Keeper, suite.QueryClient
|
|
|
|
var (
|
|
params types.Params
|
|
req *types.QueryParamsRequest
|
|
expParams types.Params
|
|
)
|
|
|
|
testCases := []struct {
|
|
msg string
|
|
malleate func()
|
|
expPass bool
|
|
}{
|
|
{
|
|
"response with default params",
|
|
func() {
|
|
expParams = types.DefaultParams()
|
|
keeper.SetParams(ctx, expParams)
|
|
req = &types.QueryParamsRequest{}
|
|
},
|
|
true,
|
|
},
|
|
{
|
|
"response with params",
|
|
func() {
|
|
params = types.Params{
|
|
Active: true,
|
|
Periods: suite.TestPeriods,
|
|
}
|
|
keeper.SetParams(ctx, params)
|
|
req = &types.QueryParamsRequest{}
|
|
expParams = params
|
|
},
|
|
true,
|
|
},
|
|
}
|
|
|
|
for _, testCase := range testCases {
|
|
suite.Run(fmt.Sprintf("Case %s", testCase.msg), func() {
|
|
testCase.malleate()
|
|
|
|
paramsRes, err := queryClient.Params(context.Background(), req)
|
|
|
|
if testCase.expPass {
|
|
suite.Require().NoError(err)
|
|
suite.Require().NotNil(paramsRes)
|
|
suite.Require().True(expParams.Equal(paramsRes.Params))
|
|
} else {
|
|
suite.Require().Error(err)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func (suite *keeperTestSuite) TestGRPCBalance() {
|
|
ctx, queryClient := suite.Ctx, suite.QueryClient
|
|
|
|
var (
|
|
req *types.QueryBalanceRequest
|
|
expCoins sdk.Coins
|
|
)
|
|
|
|
testCases := []struct {
|
|
msg string
|
|
malleate func()
|
|
expPass bool
|
|
}{
|
|
{
|
|
"response with no balance",
|
|
func() {
|
|
expCoins = sdk.Coins{}
|
|
req = &types.QueryBalanceRequest{}
|
|
},
|
|
true,
|
|
},
|
|
{
|
|
"response with balance",
|
|
func() {
|
|
expCoins = sdk.Coins{
|
|
sdk.NewCoin("ukava", sdk.NewInt(100)),
|
|
}
|
|
suite.App.FundModuleAccount(ctx, types.ModuleName, expCoins)
|
|
req = &types.QueryBalanceRequest{}
|
|
},
|
|
true,
|
|
},
|
|
}
|
|
|
|
for _, testCase := range testCases {
|
|
suite.Run(fmt.Sprintf("Case %s", testCase.msg), func() {
|
|
testCase.malleate()
|
|
|
|
res, err := queryClient.Balance(context.Background(), req)
|
|
|
|
if testCase.expPass {
|
|
suite.Require().NoError(err)
|
|
suite.Require().True(expCoins.IsEqual(res.Coins))
|
|
} else {
|
|
suite.Require().Error(err)
|
|
}
|
|
})
|
|
}
|
|
}
|