mukan-ignite/ignite/pkg/cosmosclient/testutil/mocks.go
Mukan Erkin Törük c32551b6f7
Some checks failed
Docs Deploy / build_and_deploy (push) Has been cancelled
Generate Docs / cli (push) Has been cancelled
Generate Config Doc / cli (push) Has been cancelled
Go formatting / go-formatting (push) Has been cancelled
Check links / markdown-link-check (push) Has been cancelled
Integration / pre-test (push) Has been cancelled
Integration / test on (push) Has been cancelled
Integration / status (push) Has been cancelled
Lint / Lint Go code (push) Has been cancelled
Test / test (ubuntu-latest) (push) Has been cancelled
refactor: replace all github.com upstream refs with git.cw.tr/mukan-network
2026-05-11 03:36:24 +03:00

53 lines
1.8 KiB
Go

package testutil
import (
"testing"
"github.com/stretchr/testify/mock"
"git.cw.tr/mukan-network/mukan-ignite/ignite/pkg/cosmosclient/mocks"
)
//go:generate mockery --srcpkg github.com/cometbft/cometbft/rpc/client --name Client --structname RPCClient --filename rpc_client.go --output ../mocks --with-expecter
//go:generate mockery --srcpkg github.com/cosmos/cosmos-sdk/client --name AccountRetriever --filename account_retriever.go --output ../mocks --with-expecter
//go:generate mockery --srcpkg github.com/cosmos/cosmos-sdk/x/bank/types --name QueryClient --structname BankQueryClient --filename bank_query_client.go --output ../mocks --with-expecter
// NewTendermintClientMock creates a new Tendermint RPC client mock.
func NewTendermintClientMock(t *testing.T) *TendermintClientMock {
t.Helper()
m := TendermintClientMock{}
m.Test(t)
return &m
}
// TendermintClientMock mocks Tendermint's RPC client.
type TendermintClientMock struct {
mocks.RPCClient
}
// OnStatus starts a generic call mock on the Status RPC method.
func (m *TendermintClientMock) OnStatus() *mock.Call {
return m.On("Status", mock.Anything)
}
// OnBlock starts a generic call mock on the Block RPC method.
func (m *TendermintClientMock) OnBlock() *mock.Call {
return m.On("Block", RepeatMockArgs(2)...)
}
// OnTxSearch starts a generic call mock on the TxSearch RPC method.
func (m *TendermintClientMock) OnTxSearch() *mock.Call {
return m.On("TxSearch", RepeatMockArgs(6)...)
}
// RepeatMockArgs returns a slice with an N number of mock.Anything arguments.
// This function can be useful to define a number of generic consecutive arguments
// for mocked method calls.
func RepeatMockArgs(n int) (args []interface{}) {
for i := 0; i < n; i++ {
args = append(args, mock.Anything)
}
return args
}