From f7627ea9982feabf594ac76ec8e055b62d1d827f Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Thu, 19 Sep 2024 02:00:57 -0500 Subject: [PATCH] replace manual btc rpc mock with Mockery --- zetaclient/testutils/mocks/btc_rpc.go | 603 +++++++++++++++++---- zetaclient/testutils/mocks/btc_rpc_mock.go | 548 ------------------- 2 files changed, 488 insertions(+), 663 deletions(-) delete mode 100644 zetaclient/testutils/mocks/btc_rpc_mock.go diff --git a/zetaclient/testutils/mocks/btc_rpc.go b/zetaclient/testutils/mocks/btc_rpc.go index b4291a8d07..e1f56ee2a4 100644 --- a/zetaclient/testutils/mocks/btc_rpc.go +++ b/zetaclient/testutils/mocks/btc_rpc.go @@ -1,175 +1,548 @@ +// Code generated by mockery v2.42.2. DO NOT EDIT. + package mocks import ( - "errors" + btcjson "github.com/btcsuite/btcd/btcjson" + btcutil "github.com/btcsuite/btcutil" - "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/rpcclient" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil" + chainhash "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/zeta-chain/node/zetaclient/chains/interfaces" -) + mock "github.com/stretchr/testify/mock" -// EvmClient interface -var _ interfaces.BTCRPCClient = &MockBTCRPCClient{} + rpcclient "github.com/btcsuite/btcd/rpcclient" -// MockBTCRPCClient is a mock implementation of the BTCRPCClient interface -type MockBTCRPCClient struct { - err error - blockCount int64 - blockHash *chainhash.Hash - blockHeader *wire.BlockHeader - blockVerboseTx *btcjson.GetBlockVerboseTxResult - Txs []*btcutil.Tx -} + wire "github.com/btcsuite/btcd/wire" +) -// NewMockBTCRPCClient creates a new mock BTC RPC client -func NewMockBTCRPCClient() *MockBTCRPCClient { - client := &MockBTCRPCClient{} - return client.Reset() +// BTCRPCClient is an autogenerated mock type for the BTCRPCClient type +type BTCRPCClient struct { + mock.Mock } -// Reset clears the mock data -func (c *MockBTCRPCClient) Reset() *MockBTCRPCClient { - if c.err != nil { - return nil +// CreateWallet provides a mock function with given fields: name, opts +func (_m *BTCRPCClient) CreateWallet(name string, opts ...rpcclient.CreateWalletOpt) (*btcjson.CreateWalletResult, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] } + var _ca []interface{} + _ca = append(_ca, name) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) - c.Txs = []*btcutil.Tx{} - return c -} + if len(ret) == 0 { + panic("no return value specified for CreateWallet") + } -func (c *MockBTCRPCClient) GetNetworkInfo() (*btcjson.GetNetworkInfoResult, error) { - return nil, errors.New("not implemented") -} + var r0 *btcjson.CreateWalletResult + var r1 error + if rf, ok := ret.Get(0).(func(string, ...rpcclient.CreateWalletOpt) (*btcjson.CreateWalletResult, error)); ok { + return rf(name, opts...) + } + if rf, ok := ret.Get(0).(func(string, ...rpcclient.CreateWalletOpt) *btcjson.CreateWalletResult); ok { + r0 = rf(name, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcjson.CreateWalletResult) + } + } -func (c *MockBTCRPCClient) CreateWallet(_ string, _ ...rpcclient.CreateWalletOpt) (*btcjson.CreateWalletResult, error) { - return nil, errors.New("not implemented") -} + if rf, ok := ret.Get(1).(func(string, ...rpcclient.CreateWalletOpt) error); ok { + r1 = rf(name, opts...) + } else { + r1 = ret.Error(1) + } -func (c *MockBTCRPCClient) GetNewAddress(_ string) (btcutil.Address, error) { - return nil, errors.New("not implemented") + return r0, r1 } -func (c *MockBTCRPCClient) GenerateToAddress(_ int64, _ btcutil.Address, _ *int64) ([]*chainhash.Hash, error) { - return nil, errors.New("not implemented") -} +// EstimateSmartFee provides a mock function with given fields: confTarget, mode +func (_m *BTCRPCClient) EstimateSmartFee(confTarget int64, mode *btcjson.EstimateSmartFeeMode) (*btcjson.EstimateSmartFeeResult, error) { + ret := _m.Called(confTarget, mode) -func (c *MockBTCRPCClient) GetBalance(_ string) (btcutil.Amount, error) { - return 0, errors.New("not implemented") -} + if len(ret) == 0 { + panic("no return value specified for EstimateSmartFee") + } -func (c *MockBTCRPCClient) SendRawTransaction(_ *wire.MsgTx, _ bool) (*chainhash.Hash, error) { - return nil, errors.New("not implemented") -} + var r0 *btcjson.EstimateSmartFeeResult + var r1 error + if rf, ok := ret.Get(0).(func(int64, *btcjson.EstimateSmartFeeMode) (*btcjson.EstimateSmartFeeResult, error)); ok { + return rf(confTarget, mode) + } + if rf, ok := ret.Get(0).(func(int64, *btcjson.EstimateSmartFeeMode) *btcjson.EstimateSmartFeeResult); ok { + r0 = rf(confTarget, mode) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcjson.EstimateSmartFeeResult) + } + } -func (c *MockBTCRPCClient) ListUnspent() ([]btcjson.ListUnspentResult, error) { - return nil, errors.New("not implemented") -} + if rf, ok := ret.Get(1).(func(int64, *btcjson.EstimateSmartFeeMode) error); ok { + r1 = rf(confTarget, mode) + } else { + r1 = ret.Error(1) + } -func (c *MockBTCRPCClient) ListUnspentMinMaxAddresses( - _ int, - _ int, - _ []btcutil.Address, -) ([]btcjson.ListUnspentResult, error) { - return nil, errors.New("not implemented") + return r0, r1 } -func (c *MockBTCRPCClient) EstimateSmartFee( - _ int64, - _ *btcjson.EstimateSmartFeeMode, -) (*btcjson.EstimateSmartFeeResult, error) { - return nil, errors.New("not implemented") +// GenerateToAddress provides a mock function with given fields: numBlocks, address, maxTries +func (_m *BTCRPCClient) GenerateToAddress(numBlocks int64, address btcutil.Address, maxTries *int64) ([]*chainhash.Hash, error) { + ret := _m.Called(numBlocks, address, maxTries) + + if len(ret) == 0 { + panic("no return value specified for GenerateToAddress") + } + + var r0 []*chainhash.Hash + var r1 error + if rf, ok := ret.Get(0).(func(int64, btcutil.Address, *int64) ([]*chainhash.Hash, error)); ok { + return rf(numBlocks, address, maxTries) + } + if rf, ok := ret.Get(0).(func(int64, btcutil.Address, *int64) []*chainhash.Hash); ok { + r0 = rf(numBlocks, address, maxTries) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*chainhash.Hash) + } + } + + if rf, ok := ret.Get(1).(func(int64, btcutil.Address, *int64) error); ok { + r1 = rf(numBlocks, address, maxTries) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -func (c *MockBTCRPCClient) GetTransaction(_ *chainhash.Hash) (*btcjson.GetTransactionResult, error) { - return nil, errors.New("not implemented") +// GetBalance provides a mock function with given fields: account +func (_m *BTCRPCClient) GetBalance(account string) (btcutil.Amount, error) { + ret := _m.Called(account) + + if len(ret) == 0 { + panic("no return value specified for GetBalance") + } + + var r0 btcutil.Amount + var r1 error + if rf, ok := ret.Get(0).(func(string) (btcutil.Amount, error)); ok { + return rf(account) + } + if rf, ok := ret.Get(0).(func(string) btcutil.Amount); ok { + r0 = rf(account) + } else { + r0 = ret.Get(0).(btcutil.Amount) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(account) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -// GetRawTransaction returns a pre-loaded transaction or nil -func (c *MockBTCRPCClient) GetRawTransaction(_ *chainhash.Hash) (*btcutil.Tx, error) { - // pop a transaction from the list - if len(c.Txs) > 0 { - tx := c.Txs[len(c.Txs)-1] - c.Txs = c.Txs[:len(c.Txs)-1] - return tx, nil +// GetBlockCount provides a mock function with given fields: +func (_m *BTCRPCClient) GetBlockCount() (int64, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetBlockCount") + } + + var r0 int64 + var r1 error + if rf, ok := ret.Get(0).(func() (int64, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() int64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(int64) } - return nil, errors.New("no transaction found") + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -func (c *MockBTCRPCClient) GetRawTransactionVerbose(_ *chainhash.Hash) (*btcjson.TxRawResult, error) { - return nil, errors.New("not implemented") +// GetBlockHash provides a mock function with given fields: blockHeight +func (_m *BTCRPCClient) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) { + ret := _m.Called(blockHeight) + + if len(ret) == 0 { + panic("no return value specified for GetBlockHash") + } + + var r0 *chainhash.Hash + var r1 error + if rf, ok := ret.Get(0).(func(int64) (*chainhash.Hash, error)); ok { + return rf(blockHeight) + } + if rf, ok := ret.Get(0).(func(int64) *chainhash.Hash); ok { + r0 = rf(blockHeight) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*chainhash.Hash) + } + } + + if rf, ok := ret.Get(1).(func(int64) error); ok { + r1 = rf(blockHeight) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -func (c *MockBTCRPCClient) GetBlockCount() (int64, error) { - if c.err != nil { - return 0, c.err +// GetBlockHeader provides a mock function with given fields: blockHash +func (_m *BTCRPCClient) GetBlockHeader(blockHash *chainhash.Hash) (*wire.BlockHeader, error) { + ret := _m.Called(blockHash) + + if len(ret) == 0 { + panic("no return value specified for GetBlockHeader") } - return c.blockCount, nil + + var r0 *wire.BlockHeader + var r1 error + if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*wire.BlockHeader, error)); ok { + return rf(blockHash) + } + if rf, ok := ret.Get(0).(func(*chainhash.Hash) *wire.BlockHeader); ok { + r0 = rf(blockHash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*wire.BlockHeader) + } + } + + if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { + r1 = rf(blockHash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -func (c *MockBTCRPCClient) GetBlockHash(_ int64) (*chainhash.Hash, error) { - if c.err != nil { - return nil, c.err +// GetBlockVerbose provides a mock function with given fields: blockHash +func (_m *BTCRPCClient) GetBlockVerbose(blockHash *chainhash.Hash) (*btcjson.GetBlockVerboseResult, error) { + ret := _m.Called(blockHash) + + if len(ret) == 0 { + panic("no return value specified for GetBlockVerbose") + } + + var r0 *btcjson.GetBlockVerboseResult + var r1 error + if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcjson.GetBlockVerboseResult, error)); ok { + return rf(blockHash) } - return c.blockHash, nil + if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcjson.GetBlockVerboseResult); ok { + r0 = rf(blockHash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcjson.GetBlockVerboseResult) + } + } + + if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { + r1 = rf(blockHash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -func (c *MockBTCRPCClient) GetBlockVerbose(_ *chainhash.Hash) (*btcjson.GetBlockVerboseResult, error) { - return nil, errors.New("not implemented") +// GetBlockVerboseTx provides a mock function with given fields: blockHash +func (_m *BTCRPCClient) GetBlockVerboseTx(blockHash *chainhash.Hash) (*btcjson.GetBlockVerboseTxResult, error) { + ret := _m.Called(blockHash) + + if len(ret) == 0 { + panic("no return value specified for GetBlockVerboseTx") + } + + var r0 *btcjson.GetBlockVerboseTxResult + var r1 error + if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcjson.GetBlockVerboseTxResult, error)); ok { + return rf(blockHash) + } + if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcjson.GetBlockVerboseTxResult); ok { + r0 = rf(blockHash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcjson.GetBlockVerboseTxResult) + } + } + + if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { + r1 = rf(blockHash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -func (c *MockBTCRPCClient) GetBlockVerboseTx(_ *chainhash.Hash) (*btcjson.GetBlockVerboseTxResult, error) { - if c.err != nil { - return nil, c.err +// GetNetworkInfo provides a mock function with given fields: +func (_m *BTCRPCClient) GetNetworkInfo() (*btcjson.GetNetworkInfoResult, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetNetworkInfo") } - return c.blockVerboseTx, nil + + var r0 *btcjson.GetNetworkInfoResult + var r1 error + if rf, ok := ret.Get(0).(func() (*btcjson.GetNetworkInfoResult, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *btcjson.GetNetworkInfoResult); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcjson.GetNetworkInfoResult) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -func (c *MockBTCRPCClient) GetBlockHeader(_ *chainhash.Hash) (*wire.BlockHeader, error) { - if c.err != nil { - return nil, c.err +// GetNewAddress provides a mock function with given fields: account +func (_m *BTCRPCClient) GetNewAddress(account string) (btcutil.Address, error) { + ret := _m.Called(account) + + if len(ret) == 0 { + panic("no return value specified for GetNewAddress") + } + + var r0 btcutil.Address + var r1 error + if rf, ok := ret.Get(0).(func(string) (btcutil.Address, error)); ok { + return rf(account) + } + if rf, ok := ret.Get(0).(func(string) btcutil.Address); ok { + r0 = rf(account) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(btcutil.Address) + } + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(account) + } else { + r1 = ret.Error(1) } - return c.blockHeader, nil + + return r0, r1 } -// ---------------------------------------------------------------------------- -// Feed data to the mock BTC RPC client for testing -// ---------------------------------------------------------------------------- +// GetRawTransaction provides a mock function with given fields: txHash +func (_m *BTCRPCClient) GetRawTransaction(txHash *chainhash.Hash) (*btcutil.Tx, error) { + ret := _m.Called(txHash) + + if len(ret) == 0 { + panic("no return value specified for GetRawTransaction") + } -func (c *MockBTCRPCClient) WithError(err error) *MockBTCRPCClient { - c.err = err - return c + var r0 *btcutil.Tx + var r1 error + if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcutil.Tx, error)); ok { + return rf(txHash) + } + if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcutil.Tx); ok { + r0 = rf(txHash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcutil.Tx) + } + } + + if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { + r1 = rf(txHash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -func (c *MockBTCRPCClient) WithBlockCount(blkCnt int64) *MockBTCRPCClient { - c.blockCount = blkCnt - return c +// GetRawTransactionVerbose provides a mock function with given fields: txHash +func (_m *BTCRPCClient) GetRawTransactionVerbose(txHash *chainhash.Hash) (*btcjson.TxRawResult, error) { + ret := _m.Called(txHash) + + if len(ret) == 0 { + panic("no return value specified for GetRawTransactionVerbose") + } + + var r0 *btcjson.TxRawResult + var r1 error + if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcjson.TxRawResult, error)); ok { + return rf(txHash) + } + if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcjson.TxRawResult); ok { + r0 = rf(txHash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcjson.TxRawResult) + } + } + + if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { + r1 = rf(txHash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -func (c *MockBTCRPCClient) WithBlockHash(hash *chainhash.Hash) *MockBTCRPCClient { - c.blockHash = hash - return c +// GetTransaction provides a mock function with given fields: txHash +func (_m *BTCRPCClient) GetTransaction(txHash *chainhash.Hash) (*btcjson.GetTransactionResult, error) { + ret := _m.Called(txHash) + + if len(ret) == 0 { + panic("no return value specified for GetTransaction") + } + + var r0 *btcjson.GetTransactionResult + var r1 error + if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcjson.GetTransactionResult, error)); ok { + return rf(txHash) + } + if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcjson.GetTransactionResult); ok { + r0 = rf(txHash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcjson.GetTransactionResult) + } + } + + if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { + r1 = rf(txHash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -func (c *MockBTCRPCClient) WithBlockHeader(header *wire.BlockHeader) *MockBTCRPCClient { - c.blockHeader = header - return c +// ListUnspent provides a mock function with given fields: +func (_m *BTCRPCClient) ListUnspent() ([]btcjson.ListUnspentResult, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for ListUnspent") + } + + var r0 []btcjson.ListUnspentResult + var r1 error + if rf, ok := ret.Get(0).(func() ([]btcjson.ListUnspentResult, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []btcjson.ListUnspentResult); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]btcjson.ListUnspentResult) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -func (c *MockBTCRPCClient) WithBlockVerboseTx(block *btcjson.GetBlockVerboseTxResult) *MockBTCRPCClient { - c.blockVerboseTx = block - return c +// ListUnspentMinMaxAddresses provides a mock function with given fields: minConf, maxConf, addrs +func (_m *BTCRPCClient) ListUnspentMinMaxAddresses(minConf int, maxConf int, addrs []btcutil.Address) ([]btcjson.ListUnspentResult, error) { + ret := _m.Called(minConf, maxConf, addrs) + + if len(ret) == 0 { + panic("no return value specified for ListUnspentMinMaxAddresses") + } + + var r0 []btcjson.ListUnspentResult + var r1 error + if rf, ok := ret.Get(0).(func(int, int, []btcutil.Address) ([]btcjson.ListUnspentResult, error)); ok { + return rf(minConf, maxConf, addrs) + } + if rf, ok := ret.Get(0).(func(int, int, []btcutil.Address) []btcjson.ListUnspentResult); ok { + r0 = rf(minConf, maxConf, addrs) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]btcjson.ListUnspentResult) + } + } + + if rf, ok := ret.Get(1).(func(int, int, []btcutil.Address) error); ok { + r1 = rf(minConf, maxConf, addrs) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -func (c *MockBTCRPCClient) WithRawTransaction(tx *btcutil.Tx) *MockBTCRPCClient { - c.Txs = append(c.Txs, tx) - return c +// SendRawTransaction provides a mock function with given fields: tx, allowHighFees +func (_m *BTCRPCClient) SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) (*chainhash.Hash, error) { + ret := _m.Called(tx, allowHighFees) + + if len(ret) == 0 { + panic("no return value specified for SendRawTransaction") + } + + var r0 *chainhash.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*wire.MsgTx, bool) (*chainhash.Hash, error)); ok { + return rf(tx, allowHighFees) + } + if rf, ok := ret.Get(0).(func(*wire.MsgTx, bool) *chainhash.Hash); ok { + r0 = rf(tx, allowHighFees) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*chainhash.Hash) + } + } + + if rf, ok := ret.Get(1).(func(*wire.MsgTx, bool) error); ok { + r1 = rf(tx, allowHighFees) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -func (c *MockBTCRPCClient) WithRawTransactions(txs []*btcutil.Tx) *MockBTCRPCClient { - c.Txs = append(c.Txs, txs...) - return c +// NewBTCRPCClient creates a new instance of BTCRPCClient. 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 NewBTCRPCClient(t interface { + mock.TestingT + Cleanup(func()) +}) *BTCRPCClient { + mock := &BTCRPCClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock } diff --git a/zetaclient/testutils/mocks/btc_rpc_mock.go b/zetaclient/testutils/mocks/btc_rpc_mock.go deleted file mode 100644 index e1f56ee2a4..0000000000 --- a/zetaclient/testutils/mocks/btc_rpc_mock.go +++ /dev/null @@ -1,548 +0,0 @@ -// Code generated by mockery v2.42.2. DO NOT EDIT. - -package mocks - -import ( - btcjson "github.com/btcsuite/btcd/btcjson" - btcutil "github.com/btcsuite/btcutil" - - chainhash "github.com/btcsuite/btcd/chaincfg/chainhash" - - mock "github.com/stretchr/testify/mock" - - rpcclient "github.com/btcsuite/btcd/rpcclient" - - wire "github.com/btcsuite/btcd/wire" -) - -// BTCRPCClient is an autogenerated mock type for the BTCRPCClient type -type BTCRPCClient struct { - mock.Mock -} - -// CreateWallet provides a mock function with given fields: name, opts -func (_m *BTCRPCClient) CreateWallet(name string, opts ...rpcclient.CreateWalletOpt) (*btcjson.CreateWalletResult, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, name) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for CreateWallet") - } - - var r0 *btcjson.CreateWalletResult - var r1 error - if rf, ok := ret.Get(0).(func(string, ...rpcclient.CreateWalletOpt) (*btcjson.CreateWalletResult, error)); ok { - return rf(name, opts...) - } - if rf, ok := ret.Get(0).(func(string, ...rpcclient.CreateWalletOpt) *btcjson.CreateWalletResult); ok { - r0 = rf(name, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcjson.CreateWalletResult) - } - } - - if rf, ok := ret.Get(1).(func(string, ...rpcclient.CreateWalletOpt) error); ok { - r1 = rf(name, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// EstimateSmartFee provides a mock function with given fields: confTarget, mode -func (_m *BTCRPCClient) EstimateSmartFee(confTarget int64, mode *btcjson.EstimateSmartFeeMode) (*btcjson.EstimateSmartFeeResult, error) { - ret := _m.Called(confTarget, mode) - - if len(ret) == 0 { - panic("no return value specified for EstimateSmartFee") - } - - var r0 *btcjson.EstimateSmartFeeResult - var r1 error - if rf, ok := ret.Get(0).(func(int64, *btcjson.EstimateSmartFeeMode) (*btcjson.EstimateSmartFeeResult, error)); ok { - return rf(confTarget, mode) - } - if rf, ok := ret.Get(0).(func(int64, *btcjson.EstimateSmartFeeMode) *btcjson.EstimateSmartFeeResult); ok { - r0 = rf(confTarget, mode) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcjson.EstimateSmartFeeResult) - } - } - - if rf, ok := ret.Get(1).(func(int64, *btcjson.EstimateSmartFeeMode) error); ok { - r1 = rf(confTarget, mode) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GenerateToAddress provides a mock function with given fields: numBlocks, address, maxTries -func (_m *BTCRPCClient) GenerateToAddress(numBlocks int64, address btcutil.Address, maxTries *int64) ([]*chainhash.Hash, error) { - ret := _m.Called(numBlocks, address, maxTries) - - if len(ret) == 0 { - panic("no return value specified for GenerateToAddress") - } - - var r0 []*chainhash.Hash - var r1 error - if rf, ok := ret.Get(0).(func(int64, btcutil.Address, *int64) ([]*chainhash.Hash, error)); ok { - return rf(numBlocks, address, maxTries) - } - if rf, ok := ret.Get(0).(func(int64, btcutil.Address, *int64) []*chainhash.Hash); ok { - r0 = rf(numBlocks, address, maxTries) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*chainhash.Hash) - } - } - - if rf, ok := ret.Get(1).(func(int64, btcutil.Address, *int64) error); ok { - r1 = rf(numBlocks, address, maxTries) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBalance provides a mock function with given fields: account -func (_m *BTCRPCClient) GetBalance(account string) (btcutil.Amount, error) { - ret := _m.Called(account) - - if len(ret) == 0 { - panic("no return value specified for GetBalance") - } - - var r0 btcutil.Amount - var r1 error - if rf, ok := ret.Get(0).(func(string) (btcutil.Amount, error)); ok { - return rf(account) - } - if rf, ok := ret.Get(0).(func(string) btcutil.Amount); ok { - r0 = rf(account) - } else { - r0 = ret.Get(0).(btcutil.Amount) - } - - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(account) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBlockCount provides a mock function with given fields: -func (_m *BTCRPCClient) GetBlockCount() (int64, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetBlockCount") - } - - var r0 int64 - var r1 error - if rf, ok := ret.Get(0).(func() (int64, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() int64); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(int64) - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBlockHash provides a mock function with given fields: blockHeight -func (_m *BTCRPCClient) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) { - ret := _m.Called(blockHeight) - - if len(ret) == 0 { - panic("no return value specified for GetBlockHash") - } - - var r0 *chainhash.Hash - var r1 error - if rf, ok := ret.Get(0).(func(int64) (*chainhash.Hash, error)); ok { - return rf(blockHeight) - } - if rf, ok := ret.Get(0).(func(int64) *chainhash.Hash); ok { - r0 = rf(blockHeight) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*chainhash.Hash) - } - } - - if rf, ok := ret.Get(1).(func(int64) error); ok { - r1 = rf(blockHeight) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBlockHeader provides a mock function with given fields: blockHash -func (_m *BTCRPCClient) GetBlockHeader(blockHash *chainhash.Hash) (*wire.BlockHeader, error) { - ret := _m.Called(blockHash) - - if len(ret) == 0 { - panic("no return value specified for GetBlockHeader") - } - - var r0 *wire.BlockHeader - var r1 error - if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*wire.BlockHeader, error)); ok { - return rf(blockHash) - } - if rf, ok := ret.Get(0).(func(*chainhash.Hash) *wire.BlockHeader); ok { - r0 = rf(blockHash) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*wire.BlockHeader) - } - } - - if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { - r1 = rf(blockHash) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBlockVerbose provides a mock function with given fields: blockHash -func (_m *BTCRPCClient) GetBlockVerbose(blockHash *chainhash.Hash) (*btcjson.GetBlockVerboseResult, error) { - ret := _m.Called(blockHash) - - if len(ret) == 0 { - panic("no return value specified for GetBlockVerbose") - } - - var r0 *btcjson.GetBlockVerboseResult - var r1 error - if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcjson.GetBlockVerboseResult, error)); ok { - return rf(blockHash) - } - if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcjson.GetBlockVerboseResult); ok { - r0 = rf(blockHash) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcjson.GetBlockVerboseResult) - } - } - - if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { - r1 = rf(blockHash) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBlockVerboseTx provides a mock function with given fields: blockHash -func (_m *BTCRPCClient) GetBlockVerboseTx(blockHash *chainhash.Hash) (*btcjson.GetBlockVerboseTxResult, error) { - ret := _m.Called(blockHash) - - if len(ret) == 0 { - panic("no return value specified for GetBlockVerboseTx") - } - - var r0 *btcjson.GetBlockVerboseTxResult - var r1 error - if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcjson.GetBlockVerboseTxResult, error)); ok { - return rf(blockHash) - } - if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcjson.GetBlockVerboseTxResult); ok { - r0 = rf(blockHash) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcjson.GetBlockVerboseTxResult) - } - } - - if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { - r1 = rf(blockHash) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetNetworkInfo provides a mock function with given fields: -func (_m *BTCRPCClient) GetNetworkInfo() (*btcjson.GetNetworkInfoResult, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetNetworkInfo") - } - - var r0 *btcjson.GetNetworkInfoResult - var r1 error - if rf, ok := ret.Get(0).(func() (*btcjson.GetNetworkInfoResult, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() *btcjson.GetNetworkInfoResult); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcjson.GetNetworkInfoResult) - } - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetNewAddress provides a mock function with given fields: account -func (_m *BTCRPCClient) GetNewAddress(account string) (btcutil.Address, error) { - ret := _m.Called(account) - - if len(ret) == 0 { - panic("no return value specified for GetNewAddress") - } - - var r0 btcutil.Address - var r1 error - if rf, ok := ret.Get(0).(func(string) (btcutil.Address, error)); ok { - return rf(account) - } - if rf, ok := ret.Get(0).(func(string) btcutil.Address); ok { - r0 = rf(account) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(btcutil.Address) - } - } - - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(account) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetRawTransaction provides a mock function with given fields: txHash -func (_m *BTCRPCClient) GetRawTransaction(txHash *chainhash.Hash) (*btcutil.Tx, error) { - ret := _m.Called(txHash) - - if len(ret) == 0 { - panic("no return value specified for GetRawTransaction") - } - - var r0 *btcutil.Tx - var r1 error - if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcutil.Tx, error)); ok { - return rf(txHash) - } - if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcutil.Tx); ok { - r0 = rf(txHash) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcutil.Tx) - } - } - - if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { - r1 = rf(txHash) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetRawTransactionVerbose provides a mock function with given fields: txHash -func (_m *BTCRPCClient) GetRawTransactionVerbose(txHash *chainhash.Hash) (*btcjson.TxRawResult, error) { - ret := _m.Called(txHash) - - if len(ret) == 0 { - panic("no return value specified for GetRawTransactionVerbose") - } - - var r0 *btcjson.TxRawResult - var r1 error - if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcjson.TxRawResult, error)); ok { - return rf(txHash) - } - if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcjson.TxRawResult); ok { - r0 = rf(txHash) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcjson.TxRawResult) - } - } - - if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { - r1 = rf(txHash) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetTransaction provides a mock function with given fields: txHash -func (_m *BTCRPCClient) GetTransaction(txHash *chainhash.Hash) (*btcjson.GetTransactionResult, error) { - ret := _m.Called(txHash) - - if len(ret) == 0 { - panic("no return value specified for GetTransaction") - } - - var r0 *btcjson.GetTransactionResult - var r1 error - if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcjson.GetTransactionResult, error)); ok { - return rf(txHash) - } - if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcjson.GetTransactionResult); ok { - r0 = rf(txHash) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcjson.GetTransactionResult) - } - } - - if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { - r1 = rf(txHash) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// ListUnspent provides a mock function with given fields: -func (_m *BTCRPCClient) ListUnspent() ([]btcjson.ListUnspentResult, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for ListUnspent") - } - - var r0 []btcjson.ListUnspentResult - var r1 error - if rf, ok := ret.Get(0).(func() ([]btcjson.ListUnspentResult, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() []btcjson.ListUnspentResult); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]btcjson.ListUnspentResult) - } - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// ListUnspentMinMaxAddresses provides a mock function with given fields: minConf, maxConf, addrs -func (_m *BTCRPCClient) ListUnspentMinMaxAddresses(minConf int, maxConf int, addrs []btcutil.Address) ([]btcjson.ListUnspentResult, error) { - ret := _m.Called(minConf, maxConf, addrs) - - if len(ret) == 0 { - panic("no return value specified for ListUnspentMinMaxAddresses") - } - - var r0 []btcjson.ListUnspentResult - var r1 error - if rf, ok := ret.Get(0).(func(int, int, []btcutil.Address) ([]btcjson.ListUnspentResult, error)); ok { - return rf(minConf, maxConf, addrs) - } - if rf, ok := ret.Get(0).(func(int, int, []btcutil.Address) []btcjson.ListUnspentResult); ok { - r0 = rf(minConf, maxConf, addrs) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]btcjson.ListUnspentResult) - } - } - - if rf, ok := ret.Get(1).(func(int, int, []btcutil.Address) error); ok { - r1 = rf(minConf, maxConf, addrs) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// SendRawTransaction provides a mock function with given fields: tx, allowHighFees -func (_m *BTCRPCClient) SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) (*chainhash.Hash, error) { - ret := _m.Called(tx, allowHighFees) - - if len(ret) == 0 { - panic("no return value specified for SendRawTransaction") - } - - var r0 *chainhash.Hash - var r1 error - if rf, ok := ret.Get(0).(func(*wire.MsgTx, bool) (*chainhash.Hash, error)); ok { - return rf(tx, allowHighFees) - } - if rf, ok := ret.Get(0).(func(*wire.MsgTx, bool) *chainhash.Hash); ok { - r0 = rf(tx, allowHighFees) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*chainhash.Hash) - } - } - - if rf, ok := ret.Get(1).(func(*wire.MsgTx, bool) error); ok { - r1 = rf(tx, allowHighFees) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// NewBTCRPCClient creates a new instance of BTCRPCClient. 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 NewBTCRPCClient(t interface { - mock.TestingT - Cleanup(func()) -}) *BTCRPCClient { - mock := &BTCRPCClient{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -}