Skip to content

Commit

Permalink
fix mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazar955 committed Jan 24, 2025
1 parent ee27166 commit 99531ae
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
10 changes: 7 additions & 3 deletions clientcontroller/babylon.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package clientcontroller
import (
"context"
"fmt"
coretypes "github.com/cometbft/cometbft/rpc/core/types"
"strings"
"time"

Expand Down Expand Up @@ -416,8 +415,13 @@ func (bc *BabylonController) QueryBestBlock() (*types.BlockInfo, error) {
return blocks[0], nil
}

func (bc *BabylonController) NodeStatus() (*coretypes.ResultStatus, error) {
return bc.bbnClient.GetStatus()
func (bc *BabylonController) NodeTxIndexEnabled() (bool, error) {
res, err := bc.bbnClient.GetStatus()
if err != nil {
return false, fmt.Errorf("failed to query node status: %w", err)
}

return res.TxIndexEnabled(), nil
}

func (bc *BabylonController) queryCometBestBlock() (*types.BlockInfo, error) {
Expand Down
6 changes: 2 additions & 4 deletions clientcontroller/interface.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package clientcontroller

import (
"fmt"
coretypes "github.com/cometbft/cometbft/rpc/core/types"

"cosmossdk.io/math"
"fmt"
btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
Expand Down Expand Up @@ -90,7 +88,7 @@ type ClientController interface {
// the value zero should be returned.
QueryFinalityActivationBlockHeight() (uint64, error)

NodeStatus() (*coretypes.ResultStatus, error)
NodeTxIndexEnabled() (bool, error)

Close() error
}
Expand Down
2 changes: 2 additions & 0 deletions finality-provider/service/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func FuzzCreateFinalityProvider(f *testing.F) {
mockClientController.EXPECT().QueryFinalityProvider(gomock.Any()).Return(nil, nil).AnyTimes()
mockClientController.EXPECT().QueryBlocks(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClientController.EXPECT().QueryLastCommittedPublicRand(gomock.Any(), uint64(1)).Return(nil, nil).AnyTimes()
mockClientController.EXPECT().NodeTxIndexEnabled().Return(true, nil).AnyTimes()

// Create randomized config
fpHomeDir := filepath.Join(t.TempDir(), "fp-home")
Expand Down Expand Up @@ -222,6 +223,7 @@ func FuzzUnjailFinalityProvider(f *testing.F) {
mockClientController.EXPECT().QueryLatestFinalizedBlocks(gomock.Any()).Return(nil, nil).AnyTimes()
mockClientController.EXPECT().QueryBestBlock().Return(blkInfo, nil).Return(blkInfo, nil).AnyTimes()
mockClientController.EXPECT().QueryBlocks(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.New("chain not online")).AnyTimes()
mockClientController.EXPECT().NodeTxIndexEnabled().Return(true, nil).AnyTimes()

// set voting power to be positive so that the fp should eventually become ACTIVE
mockClientController.EXPECT().QueryFinalityProviderVotingPower(gomock.Any(), gomock.Any()).Return(uint64(0), nil).AnyTimes()
Expand Down
4 changes: 2 additions & 2 deletions finality-provider/service/fp_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,12 +1041,12 @@ func (fp *FinalityProviderInstance) GetFinalityProviderSlashedOrJailedWithRetry(
}

func (fp *FinalityProviderInstance) txIndexEnabled() error {
res, err := fp.cc.NodeStatus()
enabled, err := fp.cc.NodeTxIndexEnabled()
if err != nil {
return fmt.Errorf("failed to query node status: %w", err)
}

if !res.TxIndexEnabled() {
if !enabled {
return fmt.Errorf("tx indexing in the babylon node must be enabled")
}

Expand Down
15 changes: 7 additions & 8 deletions testutil/mocks/babylon.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 99531ae

Please sign in to comment.