diff --git a/docs/docs.go b/docs/docs.go index e11e52b..330c372 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -422,7 +422,7 @@ const docTemplate = `{ "200": { "description": "Staker delegation", "schema": { - "$ref": "#/definitions/handler.PublicResponse-v2service_StakerDelegationPublic" + "$ref": "#/definitions/handler.PublicResponse-v2service_DelegationPublic" } }, "400": { @@ -475,7 +475,7 @@ const docTemplate = `{ "200": { "description": "List of staker delegations and pagination token", "schema": { - "$ref": "#/definitions/handler.PublicResponse-array_v2service_StakerDelegationPublic" + "$ref": "#/definitions/handler.PublicResponse-array_v2service_DelegationPublic" } }, "400": { @@ -690,13 +690,13 @@ const docTemplate = `{ } } }, - "handler.PublicResponse-array_v2service_FinalityProviderStatsPublic": { + "handler.PublicResponse-array_v2service_DelegationPublic": { "type": "object", "properties": { "data": { "type": "array", "items": { - "$ref": "#/definitions/v2service.FinalityProviderStatsPublic" + "$ref": "#/definitions/v2service.DelegationPublic" } }, "pagination": { @@ -704,13 +704,13 @@ const docTemplate = `{ } } }, - "handler.PublicResponse-array_v2service_StakerDelegationPublic": { + "handler.PublicResponse-array_v2service_FinalityProviderStatsPublic": { "type": "object", "properties": { "data": { "type": "array", "items": { - "$ref": "#/definitions/v2service.StakerDelegationPublic" + "$ref": "#/definitions/v2service.FinalityProviderStatsPublic" } }, "pagination": { @@ -751,22 +751,22 @@ const docTemplate = `{ } } }, - "handler.PublicResponse-v2service_OverallStatsPublic": { + "handler.PublicResponse-v2service_DelegationPublic": { "type": "object", "properties": { "data": { - "$ref": "#/definitions/v2service.OverallStatsPublic" + "$ref": "#/definitions/v2service.DelegationPublic" }, "pagination": { "$ref": "#/definitions/handler.paginationResponse" } } }, - "handler.PublicResponse-v2service_StakerDelegationPublic": { + "handler.PublicResponse-v2service_OverallStatsPublic": { "type": "object", "properties": { "data": { - "$ref": "#/definitions/v2service.StakerDelegationPublic" + "$ref": "#/definitions/v2service.OverallStatsPublic" }, "pagination": { "$ref": "#/definitions/handler.paginationResponse" @@ -1164,6 +1164,32 @@ const docTemplate = `{ } } }, + "v2service.DelegationPublic": { + "type": "object", + "properties": { + "delegation_staking": { + "$ref": "#/definitions/v2service.DelegationStaking" + }, + "delegation_unbonding": { + "$ref": "#/definitions/v2service.DelegationUnbonding" + }, + "finality_provider_btc_pks_hex": { + "type": "array", + "items": { + "type": "string" + } + }, + "params_version": { + "type": "integer" + }, + "staker_btc_pk_hex": { + "type": "string" + }, + "state": { + "$ref": "#/definitions/v2types.DelegationState" + } + } + }, "v2service.DelegationStaking": { "type": "object", "properties": { @@ -1171,7 +1197,7 @@ const docTemplate = `{ "type": "integer" }, "bbn_inception_time": { - "type": "integer" + "type": "string" }, "end_height": { "type": "integer" @@ -1183,7 +1209,7 @@ const docTemplate = `{ "type": "integer" }, "staking_time": { - "type": "integer" + "type": "string" }, "staking_tx_hash_hex": { "type": "string" @@ -1209,7 +1235,7 @@ const docTemplate = `{ "type": "string" }, "unbonding_time": { - "type": "integer" + "type": "string" }, "unbonding_tx": { "type": "string" @@ -1256,6 +1282,9 @@ const docTemplate = `{ "active_delegations": { "type": "integer" }, + "active_finality_providers": { + "type": "integer" + }, "active_stakers": { "type": "integer" }, @@ -1265,6 +1294,9 @@ const docTemplate = `{ "total_delegations": { "type": "integer" }, + "total_finality_providers": { + "type": "integer" + }, "total_stakers": { "type": "integer" }, @@ -1290,32 +1322,6 @@ const docTemplate = `{ } } }, - "v2service.StakerDelegationPublic": { - "type": "object", - "properties": { - "delegation_staking": { - "$ref": "#/definitions/v2service.DelegationStaking" - }, - "delegation_unbonding": { - "$ref": "#/definitions/v2service.DelegationUnbonding" - }, - "finality_provider_btc_pks_hex": { - "type": "array", - "items": { - "type": "string" - } - }, - "params_version": { - "type": "integer" - }, - "staker_btc_pk_hex": { - "type": "string" - }, - "state": { - "$ref": "#/definitions/v2types.DelegationState" - } - } - }, "v2service.StakerStatsPublic": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index fc9ca86..9cbd1ed 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -414,7 +414,7 @@ "200": { "description": "Staker delegation", "schema": { - "$ref": "#/definitions/handler.PublicResponse-v2service_StakerDelegationPublic" + "$ref": "#/definitions/handler.PublicResponse-v2service_DelegationPublic" } }, "400": { @@ -467,7 +467,7 @@ "200": { "description": "List of staker delegations and pagination token", "schema": { - "$ref": "#/definitions/handler.PublicResponse-array_v2service_StakerDelegationPublic" + "$ref": "#/definitions/handler.PublicResponse-array_v2service_DelegationPublic" } }, "400": { @@ -682,13 +682,13 @@ } } }, - "handler.PublicResponse-array_v2service_FinalityProviderStatsPublic": { + "handler.PublicResponse-array_v2service_DelegationPublic": { "type": "object", "properties": { "data": { "type": "array", "items": { - "$ref": "#/definitions/v2service.FinalityProviderStatsPublic" + "$ref": "#/definitions/v2service.DelegationPublic" } }, "pagination": { @@ -696,13 +696,13 @@ } } }, - "handler.PublicResponse-array_v2service_StakerDelegationPublic": { + "handler.PublicResponse-array_v2service_FinalityProviderStatsPublic": { "type": "object", "properties": { "data": { "type": "array", "items": { - "$ref": "#/definitions/v2service.StakerDelegationPublic" + "$ref": "#/definitions/v2service.FinalityProviderStatsPublic" } }, "pagination": { @@ -743,22 +743,22 @@ } } }, - "handler.PublicResponse-v2service_OverallStatsPublic": { + "handler.PublicResponse-v2service_DelegationPublic": { "type": "object", "properties": { "data": { - "$ref": "#/definitions/v2service.OverallStatsPublic" + "$ref": "#/definitions/v2service.DelegationPublic" }, "pagination": { "$ref": "#/definitions/handler.paginationResponse" } } }, - "handler.PublicResponse-v2service_StakerDelegationPublic": { + "handler.PublicResponse-v2service_OverallStatsPublic": { "type": "object", "properties": { "data": { - "$ref": "#/definitions/v2service.StakerDelegationPublic" + "$ref": "#/definitions/v2service.OverallStatsPublic" }, "pagination": { "$ref": "#/definitions/handler.paginationResponse" @@ -1156,6 +1156,32 @@ } } }, + "v2service.DelegationPublic": { + "type": "object", + "properties": { + "delegation_staking": { + "$ref": "#/definitions/v2service.DelegationStaking" + }, + "delegation_unbonding": { + "$ref": "#/definitions/v2service.DelegationUnbonding" + }, + "finality_provider_btc_pks_hex": { + "type": "array", + "items": { + "type": "string" + } + }, + "params_version": { + "type": "integer" + }, + "staker_btc_pk_hex": { + "type": "string" + }, + "state": { + "$ref": "#/definitions/v2types.DelegationState" + } + } + }, "v2service.DelegationStaking": { "type": "object", "properties": { @@ -1163,7 +1189,7 @@ "type": "integer" }, "bbn_inception_time": { - "type": "integer" + "type": "string" }, "end_height": { "type": "integer" @@ -1175,7 +1201,7 @@ "type": "integer" }, "staking_time": { - "type": "integer" + "type": "string" }, "staking_tx_hash_hex": { "type": "string" @@ -1201,7 +1227,7 @@ "type": "string" }, "unbonding_time": { - "type": "integer" + "type": "string" }, "unbonding_tx": { "type": "string" @@ -1248,6 +1274,9 @@ "active_delegations": { "type": "integer" }, + "active_finality_providers": { + "type": "integer" + }, "active_stakers": { "type": "integer" }, @@ -1257,6 +1286,9 @@ "total_delegations": { "type": "integer" }, + "total_finality_providers": { + "type": "integer" + }, "total_stakers": { "type": "integer" }, @@ -1282,32 +1314,6 @@ } } }, - "v2service.StakerDelegationPublic": { - "type": "object", - "properties": { - "delegation_staking": { - "$ref": "#/definitions/v2service.DelegationStaking" - }, - "delegation_unbonding": { - "$ref": "#/definitions/v2service.DelegationUnbonding" - }, - "finality_provider_btc_pks_hex": { - "type": "array", - "items": { - "type": "string" - } - }, - "params_version": { - "type": "integer" - }, - "staker_btc_pk_hex": { - "type": "string" - }, - "state": { - "$ref": "#/definitions/v2types.DelegationState" - } - } - }, "v2service.StakerStatsPublic": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 21c8ec2..ef062a0 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -34,20 +34,20 @@ definitions: pagination: $ref: '#/definitions/handler.paginationResponse' type: object - handler.PublicResponse-array_v2service_FinalityProviderStatsPublic: + handler.PublicResponse-array_v2service_DelegationPublic: properties: data: items: - $ref: '#/definitions/v2service.FinalityProviderStatsPublic' + $ref: '#/definitions/v2service.DelegationPublic' type: array pagination: $ref: '#/definitions/handler.paginationResponse' type: object - handler.PublicResponse-array_v2service_StakerDelegationPublic: + handler.PublicResponse-array_v2service_FinalityProviderStatsPublic: properties: data: items: - $ref: '#/definitions/v2service.StakerDelegationPublic' + $ref: '#/definitions/v2service.FinalityProviderStatsPublic' type: array pagination: $ref: '#/definitions/handler.paginationResponse' @@ -73,17 +73,17 @@ definitions: pagination: $ref: '#/definitions/handler.paginationResponse' type: object - handler.PublicResponse-v2service_OverallStatsPublic: + handler.PublicResponse-v2service_DelegationPublic: properties: data: - $ref: '#/definitions/v2service.OverallStatsPublic' + $ref: '#/definitions/v2service.DelegationPublic' pagination: $ref: '#/definitions/handler.paginationResponse' type: object - handler.PublicResponse-v2service_StakerDelegationPublic: + handler.PublicResponse-v2service_OverallStatsPublic: properties: data: - $ref: '#/definitions/v2service.StakerDelegationPublic' + $ref: '#/definitions/v2service.OverallStatsPublic' pagination: $ref: '#/definitions/handler.paginationResponse' type: object @@ -347,12 +347,29 @@ definitions: signature_hex: type: string type: object + v2service.DelegationPublic: + properties: + delegation_staking: + $ref: '#/definitions/v2service.DelegationStaking' + delegation_unbonding: + $ref: '#/definitions/v2service.DelegationUnbonding' + finality_provider_btc_pks_hex: + items: + type: string + type: array + params_version: + type: integer + staker_btc_pk_hex: + type: string + state: + $ref: '#/definitions/v2types.DelegationState' + type: object v2service.DelegationStaking: properties: bbn_inception_height: type: integer bbn_inception_time: - type: integer + type: string end_height: type: integer slashing_tx_hex: @@ -360,7 +377,7 @@ definitions: staking_amount: type: integer staking_time: - type: integer + type: string staking_tx_hash_hex: type: string staking_tx_hex: @@ -377,7 +394,7 @@ definitions: slashing_tx_hex: type: string unbonding_time: - type: integer + type: string unbonding_tx: type: string type: object @@ -407,12 +424,16 @@ definitions: properties: active_delegations: type: integer + active_finality_providers: + type: integer active_stakers: type: integer active_tvl: type: integer total_delegations: type: integer + total_finality_providers: + type: integer total_stakers: type: integer total_tvl: @@ -429,23 +450,6 @@ definitions: $ref: '#/definitions/indexertypes.BtcCheckpointParams' type: array type: object - v2service.StakerDelegationPublic: - properties: - delegation_staking: - $ref: '#/definitions/v2service.DelegationStaking' - delegation_unbonding: - $ref: '#/definitions/v2service.DelegationUnbonding' - finality_provider_btc_pks_hex: - items: - type: string - type: array - params_version: - type: integer - staker_btc_pk_hex: - type: string - state: - $ref: '#/definitions/v2types.DelegationState' - type: object v2service.StakerStatsPublic: properties: active_delegations: @@ -785,7 +789,7 @@ paths: "200": description: Staker delegation schema: - $ref: '#/definitions/handler.PublicResponse-v2service_StakerDelegationPublic' + $ref: '#/definitions/handler.PublicResponse-v2service_DelegationPublic' "400": description: 'Error: Bad Request' schema: @@ -821,7 +825,7 @@ paths: "200": description: List of staker delegations and pagination token schema: - $ref: '#/definitions/handler.PublicResponse-array_v2service_StakerDelegationPublic' + $ref: '#/definitions/handler.PublicResponse-array_v2service_DelegationPublic' "400": description: 'Error: Bad Request' schema: diff --git a/internal/v2/api/handlers/delegation.go b/internal/v2/api/handlers/delegation.go index 1acfe57..d3b1e57 100644 --- a/internal/v2/api/handlers/delegation.go +++ b/internal/v2/api/handlers/delegation.go @@ -13,7 +13,7 @@ import ( // @Produce json // @Tags v2 // @Param staking_tx_hash_hex query string true "Staking transaction hash in hex format" -// @Success 200 {object} handler.PublicResponse[v2service.StakerDelegationPublic] "Staker delegation" +// @Success 200 {object} handler.PublicResponse[v2service.DelegationPublic] "Staker delegation" // @Failure 400 {object} types.Error "Error: Bad Request" // @Failure 404 {object} types.Error "Error: Not Found" // @Failure 500 {object} types.Error "Error: Internal Server Error" @@ -38,7 +38,7 @@ func (h *V2Handler) GetDelegation(request *http.Request) (*handler.Result, *type // @Tags v2 // @Param staker_pk_hex query string true "Staker public key in hex format" // @Param pagination_key query string false "Pagination key to fetch the next page of delegations" -// @Success 200 {object} handler.PublicResponse[[]v2service.StakerDelegationPublic]{array} "List of staker delegations and pagination token" +// @Success 200 {object} handler.PublicResponse[[]v2service.DelegationPublic]{array} "List of staker delegations and pagination token" // @Failure 400 {object} types.Error "Error: Bad Request" // @Failure 404 {object} types.Error "Error: Not Found" // @Failure 500 {object} types.Error "Error: Internal Server Error" diff --git a/internal/v2/service/delegation.go b/internal/v2/service/delegation.go index 5dd0335..8a1a0a2 100644 --- a/internal/v2/service/delegation.go +++ b/internal/v2/service/delegation.go @@ -7,6 +7,7 @@ import ( indexerdbmodel "github.com/babylonlabs-io/staking-api-service/internal/indexer/db/model" "github.com/babylonlabs-io/staking-api-service/internal/shared/db" "github.com/babylonlabs-io/staking-api-service/internal/shared/types" + "github.com/babylonlabs-io/staking-api-service/internal/shared/utils" v2types "github.com/babylonlabs-io/staking-api-service/internal/v2/types" "github.com/rs/zerolog/log" ) @@ -14,12 +15,12 @@ import ( type DelegationStaking struct { StakingTxHashHex string `json:"staking_tx_hash_hex"` StakingTxHex string `json:"staking_tx_hex"` - StakingTime uint32 `json:"staking_time"` + StakingTime string `json:"staking_time"` StakingAmount uint64 `json:"staking_amount"` StartHeight uint32 `json:"start_height,omitempty"` EndHeight uint32 `json:"end_height,omitempty"` BbnInceptionHeight int64 `json:"bbn_inception_height"` - BbnInceptionTime int64 `json:"bbn_inception_time"` + BbnInceptionTime string `json:"bbn_inception_time"` SlashingTxHex string `json:"slashing_tx_hex"` } @@ -29,13 +30,13 @@ type CovenantSignature struct { } type DelegationUnbonding struct { - UnbondingTime uint32 `json:"unbonding_time"` + UnbondingTime string `json:"unbonding_time"` UnbondingTx string `json:"unbonding_tx"` CovenantUnbondingSignatures []CovenantSignature `json:"covenant_unbonding_signatures"` SlashingTxHex string `json:"slashing_tx_hex"` } -type StakerDelegationPublic struct { +type DelegationPublic struct { ParamsVersion uint32 `json:"params_version"` StakerBtcPkHex string `json:"staker_btc_pk_hex"` FinalityProviderBtcPksHex []string `json:"finality_provider_btc_pks_hex"` @@ -44,38 +45,35 @@ type StakerDelegationPublic struct { State v2types.DelegationState `json:"state"` } -func (s *V2Service) GetDelegation(ctx context.Context, stakingTxHashHex string) (*StakerDelegationPublic, *types.Error) { - delegation, err := s.DbClients.IndexerDBClient.GetDelegation(ctx, stakingTxHashHex) - if err != nil { - if db.IsNotFoundError(err) { - log.Ctx(ctx).Warn().Err(err).Str("stakingTxHashHex", stakingTxHashHex).Msg("Staking delegation not found") - return nil, types.NewErrorWithMsg(http.StatusNotFound, types.NotFound, "staking delegation not found, please retry") - } - return nil, types.NewErrorWithMsg(http.StatusInternalServerError, types.InternalServiceError, "failed to get staker delegation") - } - +func FromDelegationDocument(delegation indexerdbmodel.IndexerDelegationDetails) (*DelegationPublic, *types.Error) { state, err := v2types.MapDelegationState(delegation.State, delegation.SubState) if err != nil { - return nil, types.NewErrorWithMsg(http.StatusInternalServerError, types.InternalServiceError, "failed to get delegation state") + return nil, types.NewErrorWithMsg( + http.StatusInternalServerError, + types.InternalServiceError, + "failed to get delegation state", + ) } - delegationPublic := &StakerDelegationPublic{ + delegationPublic := &DelegationPublic{ ParamsVersion: delegation.ParamsVersion, FinalityProviderBtcPksHex: delegation.FinalityProviderBtcPksHex, StakerBtcPkHex: delegation.StakerBtcPkHex, DelegationStaking: DelegationStaking{ StakingTxHashHex: delegation.StakingTxHashHex, StakingTxHex: delegation.StakingTxHex, - StakingTime: delegation.StakingTime, + StakingTime: utils.ParseTimestampToIsoFormat(int64(delegation.StakingTime)), StakingAmount: delegation.StakingAmount, StartHeight: delegation.StartHeight, EndHeight: delegation.EndHeight, BbnInceptionHeight: delegation.BTCDelegationCreatedBbnBlock.Height, - BbnInceptionTime: delegation.BTCDelegationCreatedBbnBlock.Timestamp, - SlashingTxHex: delegation.SlashingTxHex, + BbnInceptionTime: utils.ParseTimestampToIsoFormat( + delegation.BTCDelegationCreatedBbnBlock.Timestamp, + ), + SlashingTxHex: delegation.SlashingTxHex, }, DelegationUnbonding: DelegationUnbonding{ - UnbondingTime: delegation.UnbondingTime, + UnbondingTime: utils.ParseTimestampToIsoFormat(int64(delegation.UnbondingTime)), UnbondingTx: delegation.UnbondingTx, CovenantUnbondingSignatures: getUnbondingSignatures( delegation.CovenantUnbondingSignatures, @@ -84,10 +82,24 @@ func (s *V2Service) GetDelegation(ctx context.Context, stakingTxHashHex string) }, State: state, } + return delegationPublic, nil } -func (s *V2Service) GetDelegations(ctx context.Context, stakerPkHex string, paginationKey string) ([]*StakerDelegationPublic, string, *types.Error) { +func (s *V2Service) GetDelegation(ctx context.Context, stakingTxHashHex string) (*DelegationPublic, *types.Error) { + delegation, err := s.DbClients.IndexerDBClient.GetDelegation(ctx, stakingTxHashHex) + if err != nil { + if db.IsNotFoundError(err) { + log.Ctx(ctx).Warn().Err(err).Str("stakingTxHashHex", stakingTxHashHex).Msg("Staking delegation not found") + return nil, types.NewErrorWithMsg(http.StatusNotFound, types.NotFound, "staking delegation not found, please retry") + } + return nil, types.NewErrorWithMsg(http.StatusInternalServerError, types.InternalServiceError, "failed to get staker delegation") + } + + return FromDelegationDocument(*delegation) +} + +func (s *V2Service) GetDelegations(ctx context.Context, stakerPkHex string, paginationKey string) ([]*DelegationPublic, string, *types.Error) { resultMap, err := s.DbClients.IndexerDBClient.GetDelegations(ctx, stakerPkHex, paginationKey) if err != nil { if db.IsNotFoundError(err) { @@ -98,39 +110,13 @@ func (s *V2Service) GetDelegations(ctx context.Context, stakerPkHex string, pagi } // Initialize result structure - delegationsPublic := make([]*StakerDelegationPublic, 0, len(resultMap.Data)) + delegationsPublic := make([]*DelegationPublic, 0, len(resultMap.Data)) // Group delegations by state for _, delegation := range resultMap.Data { - state, err := v2types.MapDelegationState(delegation.State, delegation.SubState) - if err != nil { - return nil, "", types.NewErrorWithMsg(http.StatusInternalServerError, types.InternalServiceError, "failed to get delegation state") - } - - delegationPublic := &StakerDelegationPublic{ - ParamsVersion: delegation.ParamsVersion, - FinalityProviderBtcPksHex: delegation.FinalityProviderBtcPksHex, - StakerBtcPkHex: delegation.StakerBtcPkHex, - DelegationStaking: DelegationStaking{ - StakingTxHashHex: delegation.StakingTxHashHex, - StakingTxHex: delegation.StakingTxHex, - StakingTime: delegation.StakingTime, - StakingAmount: delegation.StakingAmount, - StartHeight: delegation.StartHeight, - EndHeight: delegation.EndHeight, - BbnInceptionHeight: delegation.BTCDelegationCreatedBbnBlock.Height, - BbnInceptionTime: delegation.BTCDelegationCreatedBbnBlock.Timestamp, - SlashingTxHex: delegation.SlashingTxHex, - }, - DelegationUnbonding: DelegationUnbonding{ - UnbondingTime: delegation.UnbondingTime, - UnbondingTx: delegation.UnbondingTx, - CovenantUnbondingSignatures: getUnbondingSignatures( - delegation.CovenantUnbondingSignatures, - ), - SlashingTxHex: delegation.UnbondingSlashingTxHex, - }, - State: state, + delegationPublic, delErr := FromDelegationDocument(delegation) + if delErr != nil { + return nil, "", delErr } delegationsPublic = append(delegationsPublic, delegationPublic) } diff --git a/internal/v2/service/interface.go b/internal/v2/service/interface.go index 8068622..2ace400 100644 --- a/internal/v2/service/interface.go +++ b/internal/v2/service/interface.go @@ -11,8 +11,8 @@ type V2ServiceProvider interface { []*FinalityProviderStatsPublic, *types.Error, ) GetNetworkInfo(ctx context.Context) (*NetworkInfoPublic, *types.Error) - GetDelegation(ctx context.Context, stakingTxHashHex string) (*StakerDelegationPublic, *types.Error) - GetDelegations(ctx context.Context, stakerPKHex string, paginationKey string) ([]*StakerDelegationPublic, string, *types.Error) + GetDelegation(ctx context.Context, stakingTxHashHex string) (*DelegationPublic, *types.Error) + GetDelegations(ctx context.Context, stakerPKHex string, paginationKey string) ([]*DelegationPublic, string, *types.Error) MarkV1DelegationAsTransitioned(ctx context.Context, stakingTxHashHex string) *types.Error GetOverallStats(ctx context.Context) (*OverallStatsPublic, *types.Error) GetStakerStats(ctx context.Context, stakerPKHex string) (*StakerStatsPublic, *types.Error) diff --git a/tests/mocks/mock_db_client.go b/tests/mocks/mock_db_client.go new file mode 100644 index 0000000..b247612 --- /dev/null +++ b/tests/mocks/mock_db_client.go @@ -0,0 +1,192 @@ +// Code generated by mockery v2.41.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + dbmodel "github.com/babylonlabs-io/staking-api-service/internal/shared/db/model" + + mock "github.com/stretchr/testify/mock" +) + +// DBClient is an autogenerated mock type for the DBClient type +type DBClient struct { + mock.Mock +} + +// DeleteUnprocessableMessage provides a mock function with given fields: ctx, Receipt +func (_m *DBClient) DeleteUnprocessableMessage(ctx context.Context, Receipt interface{}) error { + ret := _m.Called(ctx, Receipt) + + if len(ret) == 0 { + panic("no return value specified for DeleteUnprocessableMessage") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, interface{}) error); ok { + r0 = rf(ctx, Receipt) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// FindPkMappingsByNativeSegwitAddress provides a mock function with given fields: ctx, nativeSegwitAddresses +func (_m *DBClient) FindPkMappingsByNativeSegwitAddress(ctx context.Context, nativeSegwitAddresses []string) ([]*dbmodel.PkAddressMapping, error) { + ret := _m.Called(ctx, nativeSegwitAddresses) + + if len(ret) == 0 { + panic("no return value specified for FindPkMappingsByNativeSegwitAddress") + } + + var r0 []*dbmodel.PkAddressMapping + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, []string) ([]*dbmodel.PkAddressMapping, error)); ok { + return rf(ctx, nativeSegwitAddresses) + } + if rf, ok := ret.Get(0).(func(context.Context, []string) []*dbmodel.PkAddressMapping); ok { + r0 = rf(ctx, nativeSegwitAddresses) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dbmodel.PkAddressMapping) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []string) error); ok { + r1 = rf(ctx, nativeSegwitAddresses) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FindPkMappingsByTaprootAddress provides a mock function with given fields: ctx, taprootAddresses +func (_m *DBClient) FindPkMappingsByTaprootAddress(ctx context.Context, taprootAddresses []string) ([]*dbmodel.PkAddressMapping, error) { + ret := _m.Called(ctx, taprootAddresses) + + if len(ret) == 0 { + panic("no return value specified for FindPkMappingsByTaprootAddress") + } + + var r0 []*dbmodel.PkAddressMapping + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, []string) ([]*dbmodel.PkAddressMapping, error)); ok { + return rf(ctx, taprootAddresses) + } + if rf, ok := ret.Get(0).(func(context.Context, []string) []*dbmodel.PkAddressMapping); ok { + r0 = rf(ctx, taprootAddresses) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dbmodel.PkAddressMapping) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []string) error); ok { + r1 = rf(ctx, taprootAddresses) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FindUnprocessableMessages provides a mock function with given fields: ctx +func (_m *DBClient) FindUnprocessableMessages(ctx context.Context) ([]dbmodel.UnprocessableMessageDocument, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for FindUnprocessableMessages") + } + + var r0 []dbmodel.UnprocessableMessageDocument + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]dbmodel.UnprocessableMessageDocument, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []dbmodel.UnprocessableMessageDocument); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]dbmodel.UnprocessableMessageDocument) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// InsertPkAddressMappings provides a mock function with given fields: ctx, stakerPkHex, taproot, nativeSigwitOdd, nativeSigwitEven +func (_m *DBClient) InsertPkAddressMappings(ctx context.Context, stakerPkHex string, taproot string, nativeSigwitOdd string, nativeSigwitEven string) error { + ret := _m.Called(ctx, stakerPkHex, taproot, nativeSigwitOdd, nativeSigwitEven) + + if len(ret) == 0 { + panic("no return value specified for InsertPkAddressMappings") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string) error); ok { + r0 = rf(ctx, stakerPkHex, taproot, nativeSigwitOdd, nativeSigwitEven) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Ping provides a mock function with given fields: ctx +func (_m *DBClient) Ping(ctx context.Context) error { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for Ping") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(ctx) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SaveUnprocessableMessage provides a mock function with given fields: ctx, messageBody, receipt +func (_m *DBClient) SaveUnprocessableMessage(ctx context.Context, messageBody string, receipt string) error { + ret := _m.Called(ctx, messageBody, receipt) + + if len(ret) == 0 { + panic("no return value specified for SaveUnprocessableMessage") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { + r0 = rf(ctx, messageBody, receipt) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewDBClient creates a new instance of DBClient. 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 NewDBClient(t interface { + mock.TestingT + Cleanup(func()) +}) *DBClient { + mock := &DBClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/tests/mocks/mock_ordinal_client.go b/tests/mocks/mock_ordinal_client.go new file mode 100644 index 0000000..95dff74 --- /dev/null +++ b/tests/mocks/mock_ordinal_client.go @@ -0,0 +1,121 @@ +// Code generated by mockery v2.41.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + http "net/http" + + mock "github.com/stretchr/testify/mock" + + ordinals "github.com/babylonlabs-io/staking-api-service/internal/shared/http/clients/ordinals" + + types "github.com/babylonlabs-io/staking-api-service/internal/shared/types" +) + +// OrdinalsClient is an autogenerated mock type for the OrdinalsClient type +type OrdinalsClient struct { + mock.Mock +} + +// FetchUTXOInfos provides a mock function with given fields: ctx, utxos +func (_m *OrdinalsClient) FetchUTXOInfos(ctx context.Context, utxos []types.UTXOIdentifier) ([]ordinals.OrdinalsOutputResponse, *types.Error) { + ret := _m.Called(ctx, utxos) + + if len(ret) == 0 { + panic("no return value specified for FetchUTXOInfos") + } + + var r0 []ordinals.OrdinalsOutputResponse + var r1 *types.Error + if rf, ok := ret.Get(0).(func(context.Context, []types.UTXOIdentifier) ([]ordinals.OrdinalsOutputResponse, *types.Error)); ok { + return rf(ctx, utxos) + } + if rf, ok := ret.Get(0).(func(context.Context, []types.UTXOIdentifier) []ordinals.OrdinalsOutputResponse); ok { + r0 = rf(ctx, utxos) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]ordinals.OrdinalsOutputResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []types.UTXOIdentifier) *types.Error); ok { + r1 = rf(ctx, utxos) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*types.Error) + } + } + + return r0, r1 +} + +// GetBaseURL provides a mock function with given fields: +func (_m *OrdinalsClient) GetBaseURL() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetBaseURL") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// GetDefaultRequestTimeout provides a mock function with given fields: +func (_m *OrdinalsClient) GetDefaultRequestTimeout() int { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetDefaultRequestTimeout") + } + + var r0 int + if rf, ok := ret.Get(0).(func() int); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(int) + } + + return r0 +} + +// GetHttpClient provides a mock function with given fields: +func (_m *OrdinalsClient) GetHttpClient() *http.Client { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetHttpClient") + } + + var r0 *http.Client + if rf, ok := ret.Get(0).(func() *http.Client); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Client) + } + } + + return r0 +} + +// NewOrdinalsClient creates a new instance of OrdinalsClient. 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 NewOrdinalsClient(t interface { + mock.TestingT + Cleanup(func()) +}) *OrdinalsClient { + mock := &OrdinalsClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/tests/mocks/mock_v1_db_client.go b/tests/mocks/mock_v1_db_client.go new file mode 100644 index 0000000..6cd0a26 --- /dev/null +++ b/tests/mocks/mock_v1_db_client.go @@ -0,0 +1,779 @@ +// Code generated by mockery v2.41.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + db "github.com/babylonlabs-io/staking-api-service/internal/shared/db" + dbmodel "github.com/babylonlabs-io/staking-api-service/internal/shared/db/model" + + mock "github.com/stretchr/testify/mock" + + types "github.com/babylonlabs-io/staking-api-service/internal/shared/types" + + v1dbclient "github.com/babylonlabs-io/staking-api-service/internal/v1/db/client" + + v1dbmodel "github.com/babylonlabs-io/staking-api-service/internal/v1/db/model" +) + +// V1DBClient is an autogenerated mock type for the V1DBClient type +type V1DBClient struct { + mock.Mock +} + +// CheckDelegationExistByStakerPk provides a mock function with given fields: ctx, address, extraFilter +func (_m *V1DBClient) CheckDelegationExistByStakerPk(ctx context.Context, address string, extraFilter *v1dbclient.DelegationFilter) (bool, error) { + ret := _m.Called(ctx, address, extraFilter) + + if len(ret) == 0 { + panic("no return value specified for CheckDelegationExistByStakerPk") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, *v1dbclient.DelegationFilter) (bool, error)); ok { + return rf(ctx, address, extraFilter) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *v1dbclient.DelegationFilter) bool); ok { + r0 = rf(ctx, address, extraFilter) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *v1dbclient.DelegationFilter) error); ok { + r1 = rf(ctx, address, extraFilter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeleteUnprocessableMessage provides a mock function with given fields: ctx, Receipt +func (_m *V1DBClient) DeleteUnprocessableMessage(ctx context.Context, Receipt interface{}) error { + ret := _m.Called(ctx, Receipt) + + if len(ret) == 0 { + panic("no return value specified for DeleteUnprocessableMessage") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, interface{}) error); ok { + r0 = rf(ctx, Receipt) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// FindDelegationByTxHashHex provides a mock function with given fields: ctx, txHashHex +func (_m *V1DBClient) FindDelegationByTxHashHex(ctx context.Context, txHashHex string) (*v1dbmodel.DelegationDocument, error) { + ret := _m.Called(ctx, txHashHex) + + if len(ret) == 0 { + panic("no return value specified for FindDelegationByTxHashHex") + } + + var r0 *v1dbmodel.DelegationDocument + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*v1dbmodel.DelegationDocument, error)); ok { + return rf(ctx, txHashHex) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *v1dbmodel.DelegationDocument); ok { + r0 = rf(ctx, txHashHex) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1dbmodel.DelegationDocument) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, txHashHex) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FindDelegationsByStakerPk provides a mock function with given fields: ctx, stakerPk, extraFilter, paginationToken +func (_m *V1DBClient) FindDelegationsByStakerPk(ctx context.Context, stakerPk string, extraFilter *v1dbclient.DelegationFilter, paginationToken string) (*db.DbResultMap[v1dbmodel.DelegationDocument], error) { + ret := _m.Called(ctx, stakerPk, extraFilter, paginationToken) + + if len(ret) == 0 { + panic("no return value specified for FindDelegationsByStakerPk") + } + + var r0 *db.DbResultMap[v1dbmodel.DelegationDocument] + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, *v1dbclient.DelegationFilter, string) (*db.DbResultMap[v1dbmodel.DelegationDocument], error)); ok { + return rf(ctx, stakerPk, extraFilter, paginationToken) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *v1dbclient.DelegationFilter, string) *db.DbResultMap[v1dbmodel.DelegationDocument]); ok { + r0 = rf(ctx, stakerPk, extraFilter, paginationToken) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*db.DbResultMap[v1dbmodel.DelegationDocument]) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *v1dbclient.DelegationFilter, string) error); ok { + r1 = rf(ctx, stakerPk, extraFilter, paginationToken) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FindFinalityProviderStats provides a mock function with given fields: ctx, paginationToken +func (_m *V1DBClient) FindFinalityProviderStats(ctx context.Context, paginationToken string) (*db.DbResultMap[*v1dbmodel.FinalityProviderStatsDocument], error) { + ret := _m.Called(ctx, paginationToken) + + if len(ret) == 0 { + panic("no return value specified for FindFinalityProviderStats") + } + + var r0 *db.DbResultMap[*v1dbmodel.FinalityProviderStatsDocument] + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*db.DbResultMap[*v1dbmodel.FinalityProviderStatsDocument], error)); ok { + return rf(ctx, paginationToken) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *db.DbResultMap[*v1dbmodel.FinalityProviderStatsDocument]); ok { + r0 = rf(ctx, paginationToken) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*db.DbResultMap[*v1dbmodel.FinalityProviderStatsDocument]) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, paginationToken) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FindFinalityProviderStatsByFinalityProviderPkHex provides a mock function with given fields: ctx, finalityProviderPkHex +func (_m *V1DBClient) FindFinalityProviderStatsByFinalityProviderPkHex(ctx context.Context, finalityProviderPkHex []string) ([]*v1dbmodel.FinalityProviderStatsDocument, error) { + ret := _m.Called(ctx, finalityProviderPkHex) + + if len(ret) == 0 { + panic("no return value specified for FindFinalityProviderStatsByFinalityProviderPkHex") + } + + var r0 []*v1dbmodel.FinalityProviderStatsDocument + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, []string) ([]*v1dbmodel.FinalityProviderStatsDocument, error)); ok { + return rf(ctx, finalityProviderPkHex) + } + if rf, ok := ret.Get(0).(func(context.Context, []string) []*v1dbmodel.FinalityProviderStatsDocument); ok { + r0 = rf(ctx, finalityProviderPkHex) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*v1dbmodel.FinalityProviderStatsDocument) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []string) error); ok { + r1 = rf(ctx, finalityProviderPkHex) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FindPkMappingsByNativeSegwitAddress provides a mock function with given fields: ctx, nativeSegwitAddresses +func (_m *V1DBClient) FindPkMappingsByNativeSegwitAddress(ctx context.Context, nativeSegwitAddresses []string) ([]*dbmodel.PkAddressMapping, error) { + ret := _m.Called(ctx, nativeSegwitAddresses) + + if len(ret) == 0 { + panic("no return value specified for FindPkMappingsByNativeSegwitAddress") + } + + var r0 []*dbmodel.PkAddressMapping + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, []string) ([]*dbmodel.PkAddressMapping, error)); ok { + return rf(ctx, nativeSegwitAddresses) + } + if rf, ok := ret.Get(0).(func(context.Context, []string) []*dbmodel.PkAddressMapping); ok { + r0 = rf(ctx, nativeSegwitAddresses) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dbmodel.PkAddressMapping) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []string) error); ok { + r1 = rf(ctx, nativeSegwitAddresses) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FindPkMappingsByTaprootAddress provides a mock function with given fields: ctx, taprootAddresses +func (_m *V1DBClient) FindPkMappingsByTaprootAddress(ctx context.Context, taprootAddresses []string) ([]*dbmodel.PkAddressMapping, error) { + ret := _m.Called(ctx, taprootAddresses) + + if len(ret) == 0 { + panic("no return value specified for FindPkMappingsByTaprootAddress") + } + + var r0 []*dbmodel.PkAddressMapping + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, []string) ([]*dbmodel.PkAddressMapping, error)); ok { + return rf(ctx, taprootAddresses) + } + if rf, ok := ret.Get(0).(func(context.Context, []string) []*dbmodel.PkAddressMapping); ok { + r0 = rf(ctx, taprootAddresses) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dbmodel.PkAddressMapping) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []string) error); ok { + r1 = rf(ctx, taprootAddresses) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FindTopStakersByTvl provides a mock function with given fields: ctx, paginationToken +func (_m *V1DBClient) FindTopStakersByTvl(ctx context.Context, paginationToken string) (*db.DbResultMap[*v1dbmodel.StakerStatsDocument], error) { + ret := _m.Called(ctx, paginationToken) + + if len(ret) == 0 { + panic("no return value specified for FindTopStakersByTvl") + } + + var r0 *db.DbResultMap[*v1dbmodel.StakerStatsDocument] + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*db.DbResultMap[*v1dbmodel.StakerStatsDocument], error)); ok { + return rf(ctx, paginationToken) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *db.DbResultMap[*v1dbmodel.StakerStatsDocument]); ok { + r0 = rf(ctx, paginationToken) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*db.DbResultMap[*v1dbmodel.StakerStatsDocument]) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, paginationToken) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FindUnprocessableMessages provides a mock function with given fields: ctx +func (_m *V1DBClient) FindUnprocessableMessages(ctx context.Context) ([]dbmodel.UnprocessableMessageDocument, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for FindUnprocessableMessages") + } + + var r0 []dbmodel.UnprocessableMessageDocument + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]dbmodel.UnprocessableMessageDocument, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []dbmodel.UnprocessableMessageDocument); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]dbmodel.UnprocessableMessageDocument) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetLatestBtcInfo provides a mock function with given fields: ctx +func (_m *V1DBClient) GetLatestBtcInfo(ctx context.Context) (*v1dbmodel.BtcInfo, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GetLatestBtcInfo") + } + + var r0 *v1dbmodel.BtcInfo + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (*v1dbmodel.BtcInfo, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) *v1dbmodel.BtcInfo); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1dbmodel.BtcInfo) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetOrCreateStatsLock provides a mock function with given fields: ctx, stakingTxHashHex, state +func (_m *V1DBClient) GetOrCreateStatsLock(ctx context.Context, stakingTxHashHex string, state string) (*v1dbmodel.StatsLockDocument, error) { + ret := _m.Called(ctx, stakingTxHashHex, state) + + if len(ret) == 0 { + panic("no return value specified for GetOrCreateStatsLock") + } + + var r0 *v1dbmodel.StatsLockDocument + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*v1dbmodel.StatsLockDocument, error)); ok { + return rf(ctx, stakingTxHashHex, state) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string) *v1dbmodel.StatsLockDocument); ok { + r0 = rf(ctx, stakingTxHashHex, state) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1dbmodel.StatsLockDocument) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, stakingTxHashHex, state) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetOverallStats provides a mock function with given fields: ctx +func (_m *V1DBClient) GetOverallStats(ctx context.Context) (*v1dbmodel.OverallStatsDocument, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GetOverallStats") + } + + var r0 *v1dbmodel.OverallStatsDocument + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (*v1dbmodel.OverallStatsDocument, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) *v1dbmodel.OverallStatsDocument); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1dbmodel.OverallStatsDocument) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetStakerStats provides a mock function with given fields: ctx, stakerPkHex +func (_m *V1DBClient) GetStakerStats(ctx context.Context, stakerPkHex string) (*v1dbmodel.StakerStatsDocument, error) { + ret := _m.Called(ctx, stakerPkHex) + + if len(ret) == 0 { + panic("no return value specified for GetStakerStats") + } + + var r0 *v1dbmodel.StakerStatsDocument + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*v1dbmodel.StakerStatsDocument, error)); ok { + return rf(ctx, stakerPkHex) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *v1dbmodel.StakerStatsDocument); ok { + r0 = rf(ctx, stakerPkHex) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1dbmodel.StakerStatsDocument) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, stakerPkHex) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IncrementFinalityProviderStats provides a mock function with given fields: ctx, stakingTxHashHex, fpPkHex, amount +func (_m *V1DBClient) IncrementFinalityProviderStats(ctx context.Context, stakingTxHashHex string, fpPkHex string, amount uint64) error { + ret := _m.Called(ctx, stakingTxHashHex, fpPkHex, amount) + + if len(ret) == 0 { + panic("no return value specified for IncrementFinalityProviderStats") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, uint64) error); ok { + r0 = rf(ctx, stakingTxHashHex, fpPkHex, amount) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// IncrementOverallStats provides a mock function with given fields: ctx, stakingTxHashHex, stakerPkHex, amount +func (_m *V1DBClient) IncrementOverallStats(ctx context.Context, stakingTxHashHex string, stakerPkHex string, amount uint64) error { + ret := _m.Called(ctx, stakingTxHashHex, stakerPkHex, amount) + + if len(ret) == 0 { + panic("no return value specified for IncrementOverallStats") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, uint64) error); ok { + r0 = rf(ctx, stakingTxHashHex, stakerPkHex, amount) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// IncrementStakerStats provides a mock function with given fields: ctx, stakingTxHashHex, stakerPkHex, amount +func (_m *V1DBClient) IncrementStakerStats(ctx context.Context, stakingTxHashHex string, stakerPkHex string, amount uint64) error { + ret := _m.Called(ctx, stakingTxHashHex, stakerPkHex, amount) + + if len(ret) == 0 { + panic("no return value specified for IncrementStakerStats") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, uint64) error); ok { + r0 = rf(ctx, stakingTxHashHex, stakerPkHex, amount) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// InsertPkAddressMappings provides a mock function with given fields: ctx, stakerPkHex, taproot, nativeSigwitOdd, nativeSigwitEven +func (_m *V1DBClient) InsertPkAddressMappings(ctx context.Context, stakerPkHex string, taproot string, nativeSigwitOdd string, nativeSigwitEven string) error { + ret := _m.Called(ctx, stakerPkHex, taproot, nativeSigwitOdd, nativeSigwitEven) + + if len(ret) == 0 { + panic("no return value specified for InsertPkAddressMappings") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string) error); ok { + r0 = rf(ctx, stakerPkHex, taproot, nativeSigwitOdd, nativeSigwitEven) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Ping provides a mock function with given fields: ctx +func (_m *V1DBClient) Ping(ctx context.Context) error { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for Ping") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(ctx) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SaveActiveStakingDelegation provides a mock function with given fields: ctx, stakingTxHashHex, stakerPkHex, fpPkHex, stakingTxHex, amount, startHeight, timelock, outputIndex, startTimestamp, isOverflow +func (_m *V1DBClient) SaveActiveStakingDelegation(ctx context.Context, stakingTxHashHex string, stakerPkHex string, fpPkHex string, stakingTxHex string, amount uint64, startHeight uint64, timelock uint64, outputIndex uint64, startTimestamp int64, isOverflow bool) error { + ret := _m.Called(ctx, stakingTxHashHex, stakerPkHex, fpPkHex, stakingTxHex, amount, startHeight, timelock, outputIndex, startTimestamp, isOverflow) + + if len(ret) == 0 { + panic("no return value specified for SaveActiveStakingDelegation") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string, uint64, uint64, uint64, uint64, int64, bool) error); ok { + r0 = rf(ctx, stakingTxHashHex, stakerPkHex, fpPkHex, stakingTxHex, amount, startHeight, timelock, outputIndex, startTimestamp, isOverflow) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SaveTimeLockExpireCheck provides a mock function with given fields: ctx, stakingTxHashHex, expireHeight, txType +func (_m *V1DBClient) SaveTimeLockExpireCheck(ctx context.Context, stakingTxHashHex string, expireHeight uint64, txType string) error { + ret := _m.Called(ctx, stakingTxHashHex, expireHeight, txType) + + if len(ret) == 0 { + panic("no return value specified for SaveTimeLockExpireCheck") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, uint64, string) error); ok { + r0 = rf(ctx, stakingTxHashHex, expireHeight, txType) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SaveUnbondingTx provides a mock function with given fields: ctx, stakingTxHashHex, unbondingTxHashHex, txHex, signatureHex +func (_m *V1DBClient) SaveUnbondingTx(ctx context.Context, stakingTxHashHex string, unbondingTxHashHex string, txHex string, signatureHex string) error { + ret := _m.Called(ctx, stakingTxHashHex, unbondingTxHashHex, txHex, signatureHex) + + if len(ret) == 0 { + panic("no return value specified for SaveUnbondingTx") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string) error); ok { + r0 = rf(ctx, stakingTxHashHex, unbondingTxHashHex, txHex, signatureHex) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SaveUnprocessableMessage provides a mock function with given fields: ctx, messageBody, receipt +func (_m *V1DBClient) SaveUnprocessableMessage(ctx context.Context, messageBody string, receipt string) error { + ret := _m.Called(ctx, messageBody, receipt) + + if len(ret) == 0 { + panic("no return value specified for SaveUnprocessableMessage") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { + r0 = rf(ctx, messageBody, receipt) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// ScanDelegationsPaginated provides a mock function with given fields: ctx, paginationToken +func (_m *V1DBClient) ScanDelegationsPaginated(ctx context.Context, paginationToken string) (*db.DbResultMap[v1dbmodel.DelegationDocument], error) { + ret := _m.Called(ctx, paginationToken) + + if len(ret) == 0 { + panic("no return value specified for ScanDelegationsPaginated") + } + + var r0 *db.DbResultMap[v1dbmodel.DelegationDocument] + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*db.DbResultMap[v1dbmodel.DelegationDocument], error)); ok { + return rf(ctx, paginationToken) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *db.DbResultMap[v1dbmodel.DelegationDocument]); ok { + r0 = rf(ctx, paginationToken) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*db.DbResultMap[v1dbmodel.DelegationDocument]) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, paginationToken) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SubtractFinalityProviderStats provides a mock function with given fields: ctx, stakingTxHashHex, fpPkHex, amount +func (_m *V1DBClient) SubtractFinalityProviderStats(ctx context.Context, stakingTxHashHex string, fpPkHex string, amount uint64) error { + ret := _m.Called(ctx, stakingTxHashHex, fpPkHex, amount) + + if len(ret) == 0 { + panic("no return value specified for SubtractFinalityProviderStats") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, uint64) error); ok { + r0 = rf(ctx, stakingTxHashHex, fpPkHex, amount) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SubtractOverallStats provides a mock function with given fields: ctx, stakingTxHashHex, stakerPkHex, amount +func (_m *V1DBClient) SubtractOverallStats(ctx context.Context, stakingTxHashHex string, stakerPkHex string, amount uint64) error { + ret := _m.Called(ctx, stakingTxHashHex, stakerPkHex, amount) + + if len(ret) == 0 { + panic("no return value specified for SubtractOverallStats") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, uint64) error); ok { + r0 = rf(ctx, stakingTxHashHex, stakerPkHex, amount) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SubtractStakerStats provides a mock function with given fields: ctx, stakingTxHashHex, stakerPkHex, amount +func (_m *V1DBClient) SubtractStakerStats(ctx context.Context, stakingTxHashHex string, stakerPkHex string, amount uint64) error { + ret := _m.Called(ctx, stakingTxHashHex, stakerPkHex, amount) + + if len(ret) == 0 { + panic("no return value specified for SubtractStakerStats") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, uint64) error); ok { + r0 = rf(ctx, stakingTxHashHex, stakerPkHex, amount) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// TransitionToTransitionedState provides a mock function with given fields: ctx, stakingTxHashHex +func (_m *V1DBClient) TransitionToTransitionedState(ctx context.Context, stakingTxHashHex string) error { + ret := _m.Called(ctx, stakingTxHashHex) + + if len(ret) == 0 { + panic("no return value specified for TransitionToTransitionedState") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { + r0 = rf(ctx, stakingTxHashHex) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// TransitionToUnbondedState provides a mock function with given fields: ctx, stakingTxHashHex, eligiblePreviousState +func (_m *V1DBClient) TransitionToUnbondedState(ctx context.Context, stakingTxHashHex string, eligiblePreviousState []types.DelegationState) error { + ret := _m.Called(ctx, stakingTxHashHex, eligiblePreviousState) + + if len(ret) == 0 { + panic("no return value specified for TransitionToUnbondedState") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, []types.DelegationState) error); ok { + r0 = rf(ctx, stakingTxHashHex, eligiblePreviousState) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// TransitionToUnbondingState provides a mock function with given fields: ctx, txHashHex, startHeight, timelock, outputIndex, txHex, startTimestamp +func (_m *V1DBClient) TransitionToUnbondingState(ctx context.Context, txHashHex string, startHeight uint64, timelock uint64, outputIndex uint64, txHex string, startTimestamp int64) error { + ret := _m.Called(ctx, txHashHex, startHeight, timelock, outputIndex, txHex, startTimestamp) + + if len(ret) == 0 { + panic("no return value specified for TransitionToUnbondingState") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, uint64, uint64, uint64, string, int64) error); ok { + r0 = rf(ctx, txHashHex, startHeight, timelock, outputIndex, txHex, startTimestamp) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// TransitionToWithdrawnState provides a mock function with given fields: ctx, txHashHex +func (_m *V1DBClient) TransitionToWithdrawnState(ctx context.Context, txHashHex string) error { + ret := _m.Called(ctx, txHashHex) + + if len(ret) == 0 { + panic("no return value specified for TransitionToWithdrawnState") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { + r0 = rf(ctx, txHashHex) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// UpsertLatestBtcInfo provides a mock function with given fields: ctx, height, confirmedTvl, unconfirmedTvl +func (_m *V1DBClient) UpsertLatestBtcInfo(ctx context.Context, height uint64, confirmedTvl uint64, unconfirmedTvl uint64) error { + ret := _m.Called(ctx, height, confirmedTvl, unconfirmedTvl) + + if len(ret) == 0 { + panic("no return value specified for UpsertLatestBtcInfo") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, uint64) error); ok { + r0 = rf(ctx, height, confirmedTvl, unconfirmedTvl) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewV1DBClient creates a new instance of V1DBClient. 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 NewV1DBClient(t interface { + mock.TestingT + Cleanup(func()) +}) *V1DBClient { + mock := &V1DBClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/tests/mocks/mock_v2_db_client.go b/tests/mocks/mock_v2_db_client.go new file mode 100644 index 0000000..b37d8ed --- /dev/null +++ b/tests/mocks/mock_v2_db_client.go @@ -0,0 +1,449 @@ +// Code generated by mockery v2.41.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + dbmodel "github.com/babylonlabs-io/staking-api-service/internal/shared/db/model" + mock "github.com/stretchr/testify/mock" + + v2dbmodel "github.com/babylonlabs-io/staking-api-service/internal/v2/db/model" +) + +// V2DBClient is an autogenerated mock type for the V2DBClient type +type V2DBClient struct { + mock.Mock +} + +// DeleteUnprocessableMessage provides a mock function with given fields: ctx, Receipt +func (_m *V2DBClient) DeleteUnprocessableMessage(ctx context.Context, Receipt interface{}) error { + ret := _m.Called(ctx, Receipt) + + if len(ret) == 0 { + panic("no return value specified for DeleteUnprocessableMessage") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, interface{}) error); ok { + r0 = rf(ctx, Receipt) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// FindPkMappingsByNativeSegwitAddress provides a mock function with given fields: ctx, nativeSegwitAddresses +func (_m *V2DBClient) FindPkMappingsByNativeSegwitAddress(ctx context.Context, nativeSegwitAddresses []string) ([]*dbmodel.PkAddressMapping, error) { + ret := _m.Called(ctx, nativeSegwitAddresses) + + if len(ret) == 0 { + panic("no return value specified for FindPkMappingsByNativeSegwitAddress") + } + + var r0 []*dbmodel.PkAddressMapping + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, []string) ([]*dbmodel.PkAddressMapping, error)); ok { + return rf(ctx, nativeSegwitAddresses) + } + if rf, ok := ret.Get(0).(func(context.Context, []string) []*dbmodel.PkAddressMapping); ok { + r0 = rf(ctx, nativeSegwitAddresses) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dbmodel.PkAddressMapping) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []string) error); ok { + r1 = rf(ctx, nativeSegwitAddresses) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FindPkMappingsByTaprootAddress provides a mock function with given fields: ctx, taprootAddresses +func (_m *V2DBClient) FindPkMappingsByTaprootAddress(ctx context.Context, taprootAddresses []string) ([]*dbmodel.PkAddressMapping, error) { + ret := _m.Called(ctx, taprootAddresses) + + if len(ret) == 0 { + panic("no return value specified for FindPkMappingsByTaprootAddress") + } + + var r0 []*dbmodel.PkAddressMapping + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, []string) ([]*dbmodel.PkAddressMapping, error)); ok { + return rf(ctx, taprootAddresses) + } + if rf, ok := ret.Get(0).(func(context.Context, []string) []*dbmodel.PkAddressMapping); ok { + r0 = rf(ctx, taprootAddresses) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dbmodel.PkAddressMapping) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []string) error); ok { + r1 = rf(ctx, taprootAddresses) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FindUnprocessableMessages provides a mock function with given fields: ctx +func (_m *V2DBClient) FindUnprocessableMessages(ctx context.Context) ([]dbmodel.UnprocessableMessageDocument, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for FindUnprocessableMessages") + } + + var r0 []dbmodel.UnprocessableMessageDocument + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]dbmodel.UnprocessableMessageDocument, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []dbmodel.UnprocessableMessageDocument); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]dbmodel.UnprocessableMessageDocument) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetActiveStakersCount provides a mock function with given fields: ctx +func (_m *V2DBClient) GetActiveStakersCount(ctx context.Context) (int64, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GetActiveStakersCount") + } + + var r0 int64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (int64, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) int64); ok { + r0 = rf(ctx) + } else { + r0 = ret.Get(0).(int64) + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetFinalityProviderStats provides a mock function with given fields: ctx +func (_m *V2DBClient) GetFinalityProviderStats(ctx context.Context) ([]*v2dbmodel.V2FinalityProviderStatsDocument, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GetFinalityProviderStats") + } + + var r0 []*v2dbmodel.V2FinalityProviderStatsDocument + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]*v2dbmodel.V2FinalityProviderStatsDocument, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []*v2dbmodel.V2FinalityProviderStatsDocument); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*v2dbmodel.V2FinalityProviderStatsDocument) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetOrCreateStatsLock provides a mock function with given fields: ctx, stakingTxHashHex, state +func (_m *V2DBClient) GetOrCreateStatsLock(ctx context.Context, stakingTxHashHex string, state string) (*v2dbmodel.V2StatsLockDocument, error) { + ret := _m.Called(ctx, stakingTxHashHex, state) + + if len(ret) == 0 { + panic("no return value specified for GetOrCreateStatsLock") + } + + var r0 *v2dbmodel.V2StatsLockDocument + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*v2dbmodel.V2StatsLockDocument, error)); ok { + return rf(ctx, stakingTxHashHex, state) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string) *v2dbmodel.V2StatsLockDocument); ok { + r0 = rf(ctx, stakingTxHashHex, state) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v2dbmodel.V2StatsLockDocument) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, stakingTxHashHex, state) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetOverallStats provides a mock function with given fields: ctx +func (_m *V2DBClient) GetOverallStats(ctx context.Context) (*v2dbmodel.V2OverallStatsDocument, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GetOverallStats") + } + + var r0 *v2dbmodel.V2OverallStatsDocument + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (*v2dbmodel.V2OverallStatsDocument, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) *v2dbmodel.V2OverallStatsDocument); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v2dbmodel.V2OverallStatsDocument) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetStakerStats provides a mock function with given fields: ctx, stakerPKHex +func (_m *V2DBClient) GetStakerStats(ctx context.Context, stakerPKHex string) (*v2dbmodel.V2StakerStatsDocument, error) { + ret := _m.Called(ctx, stakerPKHex) + + if len(ret) == 0 { + panic("no return value specified for GetStakerStats") + } + + var r0 *v2dbmodel.V2StakerStatsDocument + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*v2dbmodel.V2StakerStatsDocument, error)); ok { + return rf(ctx, stakerPKHex) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *v2dbmodel.V2StakerStatsDocument); ok { + r0 = rf(ctx, stakerPKHex) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v2dbmodel.V2StakerStatsDocument) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, stakerPKHex) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IncrementFinalityProviderStats provides a mock function with given fields: ctx, stakingTxHashHex, fpPkHexes, amount +func (_m *V2DBClient) IncrementFinalityProviderStats(ctx context.Context, stakingTxHashHex string, fpPkHexes []string, amount uint64) error { + ret := _m.Called(ctx, stakingTxHashHex, fpPkHexes, amount) + + if len(ret) == 0 { + panic("no return value specified for IncrementFinalityProviderStats") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, []string, uint64) error); ok { + r0 = rf(ctx, stakingTxHashHex, fpPkHexes, amount) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// IncrementOverallStats provides a mock function with given fields: ctx, stakingTxHashHex, stakerPkHex, amount +func (_m *V2DBClient) IncrementOverallStats(ctx context.Context, stakingTxHashHex string, stakerPkHex string, amount uint64) error { + ret := _m.Called(ctx, stakingTxHashHex, stakerPkHex, amount) + + if len(ret) == 0 { + panic("no return value specified for IncrementOverallStats") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, uint64) error); ok { + r0 = rf(ctx, stakingTxHashHex, stakerPkHex, amount) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// IncrementStakerStats provides a mock function with given fields: ctx, stakingTxHashHex, stakerPkHex, amount +func (_m *V2DBClient) IncrementStakerStats(ctx context.Context, stakingTxHashHex string, stakerPkHex string, amount uint64) error { + ret := _m.Called(ctx, stakingTxHashHex, stakerPkHex, amount) + + if len(ret) == 0 { + panic("no return value specified for IncrementStakerStats") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, uint64) error); ok { + r0 = rf(ctx, stakingTxHashHex, stakerPkHex, amount) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// InsertPkAddressMappings provides a mock function with given fields: ctx, stakerPkHex, taproot, nativeSigwitOdd, nativeSigwitEven +func (_m *V2DBClient) InsertPkAddressMappings(ctx context.Context, stakerPkHex string, taproot string, nativeSigwitOdd string, nativeSigwitEven string) error { + ret := _m.Called(ctx, stakerPkHex, taproot, nativeSigwitOdd, nativeSigwitEven) + + if len(ret) == 0 { + panic("no return value specified for InsertPkAddressMappings") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string) error); ok { + r0 = rf(ctx, stakerPkHex, taproot, nativeSigwitOdd, nativeSigwitEven) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Ping provides a mock function with given fields: ctx +func (_m *V2DBClient) Ping(ctx context.Context) error { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for Ping") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(ctx) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SaveUnprocessableMessage provides a mock function with given fields: ctx, messageBody, receipt +func (_m *V2DBClient) SaveUnprocessableMessage(ctx context.Context, messageBody string, receipt string) error { + ret := _m.Called(ctx, messageBody, receipt) + + if len(ret) == 0 { + panic("no return value specified for SaveUnprocessableMessage") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { + r0 = rf(ctx, messageBody, receipt) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SubtractFinalityProviderStats provides a mock function with given fields: ctx, stakingTxHashHex, fpPkHexes, amount +func (_m *V2DBClient) SubtractFinalityProviderStats(ctx context.Context, stakingTxHashHex string, fpPkHexes []string, amount uint64) error { + ret := _m.Called(ctx, stakingTxHashHex, fpPkHexes, amount) + + if len(ret) == 0 { + panic("no return value specified for SubtractFinalityProviderStats") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, []string, uint64) error); ok { + r0 = rf(ctx, stakingTxHashHex, fpPkHexes, amount) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SubtractOverallStats provides a mock function with given fields: ctx, stakingTxHashHex, stakerPkHex, amount +func (_m *V2DBClient) SubtractOverallStats(ctx context.Context, stakingTxHashHex string, stakerPkHex string, amount uint64) error { + ret := _m.Called(ctx, stakingTxHashHex, stakerPkHex, amount) + + if len(ret) == 0 { + panic("no return value specified for SubtractOverallStats") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, uint64) error); ok { + r0 = rf(ctx, stakingTxHashHex, stakerPkHex, amount) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SubtractStakerStats provides a mock function with given fields: ctx, stakingTxHashHex, stakerPkHex, amount +func (_m *V2DBClient) SubtractStakerStats(ctx context.Context, stakingTxHashHex string, stakerPkHex string, amount uint64) error { + ret := _m.Called(ctx, stakingTxHashHex, stakerPkHex, amount) + + if len(ret) == 0 { + panic("no return value specified for SubtractStakerStats") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, uint64) error); ok { + r0 = rf(ctx, stakingTxHashHex, stakerPkHex, amount) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewV2DBClient creates a new instance of V2DBClient. 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 NewV2DBClient(t interface { + mock.TestingT + Cleanup(func()) +}) *V2DBClient { + mock := &V2DBClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}