feat: attribute typing (#40)

* marshal and unmarshal

* attributes proto

* fix

* process attributes and create secondary mappings

* get records from attributes

* fix

* fix lint errors

* fix gosec

* lower case

* go mod tidy

* Fix tests

* "add search test"

* req attributes

* grpc tests

* fix tests

* register interface

* fix tests

* Remove git diff from test workflows

* fix workflow file

* fix simulations

* fix names and add checks for attributes in tests

* Add comment for attribute prefix
This commit is contained in:
Murali Krishna Komatireddy
2022-11-15 11:51:14 +05:30
committed by GitHub
parent 72ec75a857
commit 6b04c0ee5e
35 changed files with 2187 additions and 601 deletions
+4 -4
View File
@@ -162,7 +162,7 @@ func (s *IntegrationTestSuite) TestGRPCGetBondByID() {
// extract bond id from bonds list
bond := queryResponse.GetBonds()[0]
return bond.GetID()
return bond.GetId()
},
},
}
@@ -181,11 +181,11 @@ func (s *IntegrationTestSuite) TestGRPCGetBondByID() {
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &bonds)
if tc.expErr {
sr.Empty(bonds.GetBond().GetID())
sr.Empty(bonds.GetBond().GetId())
} else {
sr.NoError(err)
sr.NotZero(bonds.GetBond().GetID())
sr.Equal(bonds.GetBond().GetID(), bondID)
sr.NotZero(bonds.GetBond().GetId())
sr.Equal(bonds.GetBond().GetId(), bondID)
}
})
}
+3 -3
View File
@@ -205,7 +205,7 @@ func (s *IntegrationTestSuite) TestGetQueryBondByID() {
// extract bond id from bonds list
bond := queryResponse.GetBonds()[0]
return bond.GetID()
return bond.GetId()
},
},
}
@@ -225,9 +225,9 @@ func (s *IntegrationTestSuite) TestGetQueryBondByID() {
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
sr.NoError(err)
if tc.err {
sr.Zero(len(queryResponse.GetBond().GetID()))
sr.Zero(len(queryResponse.GetBond().GetId()))
} else {
sr.NotZero(len(queryResponse.GetBond().GetID()))
sr.NotZero(len(queryResponse.GetBond().GetId()))
sr.Equal(s.accountAddress, queryResponse.GetBond().GetOwner())
}
})
+4 -4
View File
@@ -118,7 +118,7 @@ func (s *IntegrationTestSuite) TestTxRefillBond() {
// extract bond id from bonds list
bond := queryResponse.GetBonds()[0]
tc.args = append([]string{bond.GetID()}, tc.args...)
tc.args = append([]string{bond.GetId()}, tc.args...)
}
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.err {
@@ -204,7 +204,7 @@ func (s *IntegrationTestSuite) TestTxWithdrawAmountFromBond() {
// extract bond id from bonds list
bond := queryResponse.GetBonds()[0]
tc.args = append([]string{bond.GetID()}, tc.args...)
tc.args = append([]string{bond.GetId()}, tc.args...)
}
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.err {
@@ -288,7 +288,7 @@ func (s *IntegrationTestSuite) TestTxCancelBond() {
// extract bond id from bonds list
bond := queryResponse.GetBonds()[0]
tc.args = append([]string{bond.GetID()}, tc.args...)
tc.args = append([]string{bond.GetId()}, tc.args...)
}
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.err {
@@ -312,7 +312,7 @@ func (s *IntegrationTestSuite) TestTxCancelBond() {
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
sr.NoError(err)
sr.Zero(queryResponse.GetBond().GetID())
sr.Zero(queryResponse.GetBond().GetId())
}
})
}
+2 -2
View File
@@ -28,11 +28,11 @@ func (q Querier) Params(c context.Context, _ *types.QueryParamsRequest) (*types.
func (q Querier) GetBondByID(c context.Context, req *types.QueryGetBondByIDRequest) (*types.QueryGetBondByIDResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
bondID := req.GetID()
bondID := req.GetId()
if len(bondID) == 0 {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "bond id required")
}
bond := q.Keeper.GetBond(ctx, req.GetID())
bond := q.Keeper.GetBond(ctx, req.GetId())
return &types.QueryGetBondByIDResponse{Bond: &bond}, nil
}
+1 -1
View File
@@ -124,7 +124,7 @@ func (suite *KeeperTestSuite) TestGrpcQueryBondBondId() {
if !test.errResponse {
suiteRequire.Nil(err)
suiteRequire.NotNil(resp.GetBond())
suiteRequire.Equal(test.req.Id, resp.GetBond().GetID())
suiteRequire.Equal(test.req.Id, resp.GetBond().GetId())
} else {
suiteRequire.NotNil(err)
suiteRequire.Error(err)
+1 -1
View File
@@ -114,7 +114,7 @@ func (m *Bond) XXX_DiscardUnknown() {
var xxx_messageInfo_Bond proto.InternalMessageInfo
func (m *Bond) GetID() string {
func (m *Bond) GetId() string {
if m != nil {
return m.Id
}
+1 -1
View File
@@ -252,7 +252,7 @@ func (m *QueryGetBondByIDRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryGetBondByIDRequest proto.InternalMessageInfo
func (m *QueryGetBondByIDRequest) GetID() string {
func (m *QueryGetBondByIDRequest) GetId() string {
if m != nil {
return m.Id
}