From 313b25c9eafdf24d2fca39c813d145e1267899ea Mon Sep 17 00:00:00 2001 From: AndresQuijano Date: Thu, 21 Nov 2024 14:34:56 +0000 Subject: [PATCH] feat: refactor refund user pegout script - add tests --- .../refund_user_pegout/refund_user_pegout.go | 81 +++-------------- .../refund_user_pegout_test.go | 90 +++++++++++++++++++ .../dataproviders/rootstock/bindings.go | 4 +- .../adapters/dataproviders/rootstock/lbc.go | 27 +++++- internal/entities/blockchain/lbc.go | 4 +- test/mocks/abstract_factory_mock.go | 2 +- test/mocks/bitcoin_wallet_mock.go | 2 +- test/mocks/client_adapter_mock.go | 2 +- test/mocks/collection_binding_mock.go | 2 +- test/mocks/db_binding_mock.go | 2 +- test/mocks/db_client_binding_mock.go | 2 +- .../default_credentials_provider_mock.go | 2 +- test/mocks/event_iterator_adapter_mock.go | 2 +- test/mocks/http_client_mock.go | 2 +- test/mocks/lbc_adapter_mock.go | 61 ++++++++++++- test/mocks/lbc_binding_mock.go | 61 ++++++++++++- test/mocks/lbc_mock.go | 6 ++ .../liquidity_provider_repository_mock.go | 2 +- test/mocks/pegin_quote_repository_mock.go | 2 +- test/mocks/pegout_quote_repository_mock.go | 2 +- test/mocks/rootstock_rpc_server_mock.go | 2 +- test/mocks/rpc_client_binding_mock.go | 2 +- test/mocks/rpc_client_mock.go | 2 +- test/mocks/rsk_bridge_binding_mock.go | 2 +- test/mocks/rsk_signer_wallet_mock.go | 2 +- test/mocks/ses_client_mock.go | 2 +- test/mocks/session_binding_mock.go | 2 +- test/mocks/store_mock.go | 2 +- test/mocks/ticker_mock.go | 2 +- test/mocks/transaction_signer_mock.go | 2 +- test/mocks/use_case_registry_mock.go | 2 +- 31 files changed, 280 insertions(+), 100 deletions(-) create mode 100644 cmd/utils/refund_user_pegout/refund_user_pegout_test.go diff --git a/cmd/utils/refund_user_pegout/refund_user_pegout.go b/cmd/utils/refund_user_pegout/refund_user_pegout.go index b10ba721..83216a27 100644 --- a/cmd/utils/refund_user_pegout/refund_user_pegout.go +++ b/cmd/utils/refund_user_pegout/refund_user_pegout.go @@ -4,19 +4,14 @@ import ( "context" "flag" "fmt" - "os" "syscall" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" "github.com/go-playground/validator/v10" "github.com/rsksmart/liquidity-provider-server/cmd/utils/defaults" - "github.com/rsksmart/liquidity-provider-server/internal/adapters/dataproviders/rootstock" - "github.com/rsksmart/liquidity-provider-server/internal/adapters/dataproviders/rootstock/bindings" + "github.com/rsksmart/liquidity-provider-server/cmd/utils/scripts" "github.com/rsksmart/liquidity-provider-server/internal/configuration/bootstrap" - "github.com/rsksmart/liquidity-provider-server/internal/configuration/bootstrap/wallet" "github.com/rsksmart/liquidity-provider-server/internal/configuration/environment" - "github.com/rsksmart/liquidity-provider-server/internal/configuration/environment/secrets" + "github.com/rsksmart/liquidity-provider-server/internal/entities/blockchain" "golang.org/x/term" ) @@ -36,46 +31,24 @@ type RefundUserPegOutScriptInput struct { type PasswordReader = func(int) ([]byte, error) func main() { - ctx := context.Background() - scriptInput := new(RefundUserPegOutScriptInput) ReadRefundUserPegOutScriptInput(scriptInput) env, err := ParseRefundUserPegOutScriptInput(scriptInput, term.ReadPassword) if err != nil { - ExitWithError(2, "Error reading input", err) - } - - rskClient, err := bootstrap.Rootstock(ctx, env.Rsk) - if err != nil { - ExitWithError(2, "Error connecting to RSK node", err) - } - rskWallet, err := GetWallet(ctx, env, rskClient) - if err != nil { - ExitWithError(2, "Error accessing to wallet", err) + scripts.ExitWithError(2, "Error reading input", err) } - err = ExecuteRefundUserPegOut(ctx, env, rskWallet, rskClient, common.HexToHash(scriptInput.QuoteHashBytes)) + ctx := context.Background() + lbc, err := scripts.CreateLiquidityBridgeContract(ctx, bootstrap.Rootstock, env) if err != nil { - ExitWithError(2, "Error on transaction execution", err) + scripts.ExitWithError(2, "Error accessing the Liquidity Bridge Contract", err) } -} -func GetWallet( - ctx context.Context, - env environment.Environment, - rskClient *rootstock.RskClient, -) (rootstock.RskSignerWallet, error) { - secretLoader, err := secrets.GetSecretLoader(ctx, env) + txHash, err := ExecuteRefundUserPegOut(lbc, scriptInput.QuoteHashBytes) if err != nil { - return nil, err + scripts.ExitWithError(2, "Error on transaction execution", err) } - walletFactory, err := wallet.NewFactory(env, wallet.FactoryCreationArgs{ - Ctx: ctx, Env: env, SecretLoader: secretLoader, RskClient: rskClient, - }) - if err != nil { - return nil, err - } - return walletFactory.RskWallet() + fmt.Println("Refund user peg out executed successfully. Transaction hash: ", txHash) } func ReadRefundUserPegOutScriptInput(scriptInput *RefundUserPegOutScriptInput) { @@ -142,38 +115,6 @@ func ParseRefundUserPegOutScriptInput(scriptInput *RefundUserPegOutScriptInput, return env, nil } -func ExecuteRefundUserPegOut( - ctx context.Context, - env environment.Environment, - rskWallet rootstock.RskSignerWallet, - rskClient *rootstock.RskClient, - quoteHashBytes common.Hash, -) error { - lbc, err := bindings.NewLiquidityBridgeContract(common.HexToAddress(env.Rsk.LbcAddress), rskClient.Rpc()) - if err != nil { - return err - } - - opts := &bind.TransactOpts{From: rskWallet.Address(), Signer: rskWallet.Sign} - tx, err := lbc.RefundUserPegOut(opts, quoteHashBytes) - if err != nil { - return err - } - - receipt, err := bind.WaitMined(ctx, rskClient.Rpc(), tx) - if err != nil { - return err - } - - if receipt.Status == 1 { - fmt.Println("Refund user peg out executed successfully. Transaction hash: ", receipt.TxHash.Hex()) - return nil - } else { - return fmt.Errorf("transaction %s failed", receipt.TxHash.Hex()) - } -} - -func ExitWithError(code int, message string, err error) { - fmt.Println(fmt.Sprintf("%s: %s", message, err.Error())) - os.Exit(code) +func ExecuteRefundUserPegOut(lbc blockchain.LiquidityBridgeContract, quoteHash string) (string, error) { + return lbc.RefundUserPegOut(quoteHash) } diff --git a/cmd/utils/refund_user_pegout/refund_user_pegout_test.go b/cmd/utils/refund_user_pegout/refund_user_pegout_test.go new file mode 100644 index 00000000..ad0c6f5e --- /dev/null +++ b/cmd/utils/refund_user_pegout/refund_user_pegout_test.go @@ -0,0 +1,90 @@ +package main + +import ( + "flag" + "testing" + + "github.com/rsksmart/liquidity-provider-server/test" + "github.com/rsksmart/liquidity-provider-server/test/mocks" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "golang.org/x/term" +) + +func TestReadRefundUserPegOutScriptInput(t *testing.T) { + t.Run("should set flag values", func(t *testing.T) { + // Reset flags before test + flag.CommandLine = flag.NewFlagSet("", flag.ExitOnError) + + scriptInput := new(RefundUserPegOutScriptInput) + ReadRefundUserPegOutScriptInput(scriptInput) + + // Set test values + err := flag.CommandLine.Parse([]string{ + "-network", "regtest", + "-quote-hash", "d93f58c82100a6cee4f19ac505c11d51b52cafe220f7f1944b70496f33d277fc", + "-rsk-endpoint", "http://localhost:4444", + "-secret-src", "env", + "-keystore-file", "./keystore.json", + }) + require.NoError(t, err) + + assert.Equal(t, "regtest", scriptInput.Network) + assert.Equal(t, "d93f58c82100a6cee4f19ac505c11d51b52cafe220f7f1944b70496f33d277fc", scriptInput.QuoteHashBytes) + assert.Equal(t, "http://localhost:4444", scriptInput.RskEndpoint) + assert.Equal(t, "env", scriptInput.SecretSource) + assert.Equal(t, "./keystore.json", scriptInput.KeystoreFile) + }) +} + +func TestParseRefundUserPegOutScriptInput(t *testing.T) { + t.Run("should validate required fields", func(t *testing.T) { + scriptInput := &RefundUserPegOutScriptInput{ + Network: "", + QuoteHashBytes: "", + RskEndpoint: "", + SecretSource: "", + } + + _, err := ParseRefundUserPegOutScriptInput(scriptInput, term.ReadPassword) + require.Error(t, err) + assert.Contains(t, err.Error(), "invalid input") + }) + + t.Run("should parse valid input", func(t *testing.T) { + scriptInput := &RefundUserPegOutScriptInput{ + Network: "regtest", + QuoteHashBytes: "d93f58c82100a6cee4f19ac505c11d51b52cafe220f7f1944b70496f33d277fc", + RskEndpoint: "http://localhost:4444", + SecretSource: "aws", + AwsLocalEndpoint: "http://localhost:4566", + } + + env, err := ParseRefundUserPegOutScriptInput(scriptInput, func(fd int) ([]byte, error) { + return []byte("password"), nil + }) + require.NoError(t, err) + assert.Equal(t, "regtest", env.LpsStage) + assert.Equal(t, "http://localhost:4444", env.Rsk.Endpoint) + assert.Equal(t, "aws", env.SecretSource) + assert.Equal(t, "http://localhost:4566", env.AwsLocalEndpoint) + }) +} + +func TestRefundUserPegOut(t *testing.T) { + t.Run("should execute refund user peg out successfully", func(t *testing.T) { + lbc := &mocks.LbcMock{} + quoteHash := "d93f58c82100a6cee4f19ac505c11d51b52cafe220f7f1944b70496f33d277fc" + expectedTxHash := test.AnyHash + + // Setup mock expectations + lbc.On("RefundUserPegOut", quoteHash).Return(expectedTxHash, nil) + + txHash, err := ExecuteRefundUserPegOut(lbc, quoteHash) + require.NoError(t, err) + assert.Equal(t, expectedTxHash, txHash) + + // Verify all expectations were met + lbc.AssertExpectations(t) + }) +} diff --git a/internal/adapters/dataproviders/rootstock/bindings.go b/internal/adapters/dataproviders/rootstock/bindings.go index 6f8f35fe..404809a3 100644 --- a/internal/adapters/dataproviders/rootstock/bindings.go +++ b/internal/adapters/dataproviders/rootstock/bindings.go @@ -2,12 +2,13 @@ package rootstock import ( "context" + "math/big" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/rsksmart/liquidity-provider-server/internal/adapters/dataproviders/rootstock/bindings" - "math/big" ) type RpcClientBinding interface { @@ -70,6 +71,7 @@ type LbcBinding interface { ProductFeePercentage(opts *bind.CallOpts) (*big.Int, error) IsPegOutQuoteCompleted(opts *bind.CallOpts, quoteHash [32]byte) (bool, error) UpdateProvider(opts *bind.TransactOpts, _name string, _url string) (*types.Transaction, error) + RefundUserPegOut(opts *bind.TransactOpts, quoteHash [32]byte) (*types.Transaction, error) } type LbcAdapter interface { diff --git a/internal/adapters/dataproviders/rootstock/lbc.go b/internal/adapters/dataproviders/rootstock/lbc.go index 444461e0..bffc6763 100644 --- a/internal/adapters/dataproviders/rootstock/lbc.go +++ b/internal/adapters/dataproviders/rootstock/lbc.go @@ -5,6 +5,10 @@ import ( "encoding/hex" "errors" "fmt" + "math/big" + "strings" + "time" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" geth "github.com/ethereum/go-ethereum/core/types" @@ -15,9 +19,6 @@ import ( "github.com/rsksmart/liquidity-provider-server/internal/entities/liquidity_provider" "github.com/rsksmart/liquidity-provider-server/internal/entities/quote" log "github.com/sirupsen/logrus" - "math/big" - "strings" - "time" ) // registerPeginGasLimit Fixed gas limit for registerPegin function, should change only if the function does @@ -612,6 +613,26 @@ func (lbc *liquidityBridgeContractImpl) UpdateProvider(name, url string) (string return receipt.TxHash.String(), nil } +func (lbc *liquidityBridgeContractImpl) RefundUserPegOut(quoteHash string) (string, error) { + opts := &bind.TransactOpts{ + From: lbc.signer.Address(), + Signer: lbc.signer.Sign, + } + receipt, err := awaitTx(lbc.client, "RefundUserPegOut", func() (*geth.Transaction, error) { + return lbc.contract.RefundUserPegOut(opts, common.HexToHash(quoteHash)) + }) + + if err != nil { + return "", fmt.Errorf("refund user peg out error: %w", err) + } else if receipt == nil { + return "", errors.New("refund user peg out error: incomplete receipt") + } else if receipt.Status == 0 { + txHash := receipt.TxHash.String() + return txHash, fmt.Errorf("refund user peg out error: transaction reverted (%s)", txHash) + } + return receipt.TxHash.String(), nil +} + // parsePeginQuote parses a quote.PeginQuote into a bindings.QuotesPeginQuote. All BTC address fields support all address types // except for FedBtcAddress which must be a P2SH address. func parsePeginQuote(peginQuote quote.PeginQuote) (bindings.QuotesPeginQuote, error) { diff --git a/internal/entities/blockchain/lbc.go b/internal/entities/blockchain/lbc.go index 79f6112b..ab4b780c 100644 --- a/internal/entities/blockchain/lbc.go +++ b/internal/entities/blockchain/lbc.go @@ -4,10 +4,11 @@ import ( "context" "encoding/hex" "fmt" + "math/big" + "github.com/rsksmart/liquidity-provider-server/internal/entities" "github.com/rsksmart/liquidity-provider-server/internal/entities/liquidity_provider" "github.com/rsksmart/liquidity-provider-server/internal/entities/quote" - "math/big" ) const ( @@ -100,6 +101,7 @@ type LiquidityBridgeContract interface { GetPeginPunishmentEvents(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]liquidity_provider.PunishmentEvent, error) IsPegOutQuoteCompleted(quoteHash string) (bool, error) UpdateProvider(name, url string) (string, error) + RefundUserPegOut(quoteHash string) (string, error) } type FeeCollector interface { diff --git a/test/mocks/abstract_factory_mock.go b/test/mocks/abstract_factory_mock.go index b14bd1ee..4f0048a5 100644 --- a/test/mocks/abstract_factory_mock.go +++ b/test/mocks/abstract_factory_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/bitcoin_wallet_mock.go b/test/mocks/bitcoin_wallet_mock.go index 638710b4..c004a130 100644 --- a/test/mocks/bitcoin_wallet_mock.go +++ b/test/mocks/bitcoin_wallet_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/client_adapter_mock.go b/test/mocks/client_adapter_mock.go index f29b81e2..68625e3c 100644 --- a/test/mocks/client_adapter_mock.go +++ b/test/mocks/client_adapter_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/collection_binding_mock.go b/test/mocks/collection_binding_mock.go index f6b28685..22bc0c15 100644 --- a/test/mocks/collection_binding_mock.go +++ b/test/mocks/collection_binding_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/db_binding_mock.go b/test/mocks/db_binding_mock.go index 3e5571f5..692599f6 100644 --- a/test/mocks/db_binding_mock.go +++ b/test/mocks/db_binding_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/db_client_binding_mock.go b/test/mocks/db_client_binding_mock.go index af5614e2..d15faf39 100644 --- a/test/mocks/db_client_binding_mock.go +++ b/test/mocks/db_client_binding_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/default_credentials_provider_mock.go b/test/mocks/default_credentials_provider_mock.go index 57315cb7..c31ed0f3 100644 --- a/test/mocks/default_credentials_provider_mock.go +++ b/test/mocks/default_credentials_provider_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/event_iterator_adapter_mock.go b/test/mocks/event_iterator_adapter_mock.go index d023ea16..1fb1fc6d 100644 --- a/test/mocks/event_iterator_adapter_mock.go +++ b/test/mocks/event_iterator_adapter_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/http_client_mock.go b/test/mocks/http_client_mock.go index d455d764..2ad3ca63 100644 --- a/test/mocks/http_client_mock.go +++ b/test/mocks/http_client_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/lbc_adapter_mock.go b/test/mocks/lbc_adapter_mock.go index 69ec0698..47976d7e 100644 --- a/test/mocks/lbc_adapter_mock.go +++ b/test/mocks/lbc_adapter_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks @@ -1341,6 +1341,65 @@ func (_c *LbcAdapterMock_RefundPegOut_Call) RunAndReturn(run func(*bind.Transact return _c } +// RefundUserPegOut provides a mock function with given fields: opts, quoteHash +func (_m *LbcAdapterMock) RefundUserPegOut(opts *bind.TransactOpts, quoteHash [32]byte) (*types.Transaction, error) { + ret := _m.Called(opts, quoteHash) + + if len(ret) == 0 { + panic("no return value specified for RefundUserPegOut") + } + + var r0 *types.Transaction + var r1 error + if rf, ok := ret.Get(0).(func(*bind.TransactOpts, [32]byte) (*types.Transaction, error)); ok { + return rf(opts, quoteHash) + } + if rf, ok := ret.Get(0).(func(*bind.TransactOpts, [32]byte) *types.Transaction); ok { + r0 = rf(opts, quoteHash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.Transaction) + } + } + + if rf, ok := ret.Get(1).(func(*bind.TransactOpts, [32]byte) error); ok { + r1 = rf(opts, quoteHash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// LbcAdapterMock_RefundUserPegOut_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RefundUserPegOut' +type LbcAdapterMock_RefundUserPegOut_Call struct { + *mock.Call +} + +// RefundUserPegOut is a helper method to define mock.On call +// - opts *bind.TransactOpts +// - quoteHash [32]byte +func (_e *LbcAdapterMock_Expecter) RefundUserPegOut(opts interface{}, quoteHash interface{}) *LbcAdapterMock_RefundUserPegOut_Call { + return &LbcAdapterMock_RefundUserPegOut_Call{Call: _e.mock.On("RefundUserPegOut", opts, quoteHash)} +} + +func (_c *LbcAdapterMock_RefundUserPegOut_Call) Run(run func(opts *bind.TransactOpts, quoteHash [32]byte)) *LbcAdapterMock_RefundUserPegOut_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*bind.TransactOpts), args[1].([32]byte)) + }) + return _c +} + +func (_c *LbcAdapterMock_RefundUserPegOut_Call) Return(_a0 *types.Transaction, _a1 error) *LbcAdapterMock_RefundUserPegOut_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *LbcAdapterMock_RefundUserPegOut_Call) RunAndReturn(run func(*bind.TransactOpts, [32]byte) (*types.Transaction, error)) *LbcAdapterMock_RefundUserPegOut_Call { + _c.Call.Return(run) + return _c +} + // Register provides a mock function with given fields: opts, _name, _apiBaseUrl, _status, _providerType func (_m *LbcAdapterMock) Register(opts *bind.TransactOpts, _name string, _apiBaseUrl string, _status bool, _providerType string) (*types.Transaction, error) { ret := _m.Called(opts, _name, _apiBaseUrl, _status, _providerType) diff --git a/test/mocks/lbc_binding_mock.go b/test/mocks/lbc_binding_mock.go index 770daa4a..9143006a 100644 --- a/test/mocks/lbc_binding_mock.go +++ b/test/mocks/lbc_binding_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks @@ -1196,6 +1196,65 @@ func (_c *LbcBindingMock_RefundPegOut_Call) RunAndReturn(run func(*bind.Transact return _c } +// RefundUserPegOut provides a mock function with given fields: opts, quoteHash +func (_m *LbcBindingMock) RefundUserPegOut(opts *bind.TransactOpts, quoteHash [32]byte) (*types.Transaction, error) { + ret := _m.Called(opts, quoteHash) + + if len(ret) == 0 { + panic("no return value specified for RefundUserPegOut") + } + + var r0 *types.Transaction + var r1 error + if rf, ok := ret.Get(0).(func(*bind.TransactOpts, [32]byte) (*types.Transaction, error)); ok { + return rf(opts, quoteHash) + } + if rf, ok := ret.Get(0).(func(*bind.TransactOpts, [32]byte) *types.Transaction); ok { + r0 = rf(opts, quoteHash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.Transaction) + } + } + + if rf, ok := ret.Get(1).(func(*bind.TransactOpts, [32]byte) error); ok { + r1 = rf(opts, quoteHash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// LbcBindingMock_RefundUserPegOut_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RefundUserPegOut' +type LbcBindingMock_RefundUserPegOut_Call struct { + *mock.Call +} + +// RefundUserPegOut is a helper method to define mock.On call +// - opts *bind.TransactOpts +// - quoteHash [32]byte +func (_e *LbcBindingMock_Expecter) RefundUserPegOut(opts interface{}, quoteHash interface{}) *LbcBindingMock_RefundUserPegOut_Call { + return &LbcBindingMock_RefundUserPegOut_Call{Call: _e.mock.On("RefundUserPegOut", opts, quoteHash)} +} + +func (_c *LbcBindingMock_RefundUserPegOut_Call) Run(run func(opts *bind.TransactOpts, quoteHash [32]byte)) *LbcBindingMock_RefundUserPegOut_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*bind.TransactOpts), args[1].([32]byte)) + }) + return _c +} + +func (_c *LbcBindingMock_RefundUserPegOut_Call) Return(_a0 *types.Transaction, _a1 error) *LbcBindingMock_RefundUserPegOut_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *LbcBindingMock_RefundUserPegOut_Call) RunAndReturn(run func(*bind.TransactOpts, [32]byte) (*types.Transaction, error)) *LbcBindingMock_RefundUserPegOut_Call { + _c.Call.Return(run) + return _c +} + // Register provides a mock function with given fields: opts, _name, _apiBaseUrl, _status, _providerType func (_m *LbcBindingMock) Register(opts *bind.TransactOpts, _name string, _apiBaseUrl string, _status bool, _providerType string) (*types.Transaction, error) { ret := _m.Called(opts, _name, _apiBaseUrl, _status, _providerType) diff --git a/test/mocks/lbc_mock.go b/test/mocks/lbc_mock.go index 935fa92a..f76620ca 100644 --- a/test/mocks/lbc_mock.go +++ b/test/mocks/lbc_mock.go @@ -2,6 +2,7 @@ package mocks import ( "context" + "github.com/rsksmart/liquidity-provider-server/internal/entities" "github.com/rsksmart/liquidity-provider-server/internal/entities/blockchain" "github.com/rsksmart/liquidity-provider-server/internal/entities/liquidity_provider" @@ -156,3 +157,8 @@ func (m *LbcMock) UpdateProvider(name, url string) (string, error) { args := m.Called(name, url) return args.String(0), args.Error(1) } + +func (m *LbcMock) RefundUserPegOut(quoteHash string) (string, error) { + args := m.Called(quoteHash) + return args.String(0), args.Error(1) +} diff --git a/test/mocks/liquidity_provider_repository_mock.go b/test/mocks/liquidity_provider_repository_mock.go index f9289b9e..f601d208 100644 --- a/test/mocks/liquidity_provider_repository_mock.go +++ b/test/mocks/liquidity_provider_repository_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/pegin_quote_repository_mock.go b/test/mocks/pegin_quote_repository_mock.go index 05da44b4..7493d13e 100644 --- a/test/mocks/pegin_quote_repository_mock.go +++ b/test/mocks/pegin_quote_repository_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/pegout_quote_repository_mock.go b/test/mocks/pegout_quote_repository_mock.go index 9a92a075..efc13096 100644 --- a/test/mocks/pegout_quote_repository_mock.go +++ b/test/mocks/pegout_quote_repository_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/rootstock_rpc_server_mock.go b/test/mocks/rootstock_rpc_server_mock.go index 496be6d5..19a4bf30 100644 --- a/test/mocks/rootstock_rpc_server_mock.go +++ b/test/mocks/rootstock_rpc_server_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/rpc_client_binding_mock.go b/test/mocks/rpc_client_binding_mock.go index 51009b16..04a3105f 100644 --- a/test/mocks/rpc_client_binding_mock.go +++ b/test/mocks/rpc_client_binding_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/rpc_client_mock.go b/test/mocks/rpc_client_mock.go index 5173a628..6547e5a5 100644 --- a/test/mocks/rpc_client_mock.go +++ b/test/mocks/rpc_client_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/rsk_bridge_binding_mock.go b/test/mocks/rsk_bridge_binding_mock.go index a547f0e0..110f34cb 100644 --- a/test/mocks/rsk_bridge_binding_mock.go +++ b/test/mocks/rsk_bridge_binding_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/rsk_signer_wallet_mock.go b/test/mocks/rsk_signer_wallet_mock.go index a6f59ea3..9ab828da 100644 --- a/test/mocks/rsk_signer_wallet_mock.go +++ b/test/mocks/rsk_signer_wallet_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/ses_client_mock.go b/test/mocks/ses_client_mock.go index cf72e605..39fd7f05 100644 --- a/test/mocks/ses_client_mock.go +++ b/test/mocks/ses_client_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/session_binding_mock.go b/test/mocks/session_binding_mock.go index 172197a9..7de46faf 100644 --- a/test/mocks/session_binding_mock.go +++ b/test/mocks/session_binding_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/store_mock.go b/test/mocks/store_mock.go index 685bc881..b0c1ac36 100644 --- a/test/mocks/store_mock.go +++ b/test/mocks/store_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/ticker_mock.go b/test/mocks/ticker_mock.go index 5ef8acf5..9468d69c 100644 --- a/test/mocks/ticker_mock.go +++ b/test/mocks/ticker_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/transaction_signer_mock.go b/test/mocks/transaction_signer_mock.go index ef5a3adb..7cf309b3 100644 --- a/test/mocks/transaction_signer_mock.go +++ b/test/mocks/transaction_signer_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/test/mocks/use_case_registry_mock.go b/test/mocks/use_case_registry_mock.go index bb4237b6..404b4dba 100644 --- a/test/mocks/use_case_registry_mock.go +++ b/test/mocks/use_case_registry_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks