gofumpt and ignore duplicates

This commit is contained in:
0xmuralik 2022-10-17 12:17:56 +05:30
parent ec3e8f7ce3
commit a4f2cb5731
35 changed files with 74 additions and 116 deletions

View File

@ -344,7 +344,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20))
gasAmount := sdk.NewCoins(coinAmount) gasAmount := sdk.NewCoins(coinAmount)
gas := uint64(200000) gas := uint64(200000)
//reusing the gasAmount for deposit // reusing the gasAmount for deposit
deposit := sdk.NewCoins(coinAmount) deposit := sdk.NewCoins(coinAmount)
txBuilder := suite.CreateTestEIP712SubmitProposal(from, privKey, "ethermint_9000-1", gas, gasAmount, deposit) txBuilder := suite.CreateTestEIP712SubmitProposal(from, privKey, "ethermint_9000-1", gas, gasAmount, deposit)
return txBuilder.GetTx() return txBuilder.GetTx()

View File

@ -23,9 +23,11 @@ import (
) )
// Testing Constants // Testing Constants
var chainId = "ethermint_9000-1" var (
var ctx = client.Context{}.WithTxConfig( chainId = "ethermint_9000-1"
encoding.MakeConfig(app.ModuleBasics).TxConfig, ctx = client.Context{}.WithTxConfig(
encoding.MakeConfig(app.ModuleBasics).TxConfig,
)
) )
var feePayerAddress = "ethm17xpfvakm2amg962yls6f84z3kell8c5lthdzgl" var feePayerAddress = "ethm17xpfvakm2amg962yls6f84z3kell8c5lthdzgl"

View File

