From 573ced52331f0e89b3a5912077de482bcb6eaf17 Mon Sep 17 00:00:00 2001 From: Shrenuj Bansal Date: Wed, 20 Nov 2024 17:14:33 -0500 Subject: [PATCH] fuck you mockery Signed-off-by: Shrenuj Bansal --- .../src/codegen/dydxprotocol/prices/query.ts | 20 +++- proto/dydxprotocol/perpetuals/query.proto | 3 +- proto/dydxprotocol/prices/query.proto | 6 +- protocol/mocks/ClobKeeper.go | 5 + protocol/mocks/PerpetualsKeeper.go | 42 ++----- protocol/mocks/PricesKeeper.go | 5 + protocol/mocks/QueryClient.go | 111 ++++++++++++++++++ protocol/mocks/QueryServer.go | 30 +++++ protocol/x/prices/types/query.pb.go | 3 +- 9 files changed, 182 insertions(+), 43 deletions(-) diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/prices/query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/prices/query.ts index 2730923e0f0..525f64b6b0a 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/prices/query.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/prices/query.ts @@ -157,16 +157,28 @@ export interface QueryNextMarketIdRequest {} /** QueryNextMarketIdRequest is request type for the Query/Params `NextMarketId` */ export interface QueryNextMarketIdRequestSDKType {} -/** QueryNextMarketIdResponse is response type for the Query/Params `NextMarketId` */ +/** + * QueryNextMarketIdResponse is response type for the Query/Params + * `NextMarketId` + */ export interface QueryNextMarketIdResponse { - /** QueryNextMarketIdResponse is response type for the Query/Params `NextMarketId` */ + /** + * QueryNextMarketIdResponse is response type for the Query/Params + * `NextMarketId` + */ nextMarketId: number; } -/** QueryNextMarketIdResponse is response type for the Query/Params `NextMarketId` */ +/** + * QueryNextMarketIdResponse is response type for the Query/Params + * `NextMarketId` + */ export interface QueryNextMarketIdResponseSDKType { - /** QueryNextMarketIdResponse is response type for the Query/Params `NextMarketId` */ + /** + * QueryNextMarketIdResponse is response type for the Query/Params + * `NextMarketId` + */ next_market_id: number; } diff --git a/proto/dydxprotocol/perpetuals/query.proto b/proto/dydxprotocol/perpetuals/query.proto index b849a707fd5..b69c4420504 100644 --- a/proto/dydxprotocol/perpetuals/query.proto +++ b/proto/dydxprotocol/perpetuals/query.proto @@ -46,7 +46,8 @@ service Query { } // Queries the next perpetual id. - rpc NextPerpetualId(QueryNextPerpetualIdRequest) returns (QueryNextPerpetualIdResponse) { + rpc NextPerpetualId(QueryNextPerpetualIdRequest) + returns (QueryNextPerpetualIdResponse) { option (google.api.http).get = "/dydxprotocol/perpetuals/next_perpetual_id"; } } diff --git a/proto/dydxprotocol/prices/query.proto b/proto/dydxprotocol/prices/query.proto index 1fc4ef1f07f..fc55b304e85 100644 --- a/proto/dydxprotocol/prices/query.proto +++ b/proto/dydxprotocol/prices/query.proto @@ -34,7 +34,8 @@ service Query { } // Queries the next market id. - rpc NextMarketId(QueryNextMarketIdRequest) returns (QueryNextMarketIdResponse) { + rpc NextMarketId(QueryNextMarketIdRequest) + returns (QueryNextMarketIdResponse) { option (google.api.http).get = "/dydxprotocol/prices/next_market_id"; } } @@ -88,5 +89,6 @@ message QueryAllMarketParamsResponse { // QueryNextMarketIdRequest is request type for the Query/Params `NextMarketId` message QueryNextMarketIdRequest {} -// QueryNextMarketIdResponse is response type for the Query/Params `NextMarketId` +// QueryNextMarketIdResponse is response type for the Query/Params +// `NextMarketId` message QueryNextMarketIdResponse { uint32 next_market_id = 1; } diff --git a/protocol/mocks/ClobKeeper.go b/protocol/mocks/ClobKeeper.go index 2a7b5cfd9ce..4b786d6b814 100644 --- a/protocol/mocks/ClobKeeper.go +++ b/protocol/mocks/ClobKeeper.go @@ -1134,6 +1134,11 @@ func (_m *ClobKeeper) SetLongTermOrderPlacement(ctx types.Context, order clobtyp _m.Called(ctx, order, blockHeight) } +// SetNextClobPairID provides a mock function with given fields: ctx, nextID +func (_m *ClobKeeper) SetNextClobPairID(ctx types.Context, nextID uint32) { + _m.Called(ctx, nextID) +} + // UnsafeMigrateOrderExpirationState provides a mock function with given fields: ctx func (_m *ClobKeeper) UnsafeMigrateOrderExpirationState(ctx types.Context) { _m.Called(ctx) diff --git a/protocol/mocks/PerpetualsKeeper.go b/protocol/mocks/PerpetualsKeeper.go index 38721a5f1e9..1fb70624c46 100644 --- a/protocol/mocks/PerpetualsKeeper.go +++ b/protocol/mocks/PerpetualsKeeper.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.44.1. DO NOT EDIT. +// Code generated by mockery v2.46.0. DO NOT EDIT. package mocks @@ -122,34 +122,6 @@ func (_m *PerpetualsKeeper) GetAllPerpetuals(ctx types.Context) []perpetualstype return r0 } -// GetLiquidityTier provides a mock function with given fields: ctx, id -func (_m *PerpetualsKeeper) GetLiquidityTier(ctx types.Context, id uint32) (perpetualstypes.LiquidityTier, error) { - ret := _m.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for GetLiquidityTier") - } - - var r0 perpetualstypes.LiquidityTier - var r1 error - if rf, ok := ret.Get(0).(func(types.Context, uint32) (perpetualstypes.LiquidityTier, error)); ok { - return rf(ctx, id) - } - if rf, ok := ret.Get(0).(func(types.Context, uint32) perpetualstypes.LiquidityTier); ok { - r0 = rf(ctx, id) - } else { - r0 = ret.Get(0).(perpetualstypes.LiquidityTier) - } - - if rf, ok := ret.Get(1).(func(types.Context, uint32) error); ok { - r1 = rf(ctx, id) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // GetNetCollateral provides a mock function with given fields: ctx, id, bigQuantums func (_m *PerpetualsKeeper) GetNetCollateral(ctx types.Context, id uint32, bigQuantums *big.Int) (*big.Int, error) { ret := _m.Called(ctx, id, bigQuantums) @@ -360,11 +332,6 @@ func (_m *PerpetualsKeeper) PerformStatefulPremiumVotesValidation(ctx types.Cont return r0 } -// SendOIUpdatesToIndexer provides a mock function with given fields: ctx -func (_m *PerpetualsKeeper) SendOIUpdatesToIndexer(ctx types.Context) { - _m.Called(ctx) -} - // SetLiquidityTier provides a mock function with given fields: ctx, id, name, initialMarginPpm, maintenanceFractionPpm, impactNotional, openInterestLowerCap, openInterestUpperCap func (_m *PerpetualsKeeper) SetLiquidityTier(ctx types.Context, id uint32, name string, initialMarginPpm uint32, maintenanceFractionPpm uint32, impactNotional uint64, openInterestLowerCap uint64, openInterestUpperCap uint64) (perpetualstypes.LiquidityTier, error) { ret := _m.Called(ctx, id, name, initialMarginPpm, maintenanceFractionPpm, impactNotional, openInterestLowerCap, openInterestUpperCap) @@ -393,6 +360,11 @@ func (_m *PerpetualsKeeper) SetLiquidityTier(ctx types.Context, id uint32, name return r0, r1 } +// SetNextPerpetualID provides a mock function with given fields: ctx, nextID +func (_m *PerpetualsKeeper) SetNextPerpetualID(ctx types.Context, nextID uint32) { + _m.Called(ctx, nextID) +} + // SetParams provides a mock function with given fields: ctx, params func (_m *PerpetualsKeeper) SetParams(ctx types.Context, params perpetualstypes.Params) error { ret := _m.Called(ctx, params) @@ -469,4 +441,4 @@ func NewPerpetualsKeeper(t interface { t.Cleanup(func() { mock.AssertExpectations(t) }) return mock -} \ No newline at end of file +} diff --git a/protocol/mocks/PricesKeeper.go b/protocol/mocks/PricesKeeper.go index 4776407623a..6f7a5121191 100644 --- a/protocol/mocks/PricesKeeper.go +++ b/protocol/mocks/PricesKeeper.go @@ -418,6 +418,11 @@ func (_m *PricesKeeper) PerformStatefulPriceUpdateValidation(ctx types.Context, return r0 } +// SetNextMarketID provides a mock function with given fields: ctx, nextID +func (_m *PricesKeeper) SetNextMarketID(ctx types.Context, nextID uint32) { + _m.Called(ctx, nextID) +} + // UpdateMarketPrices provides a mock function with given fields: ctx, updates func (_m *PricesKeeper) UpdateMarketPrices(ctx types.Context, updates []*pricestypes.MsgUpdateMarketPrices_MarketPrice) error { ret := _m.Called(ctx, updates) diff --git a/protocol/mocks/QueryClient.go b/protocol/mocks/QueryClient.go index e8c611ebb3e..862029d0bda 100644 --- a/protocol/mocks/QueryClient.go +++ b/protocol/mocks/QueryClient.go @@ -696,6 +696,117 @@ func (_m *QueryClient) MevNodeToNodeCalculation(ctx context.Context, in *clobtyp return r0, r1 } +// NextClobPairId provides a mock function with given fields: ctx, in, opts +func (_m *QueryClient) NextClobPairId(ctx context.Context, in *clobtypes.QueryNextClobPairIdRequest, opts ...grpc.CallOption) (*clobtypes.QueryNextClobPairIdResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for NextClobPairId") + } + + var r0 *clobtypes.QueryNextClobPairIdResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *clobtypes.QueryNextClobPairIdRequest, ...grpc.CallOption) (*clobtypes.QueryNextClobPairIdResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *clobtypes.QueryNextClobPairIdRequest, ...grpc.CallOption) *clobtypes.QueryNextClobPairIdResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*clobtypes.QueryNextClobPairIdResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *clobtypes.QueryNextClobPairIdRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NextMarketId provides a mock function with given fields: ctx, in, opts +func (_m *QueryClient) NextMarketId(ctx context.Context, in *pricestypes.QueryNextMarketIdRequest, opts ...grpc.CallOption) (*pricestypes.QueryNextMarketIdResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for NextMarketId") + } + + var r0 *pricestypes.QueryNextMarketIdResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *pricestypes.QueryNextMarketIdRequest, ...grpc.CallOption) (*pricestypes.QueryNextMarketIdResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *pricestypes.QueryNextMarketIdRequest, ...grpc.CallOption) *pricestypes.QueryNextMarketIdResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*pricestypes.QueryNextMarketIdResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *pricestypes.QueryNextMarketIdRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NextPerpetualId provides a mock function with given fields: ctx, in, opts +func (_m *QueryClient) NextPerpetualId(ctx context.Context, in *perpetualstypes.QueryNextPerpetualIdRequest, opts ...grpc.CallOption) (*perpetualstypes.QueryNextPerpetualIdResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for NextPerpetualId") + } + + var r0 *perpetualstypes.QueryNextPerpetualIdResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *perpetualstypes.QueryNextPerpetualIdRequest, ...grpc.CallOption) (*perpetualstypes.QueryNextPerpetualIdResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *perpetualstypes.QueryNextPerpetualIdRequest, ...grpc.CallOption) *perpetualstypes.QueryNextPerpetualIdResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*perpetualstypes.QueryNextPerpetualIdResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *perpetualstypes.QueryNextPerpetualIdRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // Params provides a mock function with given fields: ctx, in, opts func (_m *QueryClient) Params(ctx context.Context, in *perpetualstypes.QueryParamsRequest, opts ...grpc.CallOption) (*perpetualstypes.QueryParamsResponse, error) { _va := make([]interface{}, len(opts)) diff --git a/protocol/mocks/QueryServer.go b/protocol/mocks/QueryServer.go index 4a7770a9204..2e1187a66b5 100644 --- a/protocol/mocks/QueryServer.go +++ b/protocol/mocks/QueryServer.go @@ -135,6 +135,36 @@ func (_m *QueryServer) MarketPrice(_a0 context.Context, _a1 *types.QueryMarketPr return r0, r1 } +// NextMarketId provides a mock function with given fields: _a0, _a1 +func (_m *QueryServer) NextMarketId(_a0 context.Context, _a1 *types.QueryNextMarketIdRequest) (*types.QueryNextMarketIdResponse, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for NextMarketId") + } + + var r0 *types.QueryNextMarketIdResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *types.QueryNextMarketIdRequest) (*types.QueryNextMarketIdResponse, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, *types.QueryNextMarketIdRequest) *types.QueryNextMarketIdResponse); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.QueryNextMarketIdResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *types.QueryNextMarketIdRequest) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // NewQueryServer creates a new instance of QueryServer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewQueryServer(t interface { diff --git a/protocol/x/prices/types/query.pb.go b/protocol/x/prices/types/query.pb.go index 9a5129fd11f..dabafa61970 100644 --- a/protocol/x/prices/types/query.pb.go +++ b/protocol/x/prices/types/query.pb.go @@ -451,7 +451,8 @@ func (m *QueryNextMarketIdRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryNextMarketIdRequest proto.InternalMessageInfo -// QueryNextMarketIdResponse is response type for the Query/Params `NextMarketId` +// QueryNextMarketIdResponse is response type for the Query/Params +// `NextMarketId` type QueryNextMarketIdResponse struct { NextMarketId uint32 `protobuf:"varint,1,opt,name=next_market_id,json=nextMarketId,proto3" json:"next_market_id,omitempty"` }