laconicd-deprecated/x/nameservice/keeper/keeper_test.go
Sai Kumar db925906f3
Nameservice module cli, grpc test cases (#7)
* WIP: migrating the nameservice module

* WIP: migrating the nameservice module from dxns to ethermint

* refactor: move the proto package version from `v1` to `v1beta1` for vulcanize modules

* refactor: added bond module dependency to nameserivce module

* feat: added auction module dependency to nameservice module

* refactor: refactored the nameservice module

* refactor: add human-readable attributes output to cli nameservice `list`

* WIP: add grpc query test cases

* fix: fix the sub names authority storing issue

* WIP: add the test cases

* refactor: removed legacyCodec from nameservice

* fix: fix the responses for `authority-expiry` and `records-expiry` commands query result

* refactor: sort the imports in app

* WIP:  add test cases for cli query, tx for nameservice module

* feat: add test cases for grpc of nameservice module

1. renamed grpc gateway routes from ethermint to vulcanize

* refactor: refactored the test cases for grpc lookup of nameservice

* refactor: refactored the test cases for bond module
2021-10-13 12:07:19 +05:30

63 lines
1.9 KiB
Go

package keeper_test
import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/tharsis/ethermint/app"
bondtypes "github.com/tharsis/ethermint/x/bond/types"
nameservicekeeper "github.com/tharsis/ethermint/x/nameservice/keeper"
"github.com/tharsis/ethermint/x/nameservice/types"
"testing"
)
type KeeperTestSuite struct {
suite.Suite
app *app.EthermintApp
ctx sdk.Context
queryClient types.QueryClient
accounts []sdk.AccAddress
bond bondtypes.Bond
}
func (suite *KeeperTestSuite) SetupTest() {
testApp := app.Setup(false)
ctx := testApp.BaseApp.NewContext(false, tmproto.Header{})
querier := nameservicekeeper.Querier{Keeper: testApp.NameServiceKeeper}
queryHelper := baseapp.NewQueryServerTestHelper(ctx, testApp.InterfaceRegistry())
types.RegisterQueryServer(queryHelper, querier)
queryClient := types.NewQueryClient(queryHelper)
suite.accounts = app.CreateRandomAccounts(1)
account := suite.accounts[0]
_ = simapp.FundAccount(testApp.BankKeeper, ctx, account, sdk.NewCoins(sdk.Coin{
Denom: sdk.DefaultBondDenom,
Amount: sdk.NewInt(100000000000),
}))
bond, err := testApp.BondKeeper.CreateBond(ctx, account, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000000000))))
if err != nil {
return
}
suite.bond = *bond
suite.app, suite.ctx, suite.queryClient = testApp, ctx, queryClient
}
func TestParams(t *testing.T) {
testApp := app.Setup(false)
ctx := testApp.BaseApp.NewContext(false, tmproto.Header{})
expParams := types.DefaultParams()
params := testApp.NameServiceKeeper.GetParams(ctx)
require.True(t, params.Equal(expParams))
}
func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(KeeperTestSuite))
}