@ -125,7 +125,6 @@ func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueI
All: (all != nil && *all), All: (all != nil && *all),
}, },
) )
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -142,7 +141,6 @@ func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueI
} }
return gqlResponse, nil return gqlResponse, nil
} }
func (q queryResolver) GetRecordsByIds(ctx context.Context, ids []string) ([]*Record, error) { func (q queryResolver) GetRecordsByIds(ctx context.Context, ids []string) ([]*Record, error) {

View File

@ -38,6 +38,7 @@ func getGQLCoins(coins sdk.Coins) []*Coin {
return gqlCoins return gqlCoins
} }
func GetGQLNameAuthorityRecord(record *nstypes.NameAuthority) (*AuthorityRecord, error) { func GetGQLNameAuthorityRecord(record *nstypes.NameAuthority) (*AuthorityRecord, error) {
if record == nil { if record == nil {
return nil, nil return nil, nil
@ -118,26 +119,6 @@ func getGQLBond(bondObj *bondtypes.Bond) (*Bond, error) {
}, nil }, nil
} }
func matchBondOnAttributes(bondObj *bondtypes.Bond, attributes []*KeyValueInput) bool {
for _, attr := range attributes {
switch attr.Key {
case OwnerAttributeName:
{
if attr.Value.String == nil || bondObj.Owner != *attr.Value.String {
return false
}
}
default:
{
// Only attributes explicitly listed in the switch are queryable.
return false
}
}
}
return true
}
func getAuctionBid(bid *auctiontypes.Bid) *AuctionBid { func getAuctionBid(bid *auctiontypes.Bid) *AuctionBid {
return &AuctionBid{ return &AuctionBid{
BidderAddress: bid.BidderAddress, BidderAddress: bid.BidderAddress,

View File

@ -3,13 +3,14 @@ package rpc
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/gorilla/websocket"
"github.com/stretchr/testify/require"
"net/url" "net/url"
"os" "os"
"strings" "strings"
"testing" "testing"
"time" "time"
"github.com/gorilla/websocket"
"github.com/stretchr/testify/require"
) )
var ( var (

View File

@ -134,7 +134,7 @@ func GetCmdCommitBid() *cobra.Command {
} }
// Save reveal file. // Save reveal file.
ioutil.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0600) ioutil.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0o600)
msg := types.NewMsgCommitBid(auctionID, commitHash, clientCtx.GetFromAddress()) msg := types.NewMsgCommitBid(auctionID, commitHash, clientCtx.GetFromAddress())
err = msg.ValidateBasic() err = msg.ValidateBasic()

View File

@ -13,9 +13,7 @@ import (
const testCommitHash = "71D8CF34026E32A3A34C2C2D4ADF25ABC8D7943A4619761BE27F196603D91B9D" const testCommitHash = "71D8CF34026E32A3A34C2C2D4ADF25ABC8D7943A4619761BE27F196603D91B9D"
var ( var seed = int64(233)
seed = int64(233)
)
func (suite *KeeperTestSuite) TestGrpcGetAllAuctions() { func (suite *KeeperTestSuite) TestGrpcGetAllAuctions() {
client, ctx, k := suite.queryClient, suite.ctx, suite.app.AuctionKeeper client, ctx, k := suite.queryClient, suite.ctx, suite.app.AuctionKeeper

View File

@ -50,6 +50,7 @@ func (s msgServer) CreateAuction(c context.Context, msg *types.MsgCreateAuction)
} }
// CommitBid is the command for committing a bid // CommitBid is the command for committing a bid
//nolint: all
func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types.MsgCommitBidResponse, error) { func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types.MsgCommitBidResponse, error) {
ctx := sdk.UnwrapSDKContext(c) ctx := sdk.UnwrapSDKContext(c)
@ -80,6 +81,7 @@ func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types
} }
//RevealBid is the command for revealing a bid //RevealBid is the command for revealing a bid
//nolint: all
func (s msgServer) RevealBid(c context.Context, msg *types.MsgRevealBid) (*types.MsgRevealBidResponse, error) { func (s msgServer) RevealBid(c context.Context, msg *types.MsgRevealBid) (*types.MsgRevealBidResponse, error) {
ctx := sdk.UnwrapSDKContext(c) ctx := sdk.UnwrapSDKContext(c)

View File

@ -63,7 +63,6 @@ func (msg MsgCreateAuction) GetSigners() []sdk.AccAddress {
// NewMsgCommitBid is the constructor function for MsgCommitBid. // NewMsgCommitBid is the constructor function for MsgCommitBid.
func NewMsgCommitBid(auctionID string, commitHash string, signer sdk.AccAddress) MsgCommitBid { func NewMsgCommitBid(auctionID string, commitHash string, signer sdk.AccAddress) MsgCommitBid {
return MsgCommitBid{ return MsgCommitBid{
AuctionId: auctionID, AuctionId: auctionID,
CommitHash: commitHash, CommitHash: commitHash,
@ -107,7 +106,6 @@ func (msg MsgCommitBid) GetSigners() []sdk.AccAddress {
// NewMsgRevealBid is the constructor function for MsgRevealBid. // NewMsgRevealBid is the constructor function for MsgRevealBid.
func NewMsgRevealBid(auctionID string, reveal string, signer sdk.AccAddress) MsgRevealBid { func NewMsgRevealBid(auctionID string, reveal string, signer sdk.AccAddress) MsgRevealBid {
return MsgRevealBid{ return MsgRevealBid{
AuctionId: auctionID, AuctionId: auctionID,
Reveal: reveal, Reveal: reveal,

View File

@ -28,7 +28,6 @@ func (s *IntegrationTestSuite) TestGRPCGetBonds() {
true, true,
"", "",
func() { func() {
}, },
}, },
{ {
@ -87,7 +86,6 @@ func (s *IntegrationTestSuite) TestGRPCGetBondsByOwner() {
fmt.Sprintf(reqUrl, "asdasd"), fmt.Sprintf(reqUrl, "asdasd"),
true, true,
func() { func() {
}, },
}, },
{ {

View File

@ -251,7 +251,6 @@ func (s *IntegrationTestSuite) TestGetQueryBondListsByOwner() {
}, },
true, true,
func() { func() {
}, },
}, },
{ {

View File

@ -63,6 +63,7 @@ func (s *IntegrationTestSuite) TestTxCreateBond() {
} }
} }
//nolint: all
func (s *IntegrationTestSuite) TestTxRefillBond() { func (s *IntegrationTestSuite) TestTxRefillBond() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()
@ -148,6 +149,7 @@ func (s *IntegrationTestSuite) TestTxRefillBond() {
} }
} }
//nolint: all
func (s *IntegrationTestSuite) TestTxWithdrawAmountFromBond() { func (s *IntegrationTestSuite) TestTxWithdrawAmountFromBond() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()

View File

@ -10,8 +10,8 @@ import (
// InitGenesis initializes genesis state based on exported genesis // InitGenesis initializes genesis state based on exported genesis
func InitGenesis( func InitGenesis(
ctx sdk.Context, ctx sdk.Context,
k keeper.Keeper, data types.GenesisState) []abci.ValidatorUpdate { k keeper.Keeper, data types.GenesisState,
) []abci.ValidatorUpdate {
k.SetParams(ctx, data.Params) k.SetParams(ctx, data.Params)
for _, bond := range data.Bonds { for _, bond := range data.Bonds {

View File

@ -11,9 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/bank/testutil"
) )
var ( var seed = int64(233)
seed = int64(233)
)
func (suite *KeeperTestSuite) TestGrpcQueryBondsList() { func (suite *KeeperTestSuite) TestGrpcQueryBondsList() {
grpcClient, ctx, k := suite.queryClient, suite.ctx, suite.app.BondKeeper grpcClient, ctx, k := suite.queryClient, suite.ctx, suite.app.BondKeeper

View File

@ -45,6 +45,7 @@ func (k msgServer) CreateBond(c context.Context, msg *types.MsgCreateBond) (*typ
return &types.MsgCreateBondResponse{}, nil return &types.MsgCreateBondResponse{}, nil
} }
//nolint: all
func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*types.MsgRefillBondResponse, error) { func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*types.MsgRefillBondResponse, error) {
ctx := sdk.UnwrapSDKContext(c) ctx := sdk.UnwrapSDKContext(c)
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
@ -74,6 +75,7 @@ func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*typ
return &types.MsgRefillBondResponse{}, nil return &types.MsgRefillBondResponse{}, nil
} }
//nolint: all
func (k msgServer) WithdrawBond(c context.Context, msg *types.MsgWithdrawBond) (*types.MsgWithdrawBondResponse, error) { func (k msgServer) WithdrawBond(c context.Context, msg *types.MsgWithdrawBond) (*types.MsgWithdrawBondResponse, error) {
ctx := sdk.UnwrapSDKContext(c) ctx := sdk.UnwrapSDKContext(c)
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)

View File

@ -3,6 +3,7 @@ package types
import ( import (
"errors" "errors"
"fmt" "fmt"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
) )

View File

@ -60,7 +60,7 @@ func (suite *TxDataTestSuite) TestAccessListTxGetGasFeeCap() {
func (suite *TxDataTestSuite) TestEmptyAccessList() { func (suite *TxDataTestSuite) TestEmptyAccessList() {
testCases := []struct { testCases := []struct {
name string name string
tx AccessListTx tx AccessListTx
}{ }{
{ {
"empty access list tx", "empty access list tx",

View File

@ -11,9 +11,9 @@ import (
func (suite *TxDataTestSuite) TestTxArgsString() { func (suite *TxDataTestSuite) TestTxArgsString() {
testCases := []struct { testCases := []struct {
name string name string
txArgs TransactionArgs txArgs TransactionArgs
expectedString string expectedString string
}{ }{
{ {
"empty tx args", "empty tx args",
@ -32,25 +32,25 @@ func (suite *TxDataTestSuite) TestTxArgsString() {
AccessList: &ethtypes.AccessList{}, AccessList: &ethtypes.AccessList{},
}, },
fmt.Sprintf("TransactionArgs{From:%v, To:%v, Gas:%v, Nonce:%v, Data:%v, Input:%v, AccessList:%v}", fmt.Sprintf("TransactionArgs{From:%v, To:%v, Gas:%v, Nonce:%v, Data:%v, Input:%v, AccessList:%v}",
&suite.addr, &suite.addr,
&suite.addr, &suite.addr,
&suite.hexUint64, &suite.hexUint64,
&suite.hexUint64, &suite.hexUint64,
&suite.hexDataBytes, &suite.hexDataBytes,
&suite.hexInputBytes, &suite.hexInputBytes,
&ethtypes.AccessList{}), &ethtypes.AccessList{}),
}, },
} }
for _, tc := range testCases { for _, tc := range testCases {
outputString := tc.txArgs.String() outputString := tc.txArgs.String()
suite.Require().Equal(outputString, tc.expectedString) suite.Require().Equal(outputString, tc.expectedString)
} }
} }
func (suite *TxDataTestSuite) TestConvertTxArgsEthTx() { func (suite *TxDataTestSuite) TestConvertTxArgsEthTx() {
testCases := []struct { testCases := []struct {
name string name string
txArgs TransactionArgs txArgs TransactionArgs
}{ }{
{ {
"empty tx args", "empty tx args",
@ -227,9 +227,9 @@ func (suite *TxDataTestSuite) TestToMessageEVM() {
func (suite *TxDataTestSuite) TestGetFrom() { func (suite *TxDataTestSuite) TestGetFrom() {
testCases := []struct { testCases := []struct {
name string name string
txArgs TransactionArgs txArgs TransactionArgs
expAddress common.Address expAddress common.Address
}{ }{
{ {
"empty from field", "empty from field",

View File

@ -266,7 +266,6 @@ $ %s query %s query-by-bond [bond id]
return err return err
} }
return clientCtx.PrintProto(res) return clientCtx.PrintProto(res)
}, },
} }
flags.AddQueryFlagsToCmd(cmd) flags.AddQueryFlagsToCmd(cmd)

View File

@ -371,7 +371,7 @@ $ %s tx %s delete-name [crn]
return cmd return cmd
} }
//GetPayloadFromFile Load payload object from YAML file. // GetPayloadFromFile Load payload object from YAML file.
func GetPayloadFromFile(filePath string) (*types.PayloadType, error) { func GetPayloadFromFile(filePath string) (*types.PayloadType, error) {
var payload types.PayloadType var payload types.PayloadType

View File

@ -60,11 +60,12 @@ func (s *IntegrationTestSuite) TestGRPCQueryParams() {
} }
} }
//nolint: all
func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() { func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()
reqUrl := val.APIAddress + "/vulcanize/nameservice/v1beta1/whois/%s" reqUrl := val.APIAddress + "/vulcanize/nameservice/v1beta1/whois/%s"
var authorityName = "QueryWhoIS" authorityName := "QueryWhoIS"
testCases := []struct { testCases := []struct {
name string name string
url string url string
@ -78,7 +79,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() {
true, true,
"", "",
func(authorityName string) { func(authorityName string) {
}, },
}, },
{ {
@ -132,7 +132,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()
reqUrl := val.APIAddress + "/vulcanize/nameservice/v1beta1/lookup?crn=%s" reqUrl := val.APIAddress + "/vulcanize/nameservice/v1beta1/lookup?crn=%s"
var authorityName = "QueryLookUp" authorityName := "QueryLookUp"
testCases := []struct { testCases := []struct {
name string name string
@ -147,7 +147,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
true, true,
"", "",
func(authorityName string) { func(authorityName string) {
}, },
}, },
{ {
@ -181,6 +180,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
} }
} }
//nolint: all
func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() { func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()
@ -199,7 +199,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
true, true,
"", "",
func(bondId string) { func(bondId string) {
}, },
}, },
{ {
@ -253,6 +252,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
} }
} }
//nolint: all
func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() { func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()
@ -271,7 +271,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
true, true,
"", "",
func(authorityName string) { func(authorityName string) {
}, },
}, },
{ {
@ -325,6 +324,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
} }
} }
//nolint: all
func (s *IntegrationTestSuite) TestGRPCQueryListRecords() { func (s *IntegrationTestSuite) TestGRPCQueryListRecords() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()
@ -343,7 +343,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryListRecords() {
true, true,
"", "",
func(bondId string) { func(bondId string) {
}, },
}, },
{ {
@ -483,7 +482,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRecordByBondID() {
true, true,
"", "",
func(bondId string) { func(bondId string) {
}, },
}, },
{ {
@ -538,7 +536,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetNameServiceModuleBalance() {
true, true,
"", "",
func(bondId string) { func(bondId string) {
}, },
}, },
{ {
@ -590,7 +587,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryNamesList() {
true, true,
"", "",
func(authorityName string) { func(authorityName string) {
}, },
}, },
{ {

View File

@ -66,7 +66,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryForRecords() {
true, true,
0, 0,
func() { func() {
}, },
}, },
{ {
@ -235,7 +234,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryForRecords() {
func (s *IntegrationTestSuite) TestGetCmdWhoIs() { func (s *IntegrationTestSuite) TestGetCmdWhoIs() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()
var authorityName = "test2" authorityName := "test2"
testCases := []struct { testCases := []struct {
name string name string
args []string args []string
@ -249,7 +248,6 @@ func (s *IntegrationTestSuite) TestGetCmdWhoIs() {
true, true,
1, 1,
func(authorityName string) { func(authorityName string) {
}, },
}, },
{ {
@ -306,7 +304,7 @@ func (s *IntegrationTestSuite) TestGetCmdWhoIs() {
func (s *IntegrationTestSuite) TestGetCmdLookupCRN() { func (s *IntegrationTestSuite) TestGetCmdLookupCRN() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()
var authorityName = "test1" authorityName := "test1"
testCases := []struct { testCases := []struct {
name string name string
args []string args []string
@ -320,7 +318,6 @@ func (s *IntegrationTestSuite) TestGetCmdLookupCRN() {
true, true,
0, 0,
func(authorityName string) { func(authorityName string) {
}, },
}, },
{ {
@ -400,7 +397,7 @@ func (s *IntegrationTestSuite) TestGetCmdLookupCRN() {
func (s *IntegrationTestSuite) GetRecordExpiryQueue() { func (s *IntegrationTestSuite) GetRecordExpiryQueue() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()
var authorityName = "GetRecordExpiryQueue" authorityName := "GetRecordExpiryQueue"
testCasesForRecordsExpiry := []struct { testCasesForRecordsExpiry := []struct {
name string name string
@ -415,7 +412,6 @@ func (s *IntegrationTestSuite) GetRecordExpiryQueue() {
true, true,
0, 0,
func(authorityName string, s *IntegrationTestSuite) { func(authorityName string, s *IntegrationTestSuite) {
}, },
}, },
{ {
@ -451,10 +447,11 @@ func (s *IntegrationTestSuite) GetRecordExpiryQueue() {
}) })
} }
} }
func (s *IntegrationTestSuite) TestGetAuthorityExpiryQueue() { func (s *IntegrationTestSuite) TestGetAuthorityExpiryQueue() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()
var authorityName = "TestGetAuthorityExpiryQueue" authorityName := "TestGetAuthorityExpiryQueue"
testCases := []struct { testCases := []struct {
name string name string
@ -467,7 +464,6 @@ func (s *IntegrationTestSuite) TestGetAuthorityExpiryQueue() {
[]string{"invalid", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, []string{"invalid", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
true, true,
func(authorityName string) { func(authorityName string) {
}, },
}, },
{ {

View File

@ -42,7 +42,7 @@ func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
func (s *IntegrationTestSuite) SetupSuite() { func (s *IntegrationTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite") s.T().Log("setting up integration test suite")
var genesisState = s.cfg.GenesisState genesisState := s.cfg.GenesisState
var nsData nstypes.GenesisState var nsData nstypes.GenesisState
s.Require().NoError(s.cfg.Codec.UnmarshalJSON(genesisState[nstypes.ModuleName], &nsData)) s.Require().NoError(s.cfg.Codec.UnmarshalJSON(genesisState[nstypes.ModuleName], &nsData))
@ -222,7 +222,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetRecord() {
func (s *IntegrationTestSuite) TestGetCmdReserveName() { func (s *IntegrationTestSuite) TestGetCmdReserveName() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()
var authorityName = "testtest" authorityName := "testtest"
testCases := []struct { testCases := []struct {
name string name string
args []string args []string
@ -289,7 +289,7 @@ func (s *IntegrationTestSuite) TestGetCmdReserveName() {
func (s *IntegrationTestSuite) TestGetCmdSetName() { func (s *IntegrationTestSuite) TestGetCmdSetName() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()
var authorityName = "TestGetCmdSetName" authorityName := "TestGetCmdSetName"
testCases := []struct { testCases := []struct {
name string name string
args []string args []string
@ -307,7 +307,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetName() {
}, },
true, true,
func(authorityName string) { func(authorityName string) {
}, },
}, },
{ {
@ -394,7 +393,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetName() {
func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() { func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()
var authorityName = "TestGetCmdSetAuthorityBond" authorityName := "TestGetCmdSetAuthorityBond"
testCases := []struct { testCases := []struct {
name string name string
@ -413,7 +412,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() {
}, },
true, true,
func(authorityName string) { func(authorityName string) {
}, },
}, },
{ {
@ -480,7 +478,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() {
func (s *IntegrationTestSuite) TestGetCmdDeleteName() { func (s *IntegrationTestSuite) TestGetCmdDeleteName() {
val := s.network.Validators[0] val := s.network.Validators[0]
sr := s.Require() sr := s.Require()
var authorityName = "TestGetCmdDeleteName" authorityName := "TestGetCmdDeleteName"
testCasesForDeletingName := []struct { testCasesForDeletingName := []struct {
name string name string
args []string args []string
@ -498,7 +496,6 @@ func (s *IntegrationTestSuite) TestGetCmdDeleteName() {
}, },
true, true,
func(authorityName string, s *IntegrationTestSuite) { func(authorityName string, s *IntegrationTestSuite) {
}, },
}, },
{ {
@ -564,7 +561,6 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() {
return "" return ""
}, },
func(recordId string, s *IntegrationTestSuite) { func(recordId string, s *IntegrationTestSuite) {
}, },
}, },
{ {
@ -807,7 +803,6 @@ func (s *IntegrationTestSuite) TestGetCmdAssociateBond() {
return "", "" return "", ""
}, },
func(recordId, bondId string, s *IntegrationTestSuite) { func(recordId, bondId string, s *IntegrationTestSuite) {
}, },
}, },
{ {

View File

@ -17,7 +17,6 @@ func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data types.GenesisState)
// Add to record expiry queue if expiry time is in the future. // Add to record expiry queue if expiry time is in the future.
expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime) expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -33,7 +32,7 @@ func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data types.GenesisState)
} }
for _, authority := range data.Authorities { for _, authority := range data.Authorities {
//Only import authorities that are marked active. // Only import authorities that are marked active.
if authority.Entry.Status == types.AuthorityActive { if authority.Entry.Status == types.AuthorityActive {
keeper.SetNameAuthority(ctx, authority.Name, authority.Entry) keeper.SetNameAuthority(ctx, authority.Name, authority.Entry)

View File

@ -7,11 +7,10 @@ import (
"encoding/gob" "encoding/gob"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"sort"
wnsUtils "github.com/cerc-io/laconicd/utils" wnsUtils "github.com/cerc-io/laconicd/utils"
set "github.com/deckarep/golang-set" set "github.com/deckarep/golang-set"
"sort"
) )
func StringToBytes(val string) []byte { func StringToBytes(val string) []byte {
@ -62,7 +61,6 @@ func MarshalMapToJSONBytes(val map[string]interface{}) (bytes []byte) {
func UnMarshalMapFromJSONBytes(bytes []byte) map[string]interface{} { func UnMarshalMapFromJSONBytes(bytes []byte) map[string]interface{} {
var val map[string]interface{} var val map[string]interface{}
err := json.Unmarshal(bytes, &val) err := json.Unmarshal(bytes, &val)
if err != nil { if err != nil {
panic("Marshal error.") panic("Marshal error.")
} }

View File

@ -220,7 +220,7 @@ func (suite *KeeperTestSuite) TestGrpcQueryNameserviceModuleBalance() {
func (suite *KeeperTestSuite) TestGrpcQueryWhoIS() { func (suite *KeeperTestSuite) TestGrpcQueryWhoIS() {
grpcClient, ctx := suite.queryClient, suite.ctx grpcClient, ctx := suite.queryClient, suite.ctx
sr := suite.Require() sr := suite.Require()
var authorityName = "TestGrpcQueryWhoIS" authorityName := "TestGrpcQueryWhoIS"
testCases := []struct { testCases := []struct {
msg string msg string

View File

@ -73,7 +73,8 @@ type Keeper struct {
// NewKeeper creates new instances of the nameservice Keeper // NewKeeper creates new instances of the nameservice Keeper
func NewKeeper(cdc codec.BinaryCodec, accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, recordKeeper RecordKeeper, func NewKeeper(cdc codec.BinaryCodec, accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, recordKeeper RecordKeeper,
bondKeeper bondkeeper.Keeper, auctionKeeper auctionkeeper.Keeper, storeKey storetypes.StoreKey, ps paramtypes.Subspace) Keeper { bondKeeper bondkeeper.Keeper, auctionKeeper auctionkeeper.Keeper, storeKey storetypes.StoreKey, ps paramtypes.Subspace,
) Keeper {
// set KeyTable if it has not already been set // set KeyTable if it has not already been set
if !ps.HasKeyTable() { if !ps.HasKeyTable() {
ps = ps.WithKeyTable(types.ParamKeyTable()) ps = ps.WithKeyTable(types.ParamKeyTable())
@ -295,7 +296,6 @@ func (k Keeper) GetRecordExpiryQueueTimeSlice(ctx sdk.Context, timestamp time.Ti
// InsertRecordExpiryQueue inserts a record CID to the appropriate timeslice in the record expiry queue. // InsertRecordExpiryQueue inserts a record CID to the appropriate timeslice in the record expiry queue.
func (k Keeper) InsertRecordExpiryQueue(ctx sdk.Context, val types.Record) { func (k Keeper) InsertRecordExpiryQueue(ctx sdk.Context, val types.Record) {
expiryTime, err := time.Parse(time.RFC3339, val.ExpiryTime) expiryTime, err := time.Parse(time.RFC3339, val.ExpiryTime)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -308,7 +308,6 @@ func (k Keeper) InsertRecordExpiryQueue(ctx sdk.Context, val types.Record) {
// DeleteRecordExpiryQueue deletes a record CID from the record expiry queue. // DeleteRecordExpiryQueue deletes a record CID from the record expiry queue.
func (k Keeper) DeleteRecordExpiryQueue(ctx sdk.Context, record types.Record) { func (k Keeper) DeleteRecordExpiryQueue(ctx sdk.Context, record types.Record) {
expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime) expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -344,7 +343,6 @@ func (k Keeper) GetAllExpiredRecords(ctx sdk.Context, currTime time.Time) (expir
for ; itr.Valid(); itr.Next() { for ; itr.Valid(); itr.Next() {
timeslice, err := helpers.BytesArrToStringArr(itr.Value()) timeslice, err := helpers.BytesArrToStringArr(itr.Value())
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -426,7 +424,6 @@ func recordObjToRecord(store sdk.KVStore, codec codec.BinaryCodec, record types.
if store.Has(reverseNameIndexKey) { if store.Has(reverseNameIndexKey) {
names, err := helpers.BytesArrToStringArr(store.Get(reverseNameIndexKey)) names, err := helpers.BytesArrToStringArr(store.Get(reverseNameIndexKey))
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -17,9 +17,7 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
) )
var ( var seed = int64(233)
seed = int64(233)
)
type KeeperTestSuite struct { type KeeperTestSuite struct {
suite.Suite suite.Suite

View File

@ -51,6 +51,7 @@ func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types
return &types.MsgSetRecordResponse{Id: record.Id}, nil return &types.MsgSetRecordResponse{Id: record.Id}, nil
} }
//nolint: all
func (m msgServer) SetName(c context.Context, msg *types.MsgSetName) (*types.MsgSetNameResponse, error) { func (m msgServer) SetName(c context.Context, msg *types.MsgSetName) (*types.MsgSetNameResponse, error) {
ctx := sdk.UnwrapSDKContext(c) ctx := sdk.UnwrapSDKContext(c)
_, err := sdk.AccAddressFromBech32(msg.Signer) _, err := sdk.AccAddressFromBech32(msg.Signer)
@ -107,6 +108,7 @@ func (m msgServer) ReserveName(c context.Context, msg *types.MsgReserveAuthority
return &types.MsgReserveAuthorityResponse{}, nil return &types.MsgReserveAuthorityResponse{}, nil
} }
//nolint: all
func (m msgServer) SetAuthorityBond(c context.Context, msg *types.MsgSetAuthorityBond) (*types.MsgSetAuthorityBondResponse, error) { func (m msgServer) SetAuthorityBond(c context.Context, msg *types.MsgSetAuthorityBond) (*types.MsgSetAuthorityBondResponse, error) {
ctx := sdk.UnwrapSDKContext(c) ctx := sdk.UnwrapSDKContext(c)
_, err := sdk.AccAddressFromBech32(msg.Signer) _, err := sdk.AccAddressFromBech32(msg.Signer)
@ -180,6 +182,7 @@ func (m msgServer) RenewRecord(c context.Context, msg *types.MsgRenewRecord) (*t
return &types.MsgRenewRecordResponse{}, nil return &types.MsgRenewRecordResponse{}, nil
} }
//nolint: all
func (m msgServer) AssociateBond(c context.Context, msg *types.MsgAssociateBond) (*types.MsgAssociateBondResponse, error) { func (m msgServer) AssociateBond(c context.Context, msg *types.MsgAssociateBond) (*types.MsgAssociateBondResponse, error) {
ctx := sdk.UnwrapSDKContext(c) ctx := sdk.UnwrapSDKContext(c)
_, err := sdk.AccAddressFromBech32(msg.Signer) _, err := sdk.AccAddressFromBech32(msg.Signer)

View File

@ -653,7 +653,6 @@ func (k Keeper) GetAllExpiredAuthorities(ctx sdk.Context, currTime time.Time) (e
for ; itr.Valid(); itr.Next() { for ; itr.Valid(); itr.Next() {
timeslice := []string{} timeslice := []string{}
timeslice, err := helpers.BytesArrToStringArr(itr.Value()) timeslice, err := helpers.BytesArrToStringArr(itr.Value())
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -89,8 +89,10 @@ func (k RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionID string)
} }
// Record keeper implements the bond usage keeper interface. // Record keeper implements the bond usage keeper interface.
var _ bondtypes.BondUsageKeeper = (*RecordKeeper)(nil) var (
var _ auctiontypes.AuctionUsageKeeper = (*RecordKeeper)(nil) _ bondtypes.BondUsageKeeper = (*RecordKeeper)(nil)
_ auctiontypes.AuctionUsageKeeper = (*RecordKeeper)(nil)
)
// ModuleName returns the module name. // ModuleName returns the module name.
func (k RecordKeeper) ModuleName() string { func (k RecordKeeper) ModuleName() string {
@ -162,7 +164,6 @@ func (k Keeper) ProcessRenewRecord(ctx sdk.Context, msg types.MsgRenewRecord) er
// Check if renewal is required (i.e. expired record marked as deleted). // Check if renewal is required (i.e. expired record marked as deleted).
record := k.GetRecord(ctx, msg.RecordId) record := k.GetRecord(ctx, msg.RecordId)
expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime) expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -182,7 +183,6 @@ func (k Keeper) ProcessRenewRecord(ctx sdk.Context, msg types.MsgRenewRecord) er
// ProcessAssociateBond associates a record with a bond. // ProcessAssociateBond associates a record with a bond.
func (k Keeper) ProcessAssociateBond(ctx sdk.Context, msg types.MsgAssociateBond) error { func (k Keeper) ProcessAssociateBond(ctx sdk.Context, msg types.MsgAssociateBond) error {
if !k.HasRecord(ctx, msg.RecordId) { if !k.HasRecord(ctx, msg.RecordId) {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Record not found.") return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Record not found.")
} }

View File

@ -106,7 +106,6 @@ func (am AppModule) LegacyQuerierHandler(amino *codec.LegacyAmino) sdk.Querier {
} }
func (am AppModule) RegisterServices(cfg module.Configurator) { func (am AppModule) RegisterServices(cfg module.Configurator) {
querier := keeper.Querier{Keeper: am.keeper} querier := keeper.Querier{Keeper: am.keeper}
types.RegisterQueryServer(cfg.QueryServer(), querier) types.RegisterQueryServer(cfg.QueryServer(), querier)

View File

@ -31,7 +31,6 @@ func (msg MsgSetName) Type() string { return "set-name" }
// ValidateBasic Implements Msg. // ValidateBasic Implements Msg.
func (msg MsgSetName) ValidateBasic() error { func (msg MsgSetName) ValidateBasic() error {
if msg.Crn == "" { if msg.Crn == "" {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "CRN is required.") return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "CRN is required.")
} }
@ -76,7 +75,6 @@ func (msg MsgReserveAuthority) Type() string { return "reserve-authority" }
// ValidateBasic Implements Msg. // ValidateBasic Implements Msg.
func (msg MsgReserveAuthority) ValidateBasic() error { func (msg MsgReserveAuthority) ValidateBasic() error {
if len(msg.Name) == 0 { if len(msg.Name) == 0 {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "name is required.") return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "name is required.")
} }

View File

@ -3,9 +3,10 @@ package types
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"time"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"time"
) )
// Default parameter values. // Default parameter values.
@ -75,8 +76,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
func NewParams(recordRent sdk.Coin, recordRentDuration time.Duration, func NewParams(recordRent sdk.Coin, recordRentDuration time.Duration,
authorityRent sdk.Coin, authorityRentDuration time.Duration, authorityGracePeriod time.Duration, authorityRent sdk.Coin, authorityRentDuration time.Duration, authorityGracePeriod time.Duration,
authorityAuctionEnabled bool, commitsDuration time.Duration, revealsDuration time.Duration, authorityAuctionEnabled bool, commitsDuration time.Duration, revealsDuration time.Duration,
commitFee sdk.Coin, revealFee sdk.Coin, minimumBid sdk.Coin) Params { commitFee sdk.Coin, revealFee sdk.Coin, minimumBid sdk.Coin,
) Params {
return Params{ return Params{
RecordRent: recordRent, RecordRent: recordRent,
RecordRentDuration: recordRentDuration, RecordRentDuration: recordRentDuration,

View File

@ -22,7 +22,7 @@ type PayloadType struct {
// ToPayload converts PayloadType to Payload object. // ToPayload converts PayloadType to Payload object.
// Why? Because go-amino can't handle maps: https://github.com/tendermint/go-amino/issues/4. // Why? Because go-amino can't handle maps: https://github.com/tendermint/go-amino/issues/4.
func (payloadObj *PayloadType) ToPayload() Payload { func (payloadObj *PayloadType) ToPayload() Payload {
var payload = Payload{ payload := Payload{
Record: &Record{ Record: &Record{
Deleted: false, Deleted: false,
Owners: nil, Owners: nil,