From a6cd51028633274fbe388bb3460048711c3de06c Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Tue, 7 Nov 2023 13:11:53 -0300 Subject: [PATCH 01/18] done --- x/metoken/expected_keepers.go | 1 + x/metoken/keeper/mocks_test.go | 4 + x/metoken/keeper/price.go | 21 + x/metoken/keeper/price_test.go | 7 + x/metoken/mocks/keepers.go | 1969 +++++++++++++++++++++++++++++--- x/metoken/module/abci.go | 1 + x/oracle/keeper/hooks.go | 6 + 7 files changed, 1820 insertions(+), 189 deletions(-) diff --git a/x/metoken/expected_keepers.go b/x/metoken/expected_keepers.go index 64e2838981..5c021ece9d 100644 --- a/x/metoken/expected_keepers.go +++ b/x/metoken/expected_keepers.go @@ -34,4 +34,5 @@ type LeverageKeeper interface { // OracleKeeper interface for price feed. type OracleKeeper interface { AllMedianPrices(ctx sdk.Context) otypes.Prices + SetExchangeRateWithEvent(ctx sdk.Context, denom string, rate sdk.Dec) } diff --git a/x/metoken/keeper/mocks_test.go b/x/metoken/keeper/mocks_test.go index e38825a51c..89703f86b3 100644 --- a/x/metoken/keeper/mocks_test.go +++ b/x/metoken/keeper/mocks_test.go @@ -18,6 +18,10 @@ func (o Oracle) AllMedianPrices(_ sdk.Context) otypes.Prices { return o.prices } +func (o Oracle) SetExchangeRateWithEvent(_ sdk.Context, _ string, _ sdk.Dec) { + return +} + func NewOracleMock() Oracle { return Oracle{prices: mocks.ValidPrices()} } diff --git a/x/metoken/keeper/price.go b/x/metoken/keeper/price.go index 33cf972cd0..5e29891a4e 100644 --- a/x/metoken/keeper/price.go +++ b/x/metoken/keeper/price.go @@ -96,6 +96,27 @@ func (k Keeper) Prices(index metoken.Index) (metoken.IndexPrices, error) { return indexPrices, nil } +// SetPricesToOracle of every registered index. +func (k Keeper) SetPricesToOracle() error { + indexes := k.GetAllRegisteredIndexes() + for _, index := range indexes { + iPrice, err := k.Prices(index) + if err != nil { + k.Logger().Debug( + "setting price to oracle: couldn't calculate the price", + "denom", index.Denom, + "error", err.Error(), + "block_time", k.ctx.BlockTime(), + ) + continue + } + + k.oracleKeeper.SetExchangeRateWithEvent(*k.ctx, index.Denom, iPrice.Price) + } + + return nil +} + // latestPrice from the list of medians, based on the block number. func latestPrice(prices otypes.Prices, symbolDenom string) (sdk.Dec, error) { latestPrice := otypes.Price{} diff --git a/x/metoken/keeper/price_test.go b/x/metoken/keeper/price_test.go index 51d712273e..9c686553fb 100644 --- a/x/metoken/keeper/price_test.go +++ b/x/metoken/keeper/price_test.go @@ -157,6 +157,13 @@ func TestIndexPrices_Convert(t *testing.T) { ) } +func TestIndexPrices_SetPricesToOracle(t *testing.T) { + o := NewOracleMock() + l := NewLeverageMock() + k := initMeUSDKeeper(t, nil, l, o) + require.NoError(t, k.SetPricesToOracle()) +} + func meUSDIndexPricesAdjustedToBalance(t *testing.T, balance metoken.IndexBalances) metoken.IndexPrices { usdtSupply, i := balance.AssetBalance(mocks.USDTBaseDenom) require.True(t, i >= 0) diff --git a/x/metoken/mocks/keepers.go b/x/metoken/mocks/keepers.go index d76c19431d..44ff91b83b 100644 --- a/x/metoken/mocks/keepers.go +++ b/x/metoken/mocks/keepers.go @@ -1,276 +1,1867 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: ./x/metoken/expected_keepers.go +// Code generated by go-mockgen 1.3.7; DO NOT EDIT. -// Package mocks is a generated GoMock package. package mocks import ( - reflect "reflect" + "sync" math "cosmossdk.io/math" types "github.com/cosmos/cosmos-sdk/types" - gomock "github.com/golang/mock/gomock" - types0 "github.com/umee-network/umee/v6/x/leverage/types" - types1 "github.com/umee-network/umee/v6/x/oracle/types" + types1 "github.com/umee-network/umee/v6/x/leverage/types" + metoken "github.com/umee-network/umee/v6/x/metoken" + types2 "github.com/umee-network/umee/v6/x/oracle/types" ) -// MockBankKeeper is a mock of BankKeeper interface. +// MockBankKeeper is a mock implementation of the BankKeeper interface (from +// the package github.com/umee-network/umee/v6/x/metoken) used for unit +// testing. type MockBankKeeper struct { - ctrl *gomock.Controller - recorder *MockBankKeeperMockRecorder + // BurnCoinsFunc is an instance of a mock function object controlling + // the behavior of the method BurnCoins. + BurnCoinsFunc *BankKeeperBurnCoinsFunc + // MintCoinsFunc is an instance of a mock function object controlling + // the behavior of the method MintCoins. + MintCoinsFunc *BankKeeperMintCoinsFunc + // SendCoinsFromAccountToModuleFunc is an instance of a mock function + // object controlling the behavior of the method + // SendCoinsFromAccountToModule. + SendCoinsFromAccountToModuleFunc *BankKeeperSendCoinsFromAccountToModuleFunc + // SendCoinsFromModuleToAccountFunc is an instance of a mock function + // object controlling the behavior of the method + // SendCoinsFromModuleToAccount. + SendCoinsFromModuleToAccountFunc *BankKeeperSendCoinsFromModuleToAccountFunc } -// MockBankKeeperMockRecorder is the mock recorder for MockBankKeeper. -type MockBankKeeperMockRecorder struct { - mock *MockBankKeeper +// NewMockBankKeeper creates a new mock of the BankKeeper interface. All +// methods return zero values for all results, unless overwritten. +func NewMockBankKeeper() *MockBankKeeper { + return &MockBankKeeper{ + BurnCoinsFunc: &BankKeeperBurnCoinsFunc{ + defaultHook: func(types.Context, string, types.Coins) (r0 error) { + return + }, + }, + MintCoinsFunc: &BankKeeperMintCoinsFunc{ + defaultHook: func(types.Context, string, types.Coins) (r0 error) { + return + }, + }, + SendCoinsFromAccountToModuleFunc: &BankKeeperSendCoinsFromAccountToModuleFunc{ + defaultHook: func(types.Context, types.AccAddress, string, types.Coins) (r0 error) { + return + }, + }, + SendCoinsFromModuleToAccountFunc: &BankKeeperSendCoinsFromModuleToAccountFunc{ + defaultHook: func(types.Context, string, types.AccAddress, types.Coins) (r0 error) { + return + }, + }, + } } -// NewMockBankKeeper creates a new mock instance. -func NewMockBankKeeper(ctrl *gomock.Controller) *MockBankKeeper { - mock := &MockBankKeeper{ctrl: ctrl} - mock.recorder = &MockBankKeeperMockRecorder{mock} - return mock +// NewStrictMockBankKeeper creates a new mock of the BankKeeper interface. +// All methods panic on invocation, unless overwritten. +func NewStrictMockBankKeeper() *MockBankKeeper { + return &MockBankKeeper{ + BurnCoinsFunc: &BankKeeperBurnCoinsFunc{ + defaultHook: func(types.Context, string, types.Coins) error { + panic("unexpected invocation of MockBankKeeper.BurnCoins") + }, + }, + MintCoinsFunc: &BankKeeperMintCoinsFunc{ + defaultHook: func(types.Context, string, types.Coins) error { + panic("unexpected invocation of MockBankKeeper.MintCoins") + }, + }, + SendCoinsFromAccountToModuleFunc: &BankKeeperSendCoinsFromAccountToModuleFunc{ + defaultHook: func(types.Context, types.AccAddress, string, types.Coins) error { + panic("unexpected invocation of MockBankKeeper.SendCoinsFromAccountToModule") + }, + }, + SendCoinsFromModuleToAccountFunc: &BankKeeperSendCoinsFromModuleToAccountFunc{ + defaultHook: func(types.Context, string, types.AccAddress, types.Coins) error { + panic("unexpected invocation of MockBankKeeper.SendCoinsFromModuleToAccount") + }, + }, + } } -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { - return m.recorder +// NewMockBankKeeperFrom creates a new mock of the MockBankKeeper interface. +// All methods delegate to the given implementation, unless overwritten. +func NewMockBankKeeperFrom(i metoken.BankKeeper) *MockBankKeeper { + return &MockBankKeeper{ + BurnCoinsFunc: &BankKeeperBurnCoinsFunc{ + defaultHook: i.BurnCoins, + }, + MintCoinsFunc: &BankKeeperMintCoinsFunc{ + defaultHook: i.MintCoins, + }, + SendCoinsFromAccountToModuleFunc: &BankKeeperSendCoinsFromAccountToModuleFunc{ + defaultHook: i.SendCoinsFromAccountToModule, + }, + SendCoinsFromModuleToAccountFunc: &BankKeeperSendCoinsFromModuleToAccountFunc{ + defaultHook: i.SendCoinsFromModuleToAccount, + }, + } } -// BurnCoins mocks base method. -func (m *MockBankKeeper) BurnCoins(ctx types.Context, moduleName string, amounts types.Coins) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "BurnCoins", ctx, moduleName, amounts) - ret0, _ := ret[0].(error) - return ret0 +// BankKeeperBurnCoinsFunc describes the behavior when the BurnCoins method +// of the parent MockBankKeeper instance is invoked. +type BankKeeperBurnCoinsFunc struct { + defaultHook func(types.Context, string, types.Coins) error + hooks []func(types.Context, string, types.Coins) error + history []BankKeeperBurnCoinsFuncCall + mutex sync.Mutex } -// BurnCoins indicates an expected call of BurnCoins. -func (mr *MockBankKeeperMockRecorder) BurnCoins(ctx, moduleName, amounts interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BurnCoins", reflect.TypeOf((*MockBankKeeper)(nil).BurnCoins), ctx, moduleName, amounts) +// BurnCoins delegates to the next hook function in the queue and stores the +// parameter and result values of this invocation. +func (m *MockBankKeeper) BurnCoins(v0 types.Context, v1 string, v2 types.Coins) error { + r0 := m.BurnCoinsFunc.nextHook()(v0, v1, v2) + m.BurnCoinsFunc.appendCall(BankKeeperBurnCoinsFuncCall{v0, v1, v2, r0}) + return r0 } -// MintCoins mocks base method. -func (m *MockBankKeeper) MintCoins(ctx types.Context, moduleName string, amounts types.Coins) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "MintCoins", ctx, moduleName, amounts) - ret0, _ := ret[0].(error) - return ret0 +// SetDefaultHook sets function that is called when the BurnCoins method of +// the parent MockBankKeeper instance is invoked and the hook queue is +// empty. +func (f *BankKeeperBurnCoinsFunc) SetDefaultHook(hook func(types.Context, string, types.Coins) error) { + f.defaultHook = hook } -// MintCoins indicates an expected call of MintCoins. -func (mr *MockBankKeeperMockRecorder) MintCoins(ctx, moduleName, amounts interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MintCoins", reflect.TypeOf((*MockBankKeeper)(nil).MintCoins), ctx, moduleName, amounts) +// PushHook adds a function to the end of hook queue. Each invocation of the +// BurnCoins method of the parent MockBankKeeper instance invokes the hook +// at the front of the queue and discards it. After the queue is empty, the +// default hook function is invoked for any future action. +func (f *BankKeeperBurnCoinsFunc) PushHook(hook func(types.Context, string, types.Coins) error) { + f.mutex.Lock() + f.hooks = append(f.hooks, hook) + f.mutex.Unlock() } -// SendCoinsFromAccountToModule mocks base method. -func (m *MockBankKeeper) SendCoinsFromAccountToModule(ctx types.Context, senderAddr types.AccAddress, recipientModule string, amt types.Coins) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendCoinsFromAccountToModule", ctx, senderAddr, recipientModule, amt) - ret0, _ := ret[0].(error) - return ret0 +// SetDefaultReturn calls SetDefaultHook with a function that returns the +// given values. +func (f *BankKeeperBurnCoinsFunc) SetDefaultReturn(r0 error) { + f.SetDefaultHook(func(types.Context, string, types.Coins) error { + return r0 + }) } -// SendCoinsFromAccountToModule indicates an expected call of SendCoinsFromAccountToModule. -func (mr *MockBankKeeperMockRecorder) SendCoinsFromAccountToModule(ctx, senderAddr, recipientModule, amt interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromAccountToModule", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromAccountToModule), ctx, senderAddr, recipientModule, amt) +// PushReturn calls PushHook with a function that returns the given values. +func (f *BankKeeperBurnCoinsFunc) PushReturn(r0 error) { + f.PushHook(func(types.Context, string, types.Coins) error { + return r0 + }) } -// SendCoinsFromModuleToAccount mocks base method. -func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx types.Context, senderModule string, recipientAddr types.AccAddress, amt types.Coins) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt) - ret0, _ := ret[0].(error) - return ret0 +func (f *BankKeeperBurnCoinsFunc) nextHook() func(types.Context, string, types.Coins) error { + f.mutex.Lock() + defer f.mutex.Unlock() + + if len(f.hooks) == 0 { + return f.defaultHook + } + + hook := f.hooks[0] + f.hooks = f.hooks[1:] + return hook +} + +func (f *BankKeeperBurnCoinsFunc) appendCall(r0 BankKeeperBurnCoinsFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() +} + +// History returns a sequence of BankKeeperBurnCoinsFuncCall objects +// describing the invocations of this function. +func (f *BankKeeperBurnCoinsFunc) History() []BankKeeperBurnCoinsFuncCall { + f.mutex.Lock() + history := make([]BankKeeperBurnCoinsFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history +} + +// BankKeeperBurnCoinsFuncCall is an object that describes an invocation of +// method BurnCoins on an instance of MockBankKeeper. +type BankKeeperBurnCoinsFuncCall struct { + // Arg0 is the value of the 1st argument passed to this method + // invocation. + Arg0 types.Context + // Arg1 is the value of the 2nd argument passed to this method + // invocation. + Arg1 string + // Arg2 is the value of the 3rd argument passed to this method + // invocation. + Arg2 types.Coins + // Result0 is the value of the 1st result returned from this method + // invocation. + Result0 error +} + +// Args returns an interface slice containing the arguments of this +// invocation. +func (c BankKeeperBurnCoinsFuncCall) Args() []interface{} { + return []interface{}{c.Arg0, c.Arg1, c.Arg2} +} + +// Results returns an interface slice containing the results of this +// invocation. +func (c BankKeeperBurnCoinsFuncCall) Results() []interface{} { + return []interface{}{c.Result0} +} + +// BankKeeperMintCoinsFunc describes the behavior when the MintCoins method +// of the parent MockBankKeeper instance is invoked. +type BankKeeperMintCoinsFunc struct { + defaultHook func(types.Context, string, types.Coins) error + hooks []func(types.Context, string, types.Coins) error + history []BankKeeperMintCoinsFuncCall + mutex sync.Mutex +} + +// MintCoins delegates to the next hook function in the queue and stores the +// parameter and result values of this invocation. +func (m *MockBankKeeper) MintCoins(v0 types.Context, v1 string, v2 types.Coins) error { + r0 := m.MintCoinsFunc.nextHook()(v0, v1, v2) + m.MintCoinsFunc.appendCall(BankKeeperMintCoinsFuncCall{v0, v1, v2, r0}) + return r0 +} + +// SetDefaultHook sets function that is called when the MintCoins method of +// the parent MockBankKeeper instance is invoked and the hook queue is +// empty. +func (f *BankKeeperMintCoinsFunc) SetDefaultHook(hook func(types.Context, string, types.Coins) error) { + f.defaultHook = hook +} + +// PushHook adds a function to the end of hook queue. Each invocation of the +// MintCoins method of the parent MockBankKeeper instance invokes the hook +// at the front of the queue and discards it. After the queue is empty, the +// default hook function is invoked for any future action. +func (f *BankKeeperMintCoinsFunc) PushHook(hook func(types.Context, string, types.Coins) error) { + f.mutex.Lock() + f.hooks = append(f.hooks, hook) + f.mutex.Unlock() +} + +// SetDefaultReturn calls SetDefaultHook with a function that returns the +// given values. +func (f *BankKeeperMintCoinsFunc) SetDefaultReturn(r0 error) { + f.SetDefaultHook(func(types.Context, string, types.Coins) error { + return r0 + }) +} + +// PushReturn calls PushHook with a function that returns the given values. +func (f *BankKeeperMintCoinsFunc) PushReturn(r0 error) { + f.PushHook(func(types.Context, string, types.Coins) error { + return r0 + }) +} + +func (f *BankKeeperMintCoinsFunc) nextHook() func(types.Context, string, types.Coins) error { + f.mutex.Lock() + defer f.mutex.Unlock() + + if len(f.hooks) == 0 { + return f.defaultHook + } + + hook := f.hooks[0] + f.hooks = f.hooks[1:] + return hook +} + +func (f *BankKeeperMintCoinsFunc) appendCall(r0 BankKeeperMintCoinsFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() +} + +// History returns a sequence of BankKeeperMintCoinsFuncCall objects +// describing the invocations of this function. +func (f *BankKeeperMintCoinsFunc) History() []BankKeeperMintCoinsFuncCall { + f.mutex.Lock() + history := make([]BankKeeperMintCoinsFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history +} + +// BankKeeperMintCoinsFuncCall is an object that describes an invocation of +// method MintCoins on an instance of MockBankKeeper. +type BankKeeperMintCoinsFuncCall struct { + // Arg0 is the value of the 1st argument passed to this method + // invocation. + Arg0 types.Context + // Arg1 is the value of the 2nd argument passed to this method + // invocation. + Arg1 string + // Arg2 is the value of the 3rd argument passed to this method + // invocation. + Arg2 types.Coins + // Result0 is the value of the 1st result returned from this method + // invocation. + Result0 error +} + +// Args returns an interface slice containing the arguments of this +// invocation. +func (c BankKeeperMintCoinsFuncCall) Args() []interface{} { + return []interface{}{c.Arg0, c.Arg1, c.Arg2} +} + +// Results returns an interface slice containing the results of this +// invocation. +func (c BankKeeperMintCoinsFuncCall) Results() []interface{} { + return []interface{}{c.Result0} +} + +// BankKeeperSendCoinsFromAccountToModuleFunc describes the behavior when +// the SendCoinsFromAccountToModule method of the parent MockBankKeeper +// instance is invoked. +type BankKeeperSendCoinsFromAccountToModuleFunc struct { + defaultHook func(types.Context, types.AccAddress, string, types.Coins) error + hooks []func(types.Context, types.AccAddress, string, types.Coins) error + history []BankKeeperSendCoinsFromAccountToModuleFuncCall + mutex sync.Mutex +} + +// SendCoinsFromAccountToModule delegates to the next hook function in the +// queue and stores the parameter and result values of this invocation. +func (m *MockBankKeeper) SendCoinsFromAccountToModule(v0 types.Context, v1 types.AccAddress, v2 string, v3 types.Coins) error { + r0 := m.SendCoinsFromAccountToModuleFunc.nextHook()(v0, v1, v2, v3) + m.SendCoinsFromAccountToModuleFunc.appendCall(BankKeeperSendCoinsFromAccountToModuleFuncCall{v0, v1, v2, v3, r0}) + return r0 } -// SendCoinsFromModuleToAccount indicates an expected call of SendCoinsFromModuleToAccount. -func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, amt interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromModuleToAccount", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromModuleToAccount), ctx, senderModule, recipientAddr, amt) +// SetDefaultHook sets function that is called when the +// SendCoinsFromAccountToModule method of the parent MockBankKeeper instance +// is invoked and the hook queue is empty. +func (f *BankKeeperSendCoinsFromAccountToModuleFunc) SetDefaultHook(hook func(types.Context, types.AccAddress, string, types.Coins) error) { + f.defaultHook = hook } -// MockLeverageKeeper is a mock of LeverageKeeper interface. +// PushHook adds a function to the end of hook queue. Each invocation of the +// SendCoinsFromAccountToModule method of the parent MockBankKeeper instance +// invokes the hook at the front of the queue and discards it. After the +// queue is empty, the default hook function is invoked for any future +// action. +func (f *BankKeeperSendCoinsFromAccountToModuleFunc) PushHook(hook func(types.Context, types.AccAddress, string, types.Coins) error) { + f.mutex.Lock() + f.hooks = append(f.hooks, hook) + f.mutex.Unlock() +} + +// SetDefaultReturn calls SetDefaultHook with a function that returns the +// given values. +func (f *BankKeeperSendCoinsFromAccountToModuleFunc) SetDefaultReturn(r0 error) { + f.SetDefaultHook(func(types.Context, types.AccAddress, string, types.Coins) error { + return r0 + }) +} + +// PushReturn calls PushHook with a function that returns the given values. +func (f *BankKeeperSendCoinsFromAccountToModuleFunc) PushReturn(r0 error) { + f.PushHook(func(types.Context, types.AccAddress, string, types.Coins) error { + return r0 + }) +} + +func (f *BankKeeperSendCoinsFromAccountToModuleFunc) nextHook() func(types.Context, types.AccAddress, string, types.Coins) error { + f.mutex.Lock() + defer f.mutex.Unlock() + + if len(f.hooks) == 0 { + return f.defaultHook + } + + hook := f.hooks[0] + f.hooks = f.hooks[1:] + return hook +} + +func (f *BankKeeperSendCoinsFromAccountToModuleFunc) appendCall(r0 BankKeeperSendCoinsFromAccountToModuleFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() +} + +// History returns a sequence of +// BankKeeperSendCoinsFromAccountToModuleFuncCall objects describing the +// invocations of this function. +func (f *BankKeeperSendCoinsFromAccountToModuleFunc) History() []BankKeeperSendCoinsFromAccountToModuleFuncCall { + f.mutex.Lock() + history := make([]BankKeeperSendCoinsFromAccountToModuleFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history +} + +// BankKeeperSendCoinsFromAccountToModuleFuncCall is an object that +// describes an invocation of method SendCoinsFromAccountToModule on an +// instance of MockBankKeeper. +type BankKeeperSendCoinsFromAccountToModuleFuncCall struct { + // Arg0 is the value of the 1st argument passed to this method + // invocation. + Arg0 types.Context + // Arg1 is the value of the 2nd argument passed to this method + // invocation. + Arg1 types.AccAddress + // Arg2 is the value of the 3rd argument passed to this method + // invocation. + Arg2 string + // Arg3 is the value of the 4th argument passed to this method + // invocation. + Arg3 types.Coins + // Result0 is the value of the 1st result returned from this method + // invocation. + Result0 error +} + +// Args returns an interface slice containing the arguments of this +// invocation. +func (c BankKeeperSendCoinsFromAccountToModuleFuncCall) Args() []interface{} { + return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} +} + +// Results returns an interface slice containing the results of this +// invocation. +func (c BankKeeperSendCoinsFromAccountToModuleFuncCall) Results() []interface{} { + return []interface{}{c.Result0} +} + +// BankKeeperSendCoinsFromModuleToAccountFunc describes the behavior when +// the SendCoinsFromModuleToAccount method of the parent MockBankKeeper +// instance is invoked. +type BankKeeperSendCoinsFromModuleToAccountFunc struct { + defaultHook func(types.Context, string, types.AccAddress, types.Coins) error + hooks []func(types.Context, string, types.AccAddress, types.Coins) error + history []BankKeeperSendCoinsFromModuleToAccountFuncCall + mutex sync.Mutex +} + +// SendCoinsFromModuleToAccount delegates to the next hook function in the +// queue and stores the parameter and result values of this invocation. +func (m *MockBankKeeper) SendCoinsFromModuleToAccount(v0 types.Context, v1 string, v2 types.AccAddress, v3 types.Coins) error { + r0 := m.SendCoinsFromModuleToAccountFunc.nextHook()(v0, v1, v2, v3) + m.SendCoinsFromModuleToAccountFunc.appendCall(BankKeeperSendCoinsFromModuleToAccountFuncCall{v0, v1, v2, v3, r0}) + return r0 +} + +// SetDefaultHook sets function that is called when the +// SendCoinsFromModuleToAccount method of the parent MockBankKeeper instance +// is invoked and the hook queue is empty. +func (f *BankKeeperSendCoinsFromModuleToAccountFunc) SetDefaultHook(hook func(types.Context, string, types.AccAddress, types.Coins) error) { + f.defaultHook = hook +} + +// PushHook adds a function to the end of hook queue. Each invocation of the +// SendCoinsFromModuleToAccount method of the parent MockBankKeeper instance +// invokes the hook at the front of the queue and discards it. After the +// queue is empty, the default hook function is invoked for any future +// action. +func (f *BankKeeperSendCoinsFromModuleToAccountFunc) PushHook(hook func(types.Context, string, types.AccAddress, types.Coins) error) { + f.mutex.Lock() + f.hooks = append(f.hooks, hook) + f.mutex.Unlock() +} + +// SetDefaultReturn calls SetDefaultHook with a function that returns the +// given values. +func (f *BankKeeperSendCoinsFromModuleToAccountFunc) SetDefaultReturn(r0 error) { + f.SetDefaultHook(func(types.Context, string, types.AccAddress, types.Coins) error { + return r0 + }) +} + +// PushReturn calls PushHook with a function that returns the given values. +func (f *BankKeeperSendCoinsFromModuleToAccountFunc) PushReturn(r0 error) { + f.PushHook(func(types.Context, string, types.AccAddress, types.Coins) error { + return r0 + }) +} + +func (f *BankKeeperSendCoinsFromModuleToAccountFunc) nextHook() func(types.Context, string, types.AccAddress, types.Coins) error { + f.mutex.Lock() + defer f.mutex.Unlock() + + if len(f.hooks) == 0 { + return f.defaultHook + } + + hook := f.hooks[0] + f.hooks = f.hooks[1:] + return hook +} + +func (f *BankKeeperSendCoinsFromModuleToAccountFunc) appendCall(r0 BankKeeperSendCoinsFromModuleToAccountFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() +} + +// History returns a sequence of +// BankKeeperSendCoinsFromModuleToAccountFuncCall objects describing the +// invocations of this function. +func (f *BankKeeperSendCoinsFromModuleToAccountFunc) History() []BankKeeperSendCoinsFromModuleToAccountFuncCall { + f.mutex.Lock() + history := make([]BankKeeperSendCoinsFromModuleToAccountFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history +} + +// BankKeeperSendCoinsFromModuleToAccountFuncCall is an object that +// describes an invocation of method SendCoinsFromModuleToAccount on an +// instance of MockBankKeeper. +type BankKeeperSendCoinsFromModuleToAccountFuncCall struct { + // Arg0 is the value of the 1st argument passed to this method + // invocation. + Arg0 types.Context + // Arg1 is the value of the 2nd argument passed to this method + // invocation. + Arg1 string + // Arg2 is the value of the 3rd argument passed to this method + // invocation. + Arg2 types.AccAddress + // Arg3 is the value of the 4th argument passed to this method + // invocation. + Arg3 types.Coins + // Result0 is the value of the 1st result returned from this method + // invocation. + Result0 error +} + +// Args returns an interface slice containing the arguments of this +// invocation. +func (c BankKeeperSendCoinsFromModuleToAccountFuncCall) Args() []interface{} { + return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} +} + +// Results returns an interface slice containing the results of this +// invocation. +func (c BankKeeperSendCoinsFromModuleToAccountFuncCall) Results() []interface{} { + return []interface{}{c.Result0} +} + +// MockLeverageKeeper is a mock implementation of the LeverageKeeper +// interface (from the package github.com/umee-network/umee/v6/x/metoken) +// used for unit testing. type MockLeverageKeeper struct { - ctrl *gomock.Controller - recorder *MockLeverageKeeperMockRecorder + // GetAllSuppliedFunc is an instance of a mock function object + // controlling the behavior of the method GetAllSupplied. + GetAllSuppliedFunc *LeverageKeeperGetAllSuppliedFunc + // GetTokenSettingsFunc is an instance of a mock function object + // controlling the behavior of the method GetTokenSettings. + GetTokenSettingsFunc *LeverageKeeperGetTokenSettingsFunc + // GetTotalSupplyFunc is an instance of a mock function object + // controlling the behavior of the method GetTotalSupply. + GetTotalSupplyFunc *LeverageKeeperGetTotalSupplyFunc + // ModuleMaxWithdrawFunc is an instance of a mock function object + // controlling the behavior of the method ModuleMaxWithdraw. + ModuleMaxWithdrawFunc *LeverageKeeperModuleMaxWithdrawFunc + // SupplyFromModuleFunc is an instance of a mock function object + // controlling the behavior of the method SupplyFromModule. + SupplyFromModuleFunc *LeverageKeeperSupplyFromModuleFunc + // ToTokenFunc is an instance of a mock function object controlling the + // behavior of the method ToToken. + ToTokenFunc *LeverageKeeperToTokenFunc + // ToUTokenFunc is an instance of a mock function object controlling the + // behavior of the method ToUToken. + ToUTokenFunc *LeverageKeeperToUTokenFunc + // WithdrawToModuleFunc is an instance of a mock function object + // controlling the behavior of the method WithdrawToModule. + WithdrawToModuleFunc *LeverageKeeperWithdrawToModuleFunc +} + +// NewMockLeverageKeeper creates a new mock of the LeverageKeeper interface. +// All methods return zero values for all results, unless overwritten. +func NewMockLeverageKeeper() *MockLeverageKeeper { + return &MockLeverageKeeper{ + GetAllSuppliedFunc: &LeverageKeeperGetAllSuppliedFunc{ + defaultHook: func(types.Context, types.AccAddress) (r0 types.Coins, r1 error) { + return + }, + }, + GetTokenSettingsFunc: &LeverageKeeperGetTokenSettingsFunc{ + defaultHook: func(types.Context, string) (r0 types1.Token, r1 error) { + return + }, + }, + GetTotalSupplyFunc: &LeverageKeeperGetTotalSupplyFunc{ + defaultHook: func(types.Context, string) (r0 types.Coin, r1 error) { + return + }, + }, + ModuleMaxWithdrawFunc: &LeverageKeeperModuleMaxWithdrawFunc{ + defaultHook: func(types.Context, types.Coin) (r0 math.Int, r1 error) { + return + }, + }, + SupplyFromModuleFunc: &LeverageKeeperSupplyFromModuleFunc{ + defaultHook: func(types.Context, string, types.Coin) (r0 types.Coin, r1 bool, r2 error) { + return + }, + }, + ToTokenFunc: &LeverageKeeperToTokenFunc{ + defaultHook: func(types.Context, types.Coin) (r0 types.Coin, r1 error) { + return + }, + }, + ToUTokenFunc: &LeverageKeeperToUTokenFunc{ + defaultHook: func(types.Context, types.Coin) (r0 types.Coin, r1 error) { + return + }, + }, + WithdrawToModuleFunc: &LeverageKeeperWithdrawToModuleFunc{ + defaultHook: func(types.Context, string, types.Coin) (r0 types.Coin, r1 bool, r2 error) { + return + }, + }, + } +} + +// NewStrictMockLeverageKeeper creates a new mock of the LeverageKeeper +// interface. All methods panic on invocation, unless overwritten. +func NewStrictMockLeverageKeeper() *MockLeverageKeeper { + return &MockLeverageKeeper{ + GetAllSuppliedFunc: &LeverageKeeperGetAllSuppliedFunc{ + defaultHook: func(types.Context, types.AccAddress) (types.Coins, error) { + panic("unexpected invocation of MockLeverageKeeper.GetAllSupplied") + }, + }, + GetTokenSettingsFunc: &LeverageKeeperGetTokenSettingsFunc{ + defaultHook: func(types.Context, string) (types1.Token, error) { + panic("unexpected invocation of MockLeverageKeeper.GetTokenSettings") + }, + }, + GetTotalSupplyFunc: &LeverageKeeperGetTotalSupplyFunc{ + defaultHook: func(types.Context, string) (types.Coin, error) { + panic("unexpected invocation of MockLeverageKeeper.GetTotalSupply") + }, + }, + ModuleMaxWithdrawFunc: &LeverageKeeperModuleMaxWithdrawFunc{ + defaultHook: func(types.Context, types.Coin) (math.Int, error) { + panic("unexpected invocation of MockLeverageKeeper.ModuleMaxWithdraw") + }, + }, + SupplyFromModuleFunc: &LeverageKeeperSupplyFromModuleFunc{ + defaultHook: func(types.Context, string, types.Coin) (types.Coin, bool, error) { + panic("unexpected invocation of MockLeverageKeeper.SupplyFromModule") + }, + }, + ToTokenFunc: &LeverageKeeperToTokenFunc{ + defaultHook: func(types.Context, types.Coin) (types.Coin, error) { + panic("unexpected invocation of MockLeverageKeeper.ToToken") + }, + }, + ToUTokenFunc: &LeverageKeeperToUTokenFunc{ + defaultHook: func(types.Context, types.Coin) (types.Coin, error) { + panic("unexpected invocation of MockLeverageKeeper.ToUToken") + }, + }, + WithdrawToModuleFunc: &LeverageKeeperWithdrawToModuleFunc{ + defaultHook: func(types.Context, string, types.Coin) (types.Coin, bool, error) { + panic("unexpected invocation of MockLeverageKeeper.WithdrawToModule") + }, + }, + } +} + +// NewMockLeverageKeeperFrom creates a new mock of the MockLeverageKeeper +// interface. All methods delegate to the given implementation, unless +// overwritten. +func NewMockLeverageKeeperFrom(i metoken.LeverageKeeper) *MockLeverageKeeper { + return &MockLeverageKeeper{ + GetAllSuppliedFunc: &LeverageKeeperGetAllSuppliedFunc{ + defaultHook: i.GetAllSupplied, + }, + GetTokenSettingsFunc: &LeverageKeeperGetTokenSettingsFunc{ + defaultHook: i.GetTokenSettings, + }, + GetTotalSupplyFunc: &LeverageKeeperGetTotalSupplyFunc{ + defaultHook: i.GetTotalSupply, + }, + ModuleMaxWithdrawFunc: &LeverageKeeperModuleMaxWithdrawFunc{ + defaultHook: i.ModuleMaxWithdraw, + }, + SupplyFromModuleFunc: &LeverageKeeperSupplyFromModuleFunc{ + defaultHook: i.SupplyFromModule, + }, + ToTokenFunc: &LeverageKeeperToTokenFunc{ + defaultHook: i.ToToken, + }, + ToUTokenFunc: &LeverageKeeperToUTokenFunc{ + defaultHook: i.ToUToken, + }, + WithdrawToModuleFunc: &LeverageKeeperWithdrawToModuleFunc{ + defaultHook: i.WithdrawToModule, + }, + } +} + +// LeverageKeeperGetAllSuppliedFunc describes the behavior when the +// GetAllSupplied method of the parent MockLeverageKeeper instance is +// invoked. +type LeverageKeeperGetAllSuppliedFunc struct { + defaultHook func(types.Context, types.AccAddress) (types.Coins, error) + hooks []func(types.Context, types.AccAddress) (types.Coins, error) + history []LeverageKeeperGetAllSuppliedFuncCall + mutex sync.Mutex +} + +// GetAllSupplied delegates to the next hook function in the queue and +// stores the parameter and result values of this invocation. +func (m *MockLeverageKeeper) GetAllSupplied(v0 types.Context, v1 types.AccAddress) (types.Coins, error) { + r0, r1 := m.GetAllSuppliedFunc.nextHook()(v0, v1) + m.GetAllSuppliedFunc.appendCall(LeverageKeeperGetAllSuppliedFuncCall{v0, v1, r0, r1}) + return r0, r1 +} + +// SetDefaultHook sets function that is called when the GetAllSupplied +// method of the parent MockLeverageKeeper instance is invoked and the hook +// queue is empty. +func (f *LeverageKeeperGetAllSuppliedFunc) SetDefaultHook(hook func(types.Context, types.AccAddress) (types.Coins, error)) { + f.defaultHook = hook +} + +// PushHook adds a function to the end of hook queue. Each invocation of the +// GetAllSupplied method of the parent MockLeverageKeeper instance invokes +// the hook at the front of the queue and discards it. After the queue is +// empty, the default hook function is invoked for any future action. +func (f *LeverageKeeperGetAllSuppliedFunc) PushHook(hook func(types.Context, types.AccAddress) (types.Coins, error)) { + f.mutex.Lock() + f.hooks = append(f.hooks, hook) + f.mutex.Unlock() +} + +// SetDefaultReturn calls SetDefaultHook with a function that returns the +// given values. +func (f *LeverageKeeperGetAllSuppliedFunc) SetDefaultReturn(r0 types.Coins, r1 error) { + f.SetDefaultHook(func(types.Context, types.AccAddress) (types.Coins, error) { + return r0, r1 + }) +} + +// PushReturn calls PushHook with a function that returns the given values. +func (f *LeverageKeeperGetAllSuppliedFunc) PushReturn(r0 types.Coins, r1 error) { + f.PushHook(func(types.Context, types.AccAddress) (types.Coins, error) { + return r0, r1 + }) +} + +func (f *LeverageKeeperGetAllSuppliedFunc) nextHook() func(types.Context, types.AccAddress) (types.Coins, error) { + f.mutex.Lock() + defer f.mutex.Unlock() + + if len(f.hooks) == 0 { + return f.defaultHook + } + + hook := f.hooks[0] + f.hooks = f.hooks[1:] + return hook +} + +func (f *LeverageKeeperGetAllSuppliedFunc) appendCall(r0 LeverageKeeperGetAllSuppliedFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() +} + +// History returns a sequence of LeverageKeeperGetAllSuppliedFuncCall +// objects describing the invocations of this function. +func (f *LeverageKeeperGetAllSuppliedFunc) History() []LeverageKeeperGetAllSuppliedFuncCall { + f.mutex.Lock() + history := make([]LeverageKeeperGetAllSuppliedFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history +} + +// LeverageKeeperGetAllSuppliedFuncCall is an object that describes an +// invocation of method GetAllSupplied on an instance of MockLeverageKeeper. +type LeverageKeeperGetAllSuppliedFuncCall struct { + // Arg0 is the value of the 1st argument passed to this method + // invocation. + Arg0 types.Context + // Arg1 is the value of the 2nd argument passed to this method + // invocation. + Arg1 types.AccAddress + // Result0 is the value of the 1st result returned from this method + // invocation. + Result0 types.Coins + // Result1 is the value of the 2nd result returned from this method + // invocation. + Result1 error +} + +// Args returns an interface slice containing the arguments of this +// invocation. +func (c LeverageKeeperGetAllSuppliedFuncCall) Args() []interface{} { + return []interface{}{c.Arg0, c.Arg1} +} + +// Results returns an interface slice containing the results of this +// invocation. +func (c LeverageKeeperGetAllSuppliedFuncCall) Results() []interface{} { + return []interface{}{c.Result0, c.Result1} +} + +// LeverageKeeperGetTokenSettingsFunc describes the behavior when the +// GetTokenSettings method of the parent MockLeverageKeeper instance is +// invoked. +type LeverageKeeperGetTokenSettingsFunc struct { + defaultHook func(types.Context, string) (types1.Token, error) + hooks []func(types.Context, string) (types1.Token, error) + history []LeverageKeeperGetTokenSettingsFuncCall + mutex sync.Mutex +} + +// GetTokenSettings delegates to the next hook function in the queue and +// stores the parameter and result values of this invocation. +func (m *MockLeverageKeeper) GetTokenSettings(v0 types.Context, v1 string) (types1.Token, error) { + r0, r1 := m.GetTokenSettingsFunc.nextHook()(v0, v1) + m.GetTokenSettingsFunc.appendCall(LeverageKeeperGetTokenSettingsFuncCall{v0, v1, r0, r1}) + return r0, r1 +} + +// SetDefaultHook sets function that is called when the GetTokenSettings +// method of the parent MockLeverageKeeper instance is invoked and the hook +// queue is empty. +func (f *LeverageKeeperGetTokenSettingsFunc) SetDefaultHook(hook func(types.Context, string) (types1.Token, error)) { + f.defaultHook = hook +} + +// PushHook adds a function to the end of hook queue. Each invocation of the +// GetTokenSettings method of the parent MockLeverageKeeper instance invokes +// the hook at the front of the queue and discards it. After the queue is +// empty, the default hook function is invoked for any future action. +func (f *LeverageKeeperGetTokenSettingsFunc) PushHook(hook func(types.Context, string) (types1.Token, error)) { + f.mutex.Lock() + f.hooks = append(f.hooks, hook) + f.mutex.Unlock() +} + +// SetDefaultReturn calls SetDefaultHook with a function that returns the +// given values. +func (f *LeverageKeeperGetTokenSettingsFunc) SetDefaultReturn(r0 types1.Token, r1 error) { + f.SetDefaultHook(func(types.Context, string) (types1.Token, error) { + return r0, r1 + }) +} + +// PushReturn calls PushHook with a function that returns the given values. +func (f *LeverageKeeperGetTokenSettingsFunc) PushReturn(r0 types1.Token, r1 error) { + f.PushHook(func(types.Context, string) (types1.Token, error) { + return r0, r1 + }) +} + +func (f *LeverageKeeperGetTokenSettingsFunc) nextHook() func(types.Context, string) (types1.Token, error) { + f.mutex.Lock() + defer f.mutex.Unlock() + + if len(f.hooks) == 0 { + return f.defaultHook + } + + hook := f.hooks[0] + f.hooks = f.hooks[1:] + return hook +} + +func (f *LeverageKeeperGetTokenSettingsFunc) appendCall(r0 LeverageKeeperGetTokenSettingsFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() +} + +// History returns a sequence of LeverageKeeperGetTokenSettingsFuncCall +// objects describing the invocations of this function. +func (f *LeverageKeeperGetTokenSettingsFunc) History() []LeverageKeeperGetTokenSettingsFuncCall { + f.mutex.Lock() + history := make([]LeverageKeeperGetTokenSettingsFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history +} + +// LeverageKeeperGetTokenSettingsFuncCall is an object that describes an +// invocation of method GetTokenSettings on an instance of +// MockLeverageKeeper. +type LeverageKeeperGetTokenSettingsFuncCall struct { + // Arg0 is the value of the 1st argument passed to this method + // invocation. + Arg0 types.Context + // Arg1 is the value of the 2nd argument passed to this method + // invocation. + Arg1 string + // Result0 is the value of the 1st result returned from this method + // invocation. + Result0 types1.Token + // Result1 is the value of the 2nd result returned from this method + // invocation. + Result1 error +} + +// Args returns an interface slice containing the arguments of this +// invocation. +func (c LeverageKeeperGetTokenSettingsFuncCall) Args() []interface{} { + return []interface{}{c.Arg0, c.Arg1} +} + +// Results returns an interface slice containing the results of this +// invocation. +func (c LeverageKeeperGetTokenSettingsFuncCall) Results() []interface{} { + return []interface{}{c.Result0, c.Result1} +} + +// LeverageKeeperGetTotalSupplyFunc describes the behavior when the +// GetTotalSupply method of the parent MockLeverageKeeper instance is +// invoked. +type LeverageKeeperGetTotalSupplyFunc struct { + defaultHook func(types.Context, string) (types.Coin, error) + hooks []func(types.Context, string) (types.Coin, error) + history []LeverageKeeperGetTotalSupplyFuncCall + mutex sync.Mutex +} + +// GetTotalSupply delegates to the next hook function in the queue and +// stores the parameter and result values of this invocation. +func (m *MockLeverageKeeper) GetTotalSupply(v0 types.Context, v1 string) (types.Coin, error) { + r0, r1 := m.GetTotalSupplyFunc.nextHook()(v0, v1) + m.GetTotalSupplyFunc.appendCall(LeverageKeeperGetTotalSupplyFuncCall{v0, v1, r0, r1}) + return r0, r1 +} + +// SetDefaultHook sets function that is called when the GetTotalSupply +// method of the parent MockLeverageKeeper instance is invoked and the hook +// queue is empty. +func (f *LeverageKeeperGetTotalSupplyFunc) SetDefaultHook(hook func(types.Context, string) (types.Coin, error)) { + f.defaultHook = hook +} + +// PushHook adds a function to the end of hook queue. Each invocation of the +// GetTotalSupply method of the parent MockLeverageKeeper instance invokes +// the hook at the front of the queue and discards it. After the queue is +// empty, the default hook function is invoked for any future action. +func (f *LeverageKeeperGetTotalSupplyFunc) PushHook(hook func(types.Context, string) (types.Coin, error)) { + f.mutex.Lock() + f.hooks = append(f.hooks, hook) + f.mutex.Unlock() +} + +// SetDefaultReturn calls SetDefaultHook with a function that returns the +// given values. +func (f *LeverageKeeperGetTotalSupplyFunc) SetDefaultReturn(r0 types.Coin, r1 error) { + f.SetDefaultHook(func(types.Context, string) (types.Coin, error) { + return r0, r1 + }) +} + +// PushReturn calls PushHook with a function that returns the given values. +func (f *LeverageKeeperGetTotalSupplyFunc) PushReturn(r0 types.Coin, r1 error) { + f.PushHook(func(types.Context, string) (types.Coin, error) { + return r0, r1 + }) +} + +func (f *LeverageKeeperGetTotalSupplyFunc) nextHook() func(types.Context, string) (types.Coin, error) { + f.mutex.Lock() + defer f.mutex.Unlock() + + if len(f.hooks) == 0 { + return f.defaultHook + } + + hook := f.hooks[0] + f.hooks = f.hooks[1:] + return hook +} + +func (f *LeverageKeeperGetTotalSupplyFunc) appendCall(r0 LeverageKeeperGetTotalSupplyFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() +} + +// History returns a sequence of LeverageKeeperGetTotalSupplyFuncCall +// objects describing the invocations of this function. +func (f *LeverageKeeperGetTotalSupplyFunc) History() []LeverageKeeperGetTotalSupplyFuncCall { + f.mutex.Lock() + history := make([]LeverageKeeperGetTotalSupplyFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history +} + +// LeverageKeeperGetTotalSupplyFuncCall is an object that describes an +// invocation of method GetTotalSupply on an instance of MockLeverageKeeper. +type LeverageKeeperGetTotalSupplyFuncCall struct { + // Arg0 is the value of the 1st argument passed to this method + // invocation. + Arg0 types.Context + // Arg1 is the value of the 2nd argument passed to this method + // invocation. + Arg1 string + // Result0 is the value of the 1st result returned from this method + // invocation. + Result0 types.Coin + // Result1 is the value of the 2nd result returned from this method + // invocation. + Result1 error +} + +// Args returns an interface slice containing the arguments of this +// invocation. +func (c LeverageKeeperGetTotalSupplyFuncCall) Args() []interface{} { + return []interface{}{c.Arg0, c.Arg1} +} + +// Results returns an interface slice containing the results of this +// invocation. +func (c LeverageKeeperGetTotalSupplyFuncCall) Results() []interface{} { + return []interface{}{c.Result0, c.Result1} +} + +// LeverageKeeperModuleMaxWithdrawFunc describes the behavior when the +// ModuleMaxWithdraw method of the parent MockLeverageKeeper instance is +// invoked. +type LeverageKeeperModuleMaxWithdrawFunc struct { + defaultHook func(types.Context, types.Coin) (math.Int, error) + hooks []func(types.Context, types.Coin) (math.Int, error) + history []LeverageKeeperModuleMaxWithdrawFuncCall + mutex sync.Mutex +} + +// ModuleMaxWithdraw delegates to the next hook function in the queue and +// stores the parameter and result values of this invocation. +func (m *MockLeverageKeeper) ModuleMaxWithdraw(v0 types.Context, v1 types.Coin) (math.Int, error) { + r0, r1 := m.ModuleMaxWithdrawFunc.nextHook()(v0, v1) + m.ModuleMaxWithdrawFunc.appendCall(LeverageKeeperModuleMaxWithdrawFuncCall{v0, v1, r0, r1}) + return r0, r1 +} + +// SetDefaultHook sets function that is called when the ModuleMaxWithdraw +// method of the parent MockLeverageKeeper instance is invoked and the hook +// queue is empty. +func (f *LeverageKeeperModuleMaxWithdrawFunc) SetDefaultHook(hook func(types.Context, types.Coin) (math.Int, error)) { + f.defaultHook = hook +} + +// PushHook adds a function to the end of hook queue. Each invocation of the +// ModuleMaxWithdraw method of the parent MockLeverageKeeper instance +// invokes the hook at the front of the queue and discards it. After the +// queue is empty, the default hook function is invoked for any future +// action. +func (f *LeverageKeeperModuleMaxWithdrawFunc) PushHook(hook func(types.Context, types.Coin) (math.Int, error)) { + f.mutex.Lock() + f.hooks = append(f.hooks, hook) + f.mutex.Unlock() +} + +// SetDefaultReturn calls SetDefaultHook with a function that returns the +// given values. +func (f *LeverageKeeperModuleMaxWithdrawFunc) SetDefaultReturn(r0 math.Int, r1 error) { + f.SetDefaultHook(func(types.Context, types.Coin) (math.Int, error) { + return r0, r1 + }) +} + +// PushReturn calls PushHook with a function that returns the given values. +func (f *LeverageKeeperModuleMaxWithdrawFunc) PushReturn(r0 math.Int, r1 error) { + f.PushHook(func(types.Context, types.Coin) (math.Int, error) { + return r0, r1 + }) +} + +func (f *LeverageKeeperModuleMaxWithdrawFunc) nextHook() func(types.Context, types.Coin) (math.Int, error) { + f.mutex.Lock() + defer f.mutex.Unlock() + + if len(f.hooks) == 0 { + return f.defaultHook + } + + hook := f.hooks[0] + f.hooks = f.hooks[1:] + return hook +} + +func (f *LeverageKeeperModuleMaxWithdrawFunc) appendCall(r0 LeverageKeeperModuleMaxWithdrawFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() +} + +// History returns a sequence of LeverageKeeperModuleMaxWithdrawFuncCall +// objects describing the invocations of this function. +func (f *LeverageKeeperModuleMaxWithdrawFunc) History() []LeverageKeeperModuleMaxWithdrawFuncCall { + f.mutex.Lock() + history := make([]LeverageKeeperModuleMaxWithdrawFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history +} + +// LeverageKeeperModuleMaxWithdrawFuncCall is an object that describes an +// invocation of method ModuleMaxWithdraw on an instance of +// MockLeverageKeeper. +type LeverageKeeperModuleMaxWithdrawFuncCall struct { + // Arg0 is the value of the 1st argument passed to this method + // invocation. + Arg0 types.Context + // Arg1 is the value of the 2nd argument passed to this method + // invocation. + Arg1 types.Coin + // Result0 is the value of the 1st result returned from this method + // invocation. + Result0 math.Int + // Result1 is the value of the 2nd result returned from this method + // invocation. + Result1 error +} + +// Args returns an interface slice containing the arguments of this +// invocation. +func (c LeverageKeeperModuleMaxWithdrawFuncCall) Args() []interface{} { + return []interface{}{c.Arg0, c.Arg1} } -// MockLeverageKeeperMockRecorder is the mock recorder for MockLeverageKeeper. -type MockLeverageKeeperMockRecorder struct { - mock *MockLeverageKeeper +// Results returns an interface slice containing the results of this +// invocation. +func (c LeverageKeeperModuleMaxWithdrawFuncCall) Results() []interface{} { + return []interface{}{c.Result0, c.Result1} } -// NewMockLeverageKeeper creates a new mock instance. -func NewMockLeverageKeeper(ctrl *gomock.Controller) *MockLeverageKeeper { - mock := &MockLeverageKeeper{ctrl: ctrl} - mock.recorder = &MockLeverageKeeperMockRecorder{mock} - return mock +// LeverageKeeperSupplyFromModuleFunc describes the behavior when the +// SupplyFromModule method of the parent MockLeverageKeeper instance is +// invoked. +type LeverageKeeperSupplyFromModuleFunc struct { + defaultHook func(types.Context, string, types.Coin) (types.Coin, bool, error) + hooks []func(types.Context, string, types.Coin) (types.Coin, bool, error) + history []LeverageKeeperSupplyFromModuleFuncCall + mutex sync.Mutex } -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockLeverageKeeper) EXPECT() *MockLeverageKeeperMockRecorder { - return m.recorder +// SupplyFromModule delegates to the next hook function in the queue and +// stores the parameter and result values of this invocation. +func (m *MockLeverageKeeper) SupplyFromModule(v0 types.Context, v1 string, v2 types.Coin) (types.Coin, bool, error) { + r0, r1, r2 := m.SupplyFromModuleFunc.nextHook()(v0, v1, v2) + m.SupplyFromModuleFunc.appendCall(LeverageKeeperSupplyFromModuleFuncCall{v0, v1, v2, r0, r1, r2}) + return r0, r1, r2 } -// GetAllSupplied mocks base method. -func (m *MockLeverageKeeper) GetAllSupplied(ctx types.Context, supplierAddr types.AccAddress) (types.Coins, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAllSupplied", ctx, supplierAddr) - ret0, _ := ret[0].(types.Coins) - ret1, _ := ret[1].(error) - return ret0, ret1 +// SetDefaultHook sets function that is called when the SupplyFromModule +// method of the parent MockLeverageKeeper instance is invoked and the hook +// queue is empty. +func (f *LeverageKeeperSupplyFromModuleFunc) SetDefaultHook(hook func(types.Context, string, types.Coin) (types.Coin, bool, error)) { + f.defaultHook = hook } -// GetAllSupplied indicates an expected call of GetAllSupplied. -func (mr *MockLeverageKeeperMockRecorder) GetAllSupplied(ctx, supplierAddr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllSupplied", reflect.TypeOf((*MockLeverageKeeper)(nil).GetAllSupplied), ctx, supplierAddr) +// PushHook adds a function to the end of hook queue. Each invocation of the +// SupplyFromModule method of the parent MockLeverageKeeper instance invokes +// the hook at the front of the queue and discards it. After the queue is +// empty, the default hook function is invoked for any future action. +func (f *LeverageKeeperSupplyFromModuleFunc) PushHook(hook func(types.Context, string, types.Coin) (types.Coin, bool, error)) { + f.mutex.Lock() + f.hooks = append(f.hooks, hook) + f.mutex.Unlock() } -// GetTokenSettings mocks base method. -func (m *MockLeverageKeeper) GetTokenSettings(ctx types.Context, denom string) (types0.Token, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTokenSettings", ctx, denom) - ret0, _ := ret[0].(types0.Token) - ret1, _ := ret[1].(error) - return ret0, ret1 +// SetDefaultReturn calls SetDefaultHook with a function that returns the +// given values. +func (f *LeverageKeeperSupplyFromModuleFunc) SetDefaultReturn(r0 types.Coin, r1 bool, r2 error) { + f.SetDefaultHook(func(types.Context, string, types.Coin) (types.Coin, bool, error) { + return r0, r1, r2 + }) } -// GetTokenSettings indicates an expected call of GetTokenSettings. -func (mr *MockLeverageKeeperMockRecorder) GetTokenSettings(ctx, denom interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenSettings", reflect.TypeOf((*MockLeverageKeeper)(nil).GetTokenSettings), ctx, denom) +// PushReturn calls PushHook with a function that returns the given values. +func (f *LeverageKeeperSupplyFromModuleFunc) PushReturn(r0 types.Coin, r1 bool, r2 error) { + f.PushHook(func(types.Context, string, types.Coin) (types.Coin, bool, error) { + return r0, r1, r2 + }) } -// GetTotalSupply mocks base method. -func (m *MockLeverageKeeper) GetTotalSupply(ctx types.Context, denom string) (types.Coin, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTotalSupply", ctx, denom) - ret0, _ := ret[0].(types.Coin) - ret1, _ := ret[1].(error) - return ret0, ret1 +func (f *LeverageKeeperSupplyFromModuleFunc) nextHook() func(types.Context, string, types.Coin) (types.Coin, bool, error) { + f.mutex.Lock() + defer f.mutex.Unlock() + + if len(f.hooks) == 0 { + return f.defaultHook + } + + hook := f.hooks[0] + f.hooks = f.hooks[1:] + return hook +} + +func (f *LeverageKeeperSupplyFromModuleFunc) appendCall(r0 LeverageKeeperSupplyFromModuleFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() } -// GetTotalSupply indicates an expected call of GetTotalSupply. -func (mr *MockLeverageKeeperMockRecorder) GetTotalSupply(ctx, denom interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTotalSupply", reflect.TypeOf((*MockLeverageKeeper)(nil).GetTotalSupply), ctx, denom) +// History returns a sequence of LeverageKeeperSupplyFromModuleFuncCall +// objects describing the invocations of this function. +func (f *LeverageKeeperSupplyFromModuleFunc) History() []LeverageKeeperSupplyFromModuleFuncCall { + f.mutex.Lock() + history := make([]LeverageKeeperSupplyFromModuleFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history } -// ModuleMaxWithdraw mocks base method. -func (m *MockLeverageKeeper) ModuleMaxWithdraw(ctx types.Context, spendableUTokens types.Coin) (math.Int, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ModuleMaxWithdraw", ctx, spendableUTokens) - ret0, _ := ret[0].(math.Int) - ret1, _ := ret[1].(error) - return ret0, ret1 +// LeverageKeeperSupplyFromModuleFuncCall is an object that describes an +// invocation of method SupplyFromModule on an instance of +// MockLeverageKeeper. +type LeverageKeeperSupplyFromModuleFuncCall struct { + // Arg0 is the value of the 1st argument passed to this method + // invocation. + Arg0 types.Context + // Arg1 is the value of the 2nd argument passed to this method + // invocation. + Arg1 string + // Arg2 is the value of the 3rd argument passed to this method + // invocation. + Arg2 types.Coin + // Result0 is the value of the 1st result returned from this method + // invocation. + Result0 types.Coin + // Result1 is the value of the 2nd result returned from this method + // invocation. + Result1 bool + // Result2 is the value of the 3rd result returned from this method + // invocation. + Result2 error } -// ModuleMaxWithdraw indicates an expected call of ModuleMaxWithdraw. -func (mr *MockLeverageKeeperMockRecorder) ModuleMaxWithdraw(ctx, spendableUTokens interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ModuleMaxWithdraw", reflect.TypeOf((*MockLeverageKeeper)(nil).ModuleMaxWithdraw), ctx, spendableUTokens) +// Args returns an interface slice containing the arguments of this +// invocation. +func (c LeverageKeeperSupplyFromModuleFuncCall) Args() []interface{} { + return []interface{}{c.Arg0, c.Arg1, c.Arg2} } -// SupplyFromModule mocks base method. -func (m *MockLeverageKeeper) SupplyFromModule(ctx types.Context, fromModule string, coin types.Coin) (types.Coin, bool, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SupplyFromModule", ctx, fromModule, coin) - ret0, _ := ret[0].(types.Coin) - ret1, _ := ret[1].(bool) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 +// Results returns an interface slice containing the results of this +// invocation. +func (c LeverageKeeperSupplyFromModuleFuncCall) Results() []interface{} { + return []interface{}{c.Result0, c.Result1, c.Result2} } -// SupplyFromModule indicates an expected call of SupplyFromModule. -func (mr *MockLeverageKeeperMockRecorder) SupplyFromModule(ctx, fromModule, coin interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SupplyFromModule", reflect.TypeOf((*MockLeverageKeeper)(nil).SupplyFromModule), ctx, fromModule, coin) +// LeverageKeeperToTokenFunc describes the behavior when the ToToken method +// of the parent MockLeverageKeeper instance is invoked. +type LeverageKeeperToTokenFunc struct { + defaultHook func(types.Context, types.Coin) (types.Coin, error) + hooks []func(types.Context, types.Coin) (types.Coin, error) + history []LeverageKeeperToTokenFuncCall + mutex sync.Mutex } -// ToToken mocks base method. -func (m *MockLeverageKeeper) ToToken(ctx types.Context, uToken types.Coin) (types.Coin, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ToToken", ctx, uToken) - ret0, _ := ret[0].(types.Coin) - ret1, _ := ret[1].(error) - return ret0, ret1 +// ToToken delegates to the next hook function in the queue and stores the +// parameter and result values of this invocation. +func (m *MockLeverageKeeper) ToToken(v0 types.Context, v1 types.Coin) (types.Coin, error) { + r0, r1 := m.ToTokenFunc.nextHook()(v0, v1) + m.ToTokenFunc.appendCall(LeverageKeeperToTokenFuncCall{v0, v1, r0, r1}) + return r0, r1 } -// ToToken indicates an expected call of ToToken. -func (mr *MockLeverageKeeperMockRecorder) ToToken(ctx, uToken interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToToken", reflect.TypeOf((*MockLeverageKeeper)(nil).ToToken), ctx, uToken) +// SetDefaultHook sets function that is called when the ToToken method of +// the parent MockLeverageKeeper instance is invoked and the hook queue is +// empty. +func (f *LeverageKeeperToTokenFunc) SetDefaultHook(hook func(types.Context, types.Coin) (types.Coin, error)) { + f.defaultHook = hook } -// ToUToken mocks base method. -func (m *MockLeverageKeeper) ToUToken(ctx types.Context, token types.Coin) (types.Coin, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ToUToken", ctx, token) - ret0, _ := ret[0].(types.Coin) - ret1, _ := ret[1].(error) - return ret0, ret1 +// PushHook adds a function to the end of hook queue. Each invocation of the +// ToToken method of the parent MockLeverageKeeper instance invokes the hook +// at the front of the queue and discards it. After the queue is empty, the +// default hook function is invoked for any future action. +func (f *LeverageKeeperToTokenFunc) PushHook(hook func(types.Context, types.Coin) (types.Coin, error)) { + f.mutex.Lock() + f.hooks = append(f.hooks, hook) + f.mutex.Unlock() } -// ToUToken indicates an expected call of ToUToken. -func (mr *MockLeverageKeeperMockRecorder) ToUToken(ctx, token interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToUToken", reflect.TypeOf((*MockLeverageKeeper)(nil).ToUToken), ctx, token) +// SetDefaultReturn calls SetDefaultHook with a function that returns the +// given values. +func (f *LeverageKeeperToTokenFunc) SetDefaultReturn(r0 types.Coin, r1 error) { + f.SetDefaultHook(func(types.Context, types.Coin) (types.Coin, error) { + return r0, r1 + }) +} + +// PushReturn calls PushHook with a function that returns the given values. +func (f *LeverageKeeperToTokenFunc) PushReturn(r0 types.Coin, r1 error) { + f.PushHook(func(types.Context, types.Coin) (types.Coin, error) { + return r0, r1 + }) +} + +func (f *LeverageKeeperToTokenFunc) nextHook() func(types.Context, types.Coin) (types.Coin, error) { + f.mutex.Lock() + defer f.mutex.Unlock() + + if len(f.hooks) == 0 { + return f.defaultHook + } + + hook := f.hooks[0] + f.hooks = f.hooks[1:] + return hook } -// WithdrawToModule mocks base method. -func (m *MockLeverageKeeper) WithdrawToModule(ctx types.Context, toModule string, uToken types.Coin) (types.Coin, bool, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WithdrawToModule", ctx, toModule, uToken) - ret0, _ := ret[0].(types.Coin) - ret1, _ := ret[1].(bool) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 +func (f *LeverageKeeperToTokenFunc) appendCall(r0 LeverageKeeperToTokenFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() +} + +// History returns a sequence of LeverageKeeperToTokenFuncCall objects +// describing the invocations of this function. +func (f *LeverageKeeperToTokenFunc) History() []LeverageKeeperToTokenFuncCall { + f.mutex.Lock() + history := make([]LeverageKeeperToTokenFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history +} + +// LeverageKeeperToTokenFuncCall is an object that describes an invocation +// of method ToToken on an instance of MockLeverageKeeper. +type LeverageKeeperToTokenFuncCall struct { + // Arg0 is the value of the 1st argument passed to this method + // invocation. + Arg0 types.Context + // Arg1 is the value of the 2nd argument passed to this method + // invocation. + Arg1 types.Coin + // Result0 is the value of the 1st result returned from this method + // invocation. + Result0 types.Coin + // Result1 is the value of the 2nd result returned from this method + // invocation. + Result1 error +} + +// Args returns an interface slice containing the arguments of this +// invocation. +func (c LeverageKeeperToTokenFuncCall) Args() []interface{} { + return []interface{}{c.Arg0, c.Arg1} +} + +// Results returns an interface slice containing the results of this +// invocation. +func (c LeverageKeeperToTokenFuncCall) Results() []interface{} { + return []interface{}{c.Result0, c.Result1} +} + +// LeverageKeeperToUTokenFunc describes the behavior when the ToUToken +// method of the parent MockLeverageKeeper instance is invoked. +type LeverageKeeperToUTokenFunc struct { + defaultHook func(types.Context, types.Coin) (types.Coin, error) + hooks []func(types.Context, types.Coin) (types.Coin, error) + history []LeverageKeeperToUTokenFuncCall + mutex sync.Mutex +} + +// ToUToken delegates to the next hook function in the queue and stores the +// parameter and result values of this invocation. +func (m *MockLeverageKeeper) ToUToken(v0 types.Context, v1 types.Coin) (types.Coin, error) { + r0, r1 := m.ToUTokenFunc.nextHook()(v0, v1) + m.ToUTokenFunc.appendCall(LeverageKeeperToUTokenFuncCall{v0, v1, r0, r1}) + return r0, r1 +} + +// SetDefaultHook sets function that is called when the ToUToken method of +// the parent MockLeverageKeeper instance is invoked and the hook queue is +// empty. +func (f *LeverageKeeperToUTokenFunc) SetDefaultHook(hook func(types.Context, types.Coin) (types.Coin, error)) { + f.defaultHook = hook +} + +// PushHook adds a function to the end of hook queue. Each invocation of the +// ToUToken method of the parent MockLeverageKeeper instance invokes the +// hook at the front of the queue and discards it. After the queue is empty, +// the default hook function is invoked for any future action. +func (f *LeverageKeeperToUTokenFunc) PushHook(hook func(types.Context, types.Coin) (types.Coin, error)) { + f.mutex.Lock() + f.hooks = append(f.hooks, hook) + f.mutex.Unlock() +} + +// SetDefaultReturn calls SetDefaultHook with a function that returns the +// given values. +func (f *LeverageKeeperToUTokenFunc) SetDefaultReturn(r0 types.Coin, r1 error) { + f.SetDefaultHook(func(types.Context, types.Coin) (types.Coin, error) { + return r0, r1 + }) +} + +// PushReturn calls PushHook with a function that returns the given values. +func (f *LeverageKeeperToUTokenFunc) PushReturn(r0 types.Coin, r1 error) { + f.PushHook(func(types.Context, types.Coin) (types.Coin, error) { + return r0, r1 + }) +} + +func (f *LeverageKeeperToUTokenFunc) nextHook() func(types.Context, types.Coin) (types.Coin, error) { + f.mutex.Lock() + defer f.mutex.Unlock() + + if len(f.hooks) == 0 { + return f.defaultHook + } + + hook := f.hooks[0] + f.hooks = f.hooks[1:] + return hook +} + +func (f *LeverageKeeperToUTokenFunc) appendCall(r0 LeverageKeeperToUTokenFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() +} + +// History returns a sequence of LeverageKeeperToUTokenFuncCall objects +// describing the invocations of this function. +func (f *LeverageKeeperToUTokenFunc) History() []LeverageKeeperToUTokenFuncCall { + f.mutex.Lock() + history := make([]LeverageKeeperToUTokenFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history } -// WithdrawToModule indicates an expected call of WithdrawToModule. -func (mr *MockLeverageKeeperMockRecorder) WithdrawToModule(ctx, toModule, uToken interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WithdrawToModule", reflect.TypeOf((*MockLeverageKeeper)(nil).WithdrawToModule), ctx, toModule, uToken) +// LeverageKeeperToUTokenFuncCall is an object that describes an invocation +// of method ToUToken on an instance of MockLeverageKeeper. +type LeverageKeeperToUTokenFuncCall struct { + // Arg0 is the value of the 1st argument passed to this method + // invocation. + Arg0 types.Context + // Arg1 is the value of the 2nd argument passed to this method + // invocation. + Arg1 types.Coin + // Result0 is the value of the 1st result returned from this method + // invocation. + Result0 types.Coin + // Result1 is the value of the 2nd result returned from this method + // invocation. + Result1 error } -// MockOracleKeeper is a mock of OracleKeeper interface. +// Args returns an interface slice containing the arguments of this +// invocation. +func (c LeverageKeeperToUTokenFuncCall) Args() []interface{} { + return []interface{}{c.Arg0, c.Arg1} +} + +// Results returns an interface slice containing the results of this +// invocation. +func (c LeverageKeeperToUTokenFuncCall) Results() []interface{} { + return []interface{}{c.Result0, c.Result1} +} + +// LeverageKeeperWithdrawToModuleFunc describes the behavior when the +// WithdrawToModule method of the parent MockLeverageKeeper instance is +// invoked. +type LeverageKeeperWithdrawToModuleFunc struct { + defaultHook func(types.Context, string, types.Coin) (types.Coin, bool, error) + hooks []func(types.Context, string, types.Coin) (types.Coin, bool, error) + history []LeverageKeeperWithdrawToModuleFuncCall + mutex sync.Mutex +} + +// WithdrawToModule delegates to the next hook function in the queue and +// stores the parameter and result values of this invocation. +func (m *MockLeverageKeeper) WithdrawToModule(v0 types.Context, v1 string, v2 types.Coin) (types.Coin, bool, error) { + r0, r1, r2 := m.WithdrawToModuleFunc.nextHook()(v0, v1, v2) + m.WithdrawToModuleFunc.appendCall(LeverageKeeperWithdrawToModuleFuncCall{v0, v1, v2, r0, r1, r2}) + return r0, r1, r2 +} + +// SetDefaultHook sets function that is called when the WithdrawToModule +// method of the parent MockLeverageKeeper instance is invoked and the hook +// queue is empty. +func (f *LeverageKeeperWithdrawToModuleFunc) SetDefaultHook(hook func(types.Context, string, types.Coin) (types.Coin, bool, error)) { + f.defaultHook = hook +} + +// PushHook adds a function to the end of hook queue. Each invocation of the +// WithdrawToModule method of the parent MockLeverageKeeper instance invokes +// the hook at the front of the queue and discards it. After the queue is +// empty, the default hook function is invoked for any future action. +func (f *LeverageKeeperWithdrawToModuleFunc) PushHook(hook func(types.Context, string, types.Coin) (types.Coin, bool, error)) { + f.mutex.Lock() + f.hooks = append(f.hooks, hook) + f.mutex.Unlock() +} + +// SetDefaultReturn calls SetDefaultHook with a function that returns the +// given values. +func (f *LeverageKeeperWithdrawToModuleFunc) SetDefaultReturn(r0 types.Coin, r1 bool, r2 error) { + f.SetDefaultHook(func(types.Context, string, types.Coin) (types.Coin, bool, error) { + return r0, r1, r2 + }) +} + +// PushReturn calls PushHook with a function that returns the given values. +func (f *LeverageKeeperWithdrawToModuleFunc) PushReturn(r0 types.Coin, r1 bool, r2 error) { + f.PushHook(func(types.Context, string, types.Coin) (types.Coin, bool, error) { + return r0, r1, r2 + }) +} + +func (f *LeverageKeeperWithdrawToModuleFunc) nextHook() func(types.Context, string, types.Coin) (types.Coin, bool, error) { + f.mutex.Lock() + defer f.mutex.Unlock() + + if len(f.hooks) == 0 { + return f.defaultHook + } + + hook := f.hooks[0] + f.hooks = f.hooks[1:] + return hook +} + +func (f *LeverageKeeperWithdrawToModuleFunc) appendCall(r0 LeverageKeeperWithdrawToModuleFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() +} + +// History returns a sequence of LeverageKeeperWithdrawToModuleFuncCall +// objects describing the invocations of this function. +func (f *LeverageKeeperWithdrawToModuleFunc) History() []LeverageKeeperWithdrawToModuleFuncCall { + f.mutex.Lock() + history := make([]LeverageKeeperWithdrawToModuleFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history +} + +// LeverageKeeperWithdrawToModuleFuncCall is an object that describes an +// invocation of method WithdrawToModule on an instance of +// MockLeverageKeeper. +type LeverageKeeperWithdrawToModuleFuncCall struct { + // Arg0 is the value of the 1st argument passed to this method + // invocation. + Arg0 types.Context + // Arg1 is the value of the 2nd argument passed to this method + // invocation. + Arg1 string + // Arg2 is the value of the 3rd argument passed to this method + // invocation. + Arg2 types.Coin + // Result0 is the value of the 1st result returned from this method + // invocation. + Result0 types.Coin + // Result1 is the value of the 2nd result returned from this method + // invocation. + Result1 bool + // Result2 is the value of the 3rd result returned from this method + // invocation. + Result2 error +} + +// Args returns an interface slice containing the arguments of this +// invocation. +func (c LeverageKeeperWithdrawToModuleFuncCall) Args() []interface{} { + return []interface{}{c.Arg0, c.Arg1, c.Arg2} +} + +// Results returns an interface slice containing the results of this +// invocation. +func (c LeverageKeeperWithdrawToModuleFuncCall) Results() []interface{} { + return []interface{}{c.Result0, c.Result1, c.Result2} +} + +// MockOracleKeeper is a mock implementation of the OracleKeeper interface +// (from the package github.com/umee-network/umee/v6/x/metoken) used for +// unit testing. type MockOracleKeeper struct { - ctrl *gomock.Controller - recorder *MockOracleKeeperMockRecorder + // AllMedianPricesFunc is an instance of a mock function object + // controlling the behavior of the method AllMedianPrices. + AllMedianPricesFunc *OracleKeeperAllMedianPricesFunc + // SetExchangeRateWithEventFunc is an instance of a mock function object + // controlling the behavior of the method SetExchangeRateWithEvent. + SetExchangeRateWithEventFunc *OracleKeeperSetExchangeRateWithEventFunc +} + +// NewMockOracleKeeper creates a new mock of the OracleKeeper interface. All +// methods return zero values for all results, unless overwritten. +func NewMockOracleKeeper() *MockOracleKeeper { + return &MockOracleKeeper{ + AllMedianPricesFunc: &OracleKeeperAllMedianPricesFunc{ + defaultHook: func(types.Context) (r0 types2.Prices) { + return + }, + }, + SetExchangeRateWithEventFunc: &OracleKeeperSetExchangeRateWithEventFunc{ + defaultHook: func(types.Context, string, math.LegacyDec) { + return + }, + }, + } +} + +// NewStrictMockOracleKeeper creates a new mock of the OracleKeeper +// interface. All methods panic on invocation, unless overwritten. +func NewStrictMockOracleKeeper() *MockOracleKeeper { + return &MockOracleKeeper{ + AllMedianPricesFunc: &OracleKeeperAllMedianPricesFunc{ + defaultHook: func(types.Context) types2.Prices { + panic("unexpected invocation of MockOracleKeeper.AllMedianPrices") + }, + }, + SetExchangeRateWithEventFunc: &OracleKeeperSetExchangeRateWithEventFunc{ + defaultHook: func(types.Context, string, math.LegacyDec) { + panic("unexpected invocation of MockOracleKeeper.SetExchangeRateWithEvent") + }, + }, + } +} + +// NewMockOracleKeeperFrom creates a new mock of the MockOracleKeeper +// interface. All methods delegate to the given implementation, unless +// overwritten. +func NewMockOracleKeeperFrom(i metoken.OracleKeeper) *MockOracleKeeper { + return &MockOracleKeeper{ + AllMedianPricesFunc: &OracleKeeperAllMedianPricesFunc{ + defaultHook: i.AllMedianPrices, + }, + SetExchangeRateWithEventFunc: &OracleKeeperSetExchangeRateWithEventFunc{ + defaultHook: i.SetExchangeRateWithEvent, + }, + } +} + +// OracleKeeperAllMedianPricesFunc describes the behavior when the +// AllMedianPrices method of the parent MockOracleKeeper instance is +// invoked. +type OracleKeeperAllMedianPricesFunc struct { + defaultHook func(types.Context) types2.Prices + hooks []func(types.Context) types2.Prices + history []OracleKeeperAllMedianPricesFuncCall + mutex sync.Mutex +} + +// AllMedianPrices delegates to the next hook function in the queue and +// stores the parameter and result values of this invocation. +func (m *MockOracleKeeper) AllMedianPrices(v0 types.Context) types2.Prices { + r0 := m.AllMedianPricesFunc.nextHook()(v0) + m.AllMedianPricesFunc.appendCall(OracleKeeperAllMedianPricesFuncCall{v0, r0}) + return r0 } -// MockOracleKeeperMockRecorder is the mock recorder for MockOracleKeeper. -type MockOracleKeeperMockRecorder struct { - mock *MockOracleKeeper +// SetDefaultHook sets function that is called when the AllMedianPrices +// method of the parent MockOracleKeeper instance is invoked and the hook +// queue is empty. +func (f *OracleKeeperAllMedianPricesFunc) SetDefaultHook(hook func(types.Context) types2.Prices) { + f.defaultHook = hook } -// NewMockOracleKeeper creates a new mock instance. -func NewMockOracleKeeper(ctrl *gomock.Controller) *MockOracleKeeper { - mock := &MockOracleKeeper{ctrl: ctrl} - mock.recorder = &MockOracleKeeperMockRecorder{mock} - return mock +// PushHook adds a function to the end of hook queue. Each invocation of the +// AllMedianPrices method of the parent MockOracleKeeper instance invokes +// the hook at the front of the queue and discards it. After the queue is +// empty, the default hook function is invoked for any future action. +func (f *OracleKeeperAllMedianPricesFunc) PushHook(hook func(types.Context) types2.Prices) { + f.mutex.Lock() + f.hooks = append(f.hooks, hook) + f.mutex.Unlock() +} + +// SetDefaultReturn calls SetDefaultHook with a function that returns the +// given values. +func (f *OracleKeeperAllMedianPricesFunc) SetDefaultReturn(r0 types2.Prices) { + f.SetDefaultHook(func(types.Context) types2.Prices { + return r0 + }) +} + +// PushReturn calls PushHook with a function that returns the given values. +func (f *OracleKeeperAllMedianPricesFunc) PushReturn(r0 types2.Prices) { + f.PushHook(func(types.Context) types2.Prices { + return r0 + }) +} + +func (f *OracleKeeperAllMedianPricesFunc) nextHook() func(types.Context) types2.Prices { + f.mutex.Lock() + defer f.mutex.Unlock() + + if len(f.hooks) == 0 { + return f.defaultHook + } + + hook := f.hooks[0] + f.hooks = f.hooks[1:] + return hook +} + +func (f *OracleKeeperAllMedianPricesFunc) appendCall(r0 OracleKeeperAllMedianPricesFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() +} + +// History returns a sequence of OracleKeeperAllMedianPricesFuncCall objects +// describing the invocations of this function. +func (f *OracleKeeperAllMedianPricesFunc) History() []OracleKeeperAllMedianPricesFuncCall { + f.mutex.Lock() + history := make([]OracleKeeperAllMedianPricesFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history +} + +// OracleKeeperAllMedianPricesFuncCall is an object that describes an +// invocation of method AllMedianPrices on an instance of MockOracleKeeper. +type OracleKeeperAllMedianPricesFuncCall struct { + // Arg0 is the value of the 1st argument passed to this method + // invocation. + Arg0 types.Context + // Result0 is the value of the 1st result returned from this method + // invocation. + Result0 types2.Prices +} + +// Args returns an interface slice containing the arguments of this +// invocation. +func (c OracleKeeperAllMedianPricesFuncCall) Args() []interface{} { + return []interface{}{c.Arg0} +} + +// Results returns an interface slice containing the results of this +// invocation. +func (c OracleKeeperAllMedianPricesFuncCall) Results() []interface{} { + return []interface{}{c.Result0} +} + +// OracleKeeperSetExchangeRateWithEventFunc describes the behavior when the +// SetExchangeRateWithEvent method of the parent MockOracleKeeper instance +// is invoked. +type OracleKeeperSetExchangeRateWithEventFunc struct { + defaultHook func(types.Context, string, math.LegacyDec) + hooks []func(types.Context, string, math.LegacyDec) + history []OracleKeeperSetExchangeRateWithEventFuncCall + mutex sync.Mutex +} + +// SetExchangeRateWithEvent delegates to the next hook function in the queue +// and stores the parameter and result values of this invocation. +func (m *MockOracleKeeper) SetExchangeRateWithEvent(v0 types.Context, v1 string, v2 math.LegacyDec) { + m.SetExchangeRateWithEventFunc.nextHook()(v0, v1, v2) + m.SetExchangeRateWithEventFunc.appendCall(OracleKeeperSetExchangeRateWithEventFuncCall{v0, v1, v2}) + return +} + +// SetDefaultHook sets function that is called when the +// SetExchangeRateWithEvent method of the parent MockOracleKeeper instance +// is invoked and the hook queue is empty. +func (f *OracleKeeperSetExchangeRateWithEventFunc) SetDefaultHook(hook func(types.Context, string, math.LegacyDec)) { + f.defaultHook = hook +} + +// PushHook adds a function to the end of hook queue. Each invocation of the +// SetExchangeRateWithEvent method of the parent MockOracleKeeper instance +// invokes the hook at the front of the queue and discards it. After the +// queue is empty, the default hook function is invoked for any future +// action. +func (f *OracleKeeperSetExchangeRateWithEventFunc) PushHook(hook func(types.Context, string, math.LegacyDec)) { + f.mutex.Lock() + f.hooks = append(f.hooks, hook) + f.mutex.Unlock() +} + +// SetDefaultReturn calls SetDefaultHook with a function that returns the +// given values. +func (f *OracleKeeperSetExchangeRateWithEventFunc) SetDefaultReturn() { + f.SetDefaultHook(func(types.Context, string, math.LegacyDec) { + return + }) +} + +// PushReturn calls PushHook with a function that returns the given values. +func (f *OracleKeeperSetExchangeRateWithEventFunc) PushReturn() { + f.PushHook(func(types.Context, string, math.LegacyDec) { + return + }) +} + +func (f *OracleKeeperSetExchangeRateWithEventFunc) nextHook() func(types.Context, string, math.LegacyDec) { + f.mutex.Lock() + defer f.mutex.Unlock() + + if len(f.hooks) == 0 { + return f.defaultHook + } + + hook := f.hooks[0] + f.hooks = f.hooks[1:] + return hook +} + +func (f *OracleKeeperSetExchangeRateWithEventFunc) appendCall(r0 OracleKeeperSetExchangeRateWithEventFuncCall) { + f.mutex.Lock() + f.history = append(f.history, r0) + f.mutex.Unlock() +} + +// History returns a sequence of +// OracleKeeperSetExchangeRateWithEventFuncCall objects describing the +// invocations of this function. +func (f *OracleKeeperSetExchangeRateWithEventFunc) History() []OracleKeeperSetExchangeRateWithEventFuncCall { + f.mutex.Lock() + history := make([]OracleKeeperSetExchangeRateWithEventFuncCall, len(f.history)) + copy(history, f.history) + f.mutex.Unlock() + + return history } -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockOracleKeeper) EXPECT() *MockOracleKeeperMockRecorder { - return m.recorder +// OracleKeeperSetExchangeRateWithEventFuncCall is an object that describes +// an invocation of method SetExchangeRateWithEvent on an instance of +// MockOracleKeeper. +type OracleKeeperSetExchangeRateWithEventFuncCall struct { + // Arg0 is the value of the 1st argument passed to this method + // invocation. + Arg0 types.Context + // Arg1 is the value of the 2nd argument passed to this method + // invocation. + Arg1 string + // Arg2 is the value of the 3rd argument passed to this method + // invocation. + Arg2 math.LegacyDec } -// AllMedianPrices mocks base method. -func (m *MockOracleKeeper) AllMedianPrices(ctx types.Context) types1.Prices { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AllMedianPrices", ctx) - ret0, _ := ret[0].(types1.Prices) - return ret0 +// Args returns an interface slice containing the arguments of this +// invocation. +func (c OracleKeeperSetExchangeRateWithEventFuncCall) Args() []interface{} { + return []interface{}{c.Arg0, c.Arg1, c.Arg2} } -// AllMedianPrices indicates an expected call of AllMedianPrices. -func (mr *MockOracleKeeperMockRecorder) AllMedianPrices(ctx interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AllMedianPrices", reflect.TypeOf((*MockOracleKeeper)(nil).AllMedianPrices), ctx) +// Results returns an interface slice containing the results of this +// invocation. +func (c OracleKeeperSetExchangeRateWithEventFuncCall) Results() []interface{} { + return []interface{}{} } diff --git a/x/metoken/module/abci.go b/x/metoken/module/abci.go index cb76993ccf..2b23205551 100644 --- a/x/metoken/module/abci.go +++ b/x/metoken/module/abci.go @@ -11,5 +11,6 @@ import ( func EndBlocker(k keeper.Keeper) []abci.ValidatorUpdate { util.Panic(k.ClaimLeverageInterest()) util.Panic(k.RebalanceReserves()) + util.Panic(k.SetPricesToOracle()) return []abci.ValidatorUpdate{} } diff --git a/x/oracle/keeper/hooks.go b/x/oracle/keeper/hooks.go index a3d8554e1c..cc1e1bc2e4 100644 --- a/x/oracle/keeper/hooks.go +++ b/x/oracle/keeper/hooks.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/umee-network/umee/v6/x/metoken" leveragetypes "github.com/umee-network/umee/v6/x/leverage/types" "github.com/umee-network/umee/v6/x/oracle/types" @@ -29,6 +30,11 @@ func (h Hooks) AfterTokenRegistered(ctx sdk.Context, token leveragetypes.Token) return } + // Metokens shouldn't be part of oracle accept list. Every index informs its price to oracle each endBlock. + if metoken.IsMeToken(token.BaseDenom) { + return + } + acceptList := h.k.AcceptList(ctx) var tokenExists bool From a1b036e52a2a752fc4671623d7c5803ccbbd6b80 Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Tue, 7 Nov 2023 13:40:31 -0300 Subject: [PATCH 02/18] mocks fixed --- contrib/scripts/mockgen.sh | 8 +- x/metoken/mocks/keepers.go | 1973 ++++-------------------------------- 2 files changed, 201 insertions(+), 1780 deletions(-) diff --git a/contrib/scripts/mockgen.sh b/contrib/scripts/mockgen.sh index 224afa112d..b48a212a03 100644 --- a/contrib/scripts/mockgen.sh +++ b/contrib/scripts/mockgen.sh @@ -2,7 +2,7 @@ mockgen_cmd="go run github.com/golang/mock/mockgen" -$mockgen_cmd -source ./x/ugov/keeper_interfaces.go -package mocks -destination ./x/ugov/mocks/keepers.go -$mockgen_cmd -source ./x/uibc/expected_keepers.go -package mocks -destination ./x/uibc/mocks/keepers.go -$mockgen_cmd -source ./x/metoken/expected_keepers.go -package mocks -destination ./x/metoken/mocks/keepers.go -$mockgen_cmd -source ./app/inflation/expected_keepers.go -package mocks -destination ./app/inflation/mocks/keepers.go +$mockgen_cmd -source ./../../x/ugov/keeper_interfaces.go -package mocks -destination ./../..//x/ugov/mocks/keepers.go +$mockgen_cmd -source ./../../x/uibc/expected_keepers.go -package mocks -destination ./../..//x/uibc/mocks/keepers.go +$mockgen_cmd -source ./../../x/metoken/expected_keepers.go -package mocks -destination ./../../x/metoken/mocks/keepers.go +$mockgen_cmd -source ./../../app/inflation/expected_keepers.go -package mocks -destination ./../..//app/inflation/mocks/keepers.go diff --git a/x/metoken/mocks/keepers.go b/x/metoken/mocks/keepers.go index 44ff91b83b..89d12951af 100644 --- a/x/metoken/mocks/keepers.go +++ b/x/metoken/mocks/keepers.go @@ -1,1867 +1,288 @@ -// Code generated by go-mockgen 1.3.7; DO NOT EDIT. +// Code generated by MockGen. DO NOT EDIT. +// Source: ./../../x/metoken/expected_keepers.go +// Package mocks is a generated GoMock package. package mocks import ( - "sync" + reflect "reflect" math "cosmossdk.io/math" types "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/umee-network/umee/v6/x/leverage/types" - metoken "github.com/umee-network/umee/v6/x/metoken" - types2 "github.com/umee-network/umee/v6/x/oracle/types" + gomock "github.com/golang/mock/gomock" + types0 "github.com/umee-network/umee/v6/x/leverage/types" + types1 "github.com/umee-network/umee/v6/x/oracle/types" ) -// MockBankKeeper is a mock implementation of the BankKeeper interface (from -// the package github.com/umee-network/umee/v6/x/metoken) used for unit -// testing. +// MockBankKeeper is a mock of BankKeeper interface. type MockBankKeeper struct { - // BurnCoinsFunc is an instance of a mock function object controlling - // the behavior of the method BurnCoins. - BurnCoinsFunc *BankKeeperBurnCoinsFunc - // MintCoinsFunc is an instance of a mock function object controlling - // the behavior of the method MintCoins. - MintCoinsFunc *BankKeeperMintCoinsFunc - // SendCoinsFromAccountToModuleFunc is an instance of a mock function - // object controlling the behavior of the method - // SendCoinsFromAccountToModule. - SendCoinsFromAccountToModuleFunc *BankKeeperSendCoinsFromAccountToModuleFunc - // SendCoinsFromModuleToAccountFunc is an instance of a mock function - // object controlling the behavior of the method - // SendCoinsFromModuleToAccount. - SendCoinsFromModuleToAccountFunc *BankKeeperSendCoinsFromModuleToAccountFunc + ctrl *gomock.Controller + recorder *MockBankKeeperMockRecorder } -// NewMockBankKeeper creates a new mock of the BankKeeper interface. All -// methods return zero values for all results, unless overwritten. -func NewMockBankKeeper() *MockBankKeeper { - return &MockBankKeeper{ - BurnCoinsFunc: &BankKeeperBurnCoinsFunc{ - defaultHook: func(types.Context, string, types.Coins) (r0 error) { - return - }, - }, - MintCoinsFunc: &BankKeeperMintCoinsFunc{ - defaultHook: func(types.Context, string, types.Coins) (r0 error) { - return - }, - }, - SendCoinsFromAccountToModuleFunc: &BankKeeperSendCoinsFromAccountToModuleFunc{ - defaultHook: func(types.Context, types.AccAddress, string, types.Coins) (r0 error) { - return - }, - }, - SendCoinsFromModuleToAccountFunc: &BankKeeperSendCoinsFromModuleToAccountFunc{ - defaultHook: func(types.Context, string, types.AccAddress, types.Coins) (r0 error) { - return - }, - }, - } +// MockBankKeeperMockRecorder is the mock recorder for MockBankKeeper. +type MockBankKeeperMockRecorder struct { + mock *MockBankKeeper } -// NewStrictMockBankKeeper creates a new mock of the BankKeeper interface. -// All methods panic on invocation, unless overwritten. -func NewStrictMockBankKeeper() *MockBankKeeper { - return &MockBankKeeper{ - BurnCoinsFunc: &BankKeeperBurnCoinsFunc{ - defaultHook: func(types.Context, string, types.Coins) error { - panic("unexpected invocation of MockBankKeeper.BurnCoins") - }, - }, - MintCoinsFunc: &BankKeeperMintCoinsFunc{ - defaultHook: func(types.Context, string, types.Coins) error { - panic("unexpected invocation of MockBankKeeper.MintCoins") - }, - }, - SendCoinsFromAccountToModuleFunc: &BankKeeperSendCoinsFromAccountToModuleFunc{ - defaultHook: func(types.Context, types.AccAddress, string, types.Coins) error { - panic("unexpected invocation of MockBankKeeper.SendCoinsFromAccountToModule") - }, - }, - SendCoinsFromModuleToAccountFunc: &BankKeeperSendCoinsFromModuleToAccountFunc{ - defaultHook: func(types.Context, string, types.AccAddress, types.Coins) error { - panic("unexpected invocation of MockBankKeeper.SendCoinsFromModuleToAccount") - }, - }, - } +// NewMockBankKeeper creates a new mock instance. +func NewMockBankKeeper(ctrl *gomock.Controller) *MockBankKeeper { + mock := &MockBankKeeper{ctrl: ctrl} + mock.recorder = &MockBankKeeperMockRecorder{mock} + return mock } -// NewMockBankKeeperFrom creates a new mock of the MockBankKeeper interface. -// All methods delegate to the given implementation, unless overwritten. -func NewMockBankKeeperFrom(i metoken.BankKeeper) *MockBankKeeper { - return &MockBankKeeper{ - BurnCoinsFunc: &BankKeeperBurnCoinsFunc{ - defaultHook: i.BurnCoins, - }, - MintCoinsFunc: &BankKeeperMintCoinsFunc{ - defaultHook: i.MintCoins, - }, - SendCoinsFromAccountToModuleFunc: &BankKeeperSendCoinsFromAccountToModuleFunc{ - defaultHook: i.SendCoinsFromAccountToModule, - }, - SendCoinsFromModuleToAccountFunc: &BankKeeperSendCoinsFromModuleToAccountFunc{ - defaultHook: i.SendCoinsFromModuleToAccount, - }, - } +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { + return m.recorder } -// BankKeeperBurnCoinsFunc describes the behavior when the BurnCoins method -// of the parent MockBankKeeper instance is invoked. -type BankKeeperBurnCoinsFunc struct { - defaultHook func(types.Context, string, types.Coins) error - hooks []func(types.Context, string, types.Coins) error - history []BankKeeperBurnCoinsFuncCall - mutex sync.Mutex +// BurnCoins mocks base method. +func (m *MockBankKeeper) BurnCoins(ctx types.Context, moduleName string, amounts types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BurnCoins", ctx, moduleName, amounts) + ret0, _ := ret[0].(error) + return ret0 } -// BurnCoins delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockBankKeeper) BurnCoins(v0 types.Context, v1 string, v2 types.Coins) error { - r0 := m.BurnCoinsFunc.nextHook()(v0, v1, v2) - m.BurnCoinsFunc.appendCall(BankKeeperBurnCoinsFuncCall{v0, v1, v2, r0}) - return r0 +// BurnCoins indicates an expected call of BurnCoins. +func (mr *MockBankKeeperMockRecorder) BurnCoins(ctx, moduleName, amounts interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BurnCoins", reflect.TypeOf((*MockBankKeeper)(nil).BurnCoins), ctx, moduleName, amounts) } -// SetDefaultHook sets function that is called when the BurnCoins method of -// the parent MockBankKeeper instance is invoked and the hook queue is -// empty. -func (f *BankKeeperBurnCoinsFunc) SetDefaultHook(hook func(types.Context, string, types.Coins) error) { - f.defaultHook = hook +// MintCoins mocks base method. +func (m *MockBankKeeper) MintCoins(ctx types.Context, moduleName string, amounts types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MintCoins", ctx, moduleName, amounts) + ret0, _ := ret[0].(error) + return ret0 } -// PushHook adds a function to the end of hook queue. Each invocation of the -// BurnCoins method of the parent MockBankKeeper instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *BankKeeperBurnCoinsFunc) PushHook(hook func(types.Context, string, types.Coins) error) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() +// MintCoins indicates an expected call of MintCoins. +func (mr *MockBankKeeperMockRecorder) MintCoins(ctx, moduleName, amounts interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MintCoins", reflect.TypeOf((*MockBankKeeper)(nil).MintCoins), ctx, moduleName, amounts) } -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *BankKeeperBurnCoinsFunc) SetDefaultReturn(r0 error) { - f.SetDefaultHook(func(types.Context, string, types.Coins) error { - return r0 - }) +// SendCoinsFromAccountToModule mocks base method. +func (m *MockBankKeeper) SendCoinsFromAccountToModule(ctx types.Context, senderAddr types.AccAddress, recipientModule string, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoinsFromAccountToModule", ctx, senderAddr, recipientModule, amt) + ret0, _ := ret[0].(error) + return ret0 } -// PushReturn calls PushHook with a function that returns the given values. -func (f *BankKeeperBurnCoinsFunc) PushReturn(r0 error) { - f.PushHook(func(types.Context, string, types.Coins) error { - return r0 - }) +// SendCoinsFromAccountToModule indicates an expected call of SendCoinsFromAccountToModule. +func (mr *MockBankKeeperMockRecorder) SendCoinsFromAccountToModule(ctx, senderAddr, recipientModule, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromAccountToModule", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromAccountToModule), ctx, senderAddr, recipientModule, amt) } -func (f *BankKeeperBurnCoinsFunc) nextHook() func(types.Context, string, types.Coins) error { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *BankKeeperBurnCoinsFunc) appendCall(r0 BankKeeperBurnCoinsFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of BankKeeperBurnCoinsFuncCall objects -// describing the invocations of this function. -func (f *BankKeeperBurnCoinsFunc) History() []BankKeeperBurnCoinsFuncCall { - f.mutex.Lock() - history := make([]BankKeeperBurnCoinsFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// BankKeeperBurnCoinsFuncCall is an object that describes an invocation of -// method BurnCoins on an instance of MockBankKeeper. -type BankKeeperBurnCoinsFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 types.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 types.Coins - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c BankKeeperBurnCoinsFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c BankKeeperBurnCoinsFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// BankKeeperMintCoinsFunc describes the behavior when the MintCoins method -// of the parent MockBankKeeper instance is invoked. -type BankKeeperMintCoinsFunc struct { - defaultHook func(types.Context, string, types.Coins) error - hooks []func(types.Context, string, types.Coins) error - history []BankKeeperMintCoinsFuncCall - mutex sync.Mutex -} - -// MintCoins delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockBankKeeper) MintCoins(v0 types.Context, v1 string, v2 types.Coins) error { - r0 := m.MintCoinsFunc.nextHook()(v0, v1, v2) - m.MintCoinsFunc.appendCall(BankKeeperMintCoinsFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the MintCoins method of -// the parent MockBankKeeper instance is invoked and the hook queue is -// empty. -func (f *BankKeeperMintCoinsFunc) SetDefaultHook(hook func(types.Context, string, types.Coins) error) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// MintCoins method of the parent MockBankKeeper instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *BankKeeperMintCoinsFunc) PushHook(hook func(types.Context, string, types.Coins) error) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() +// SendCoinsFromModuleToAccount mocks base method. +func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx types.Context, senderModule string, recipientAddr types.AccAddress, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt) + ret0, _ := ret[0].(error) + return ret0 } -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *BankKeeperMintCoinsFunc) SetDefaultReturn(r0 error) { - f.SetDefaultHook(func(types.Context, string, types.Coins) error { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *BankKeeperMintCoinsFunc) PushReturn(r0 error) { - f.PushHook(func(types.Context, string, types.Coins) error { - return r0 - }) -} - -func (f *BankKeeperMintCoinsFunc) nextHook() func(types.Context, string, types.Coins) error { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *BankKeeperMintCoinsFunc) appendCall(r0 BankKeeperMintCoinsFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of BankKeeperMintCoinsFuncCall objects -// describing the invocations of this function. -func (f *BankKeeperMintCoinsFunc) History() []BankKeeperMintCoinsFuncCall { - f.mutex.Lock() - history := make([]BankKeeperMintCoinsFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// BankKeeperMintCoinsFuncCall is an object that describes an invocation of -// method MintCoins on an instance of MockBankKeeper. -type BankKeeperMintCoinsFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 types.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 types.Coins - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c BankKeeperMintCoinsFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c BankKeeperMintCoinsFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// BankKeeperSendCoinsFromAccountToModuleFunc describes the behavior when -// the SendCoinsFromAccountToModule method of the parent MockBankKeeper -// instance is invoked. -type BankKeeperSendCoinsFromAccountToModuleFunc struct { - defaultHook func(types.Context, types.AccAddress, string, types.Coins) error - hooks []func(types.Context, types.AccAddress, string, types.Coins) error - history []BankKeeperSendCoinsFromAccountToModuleFuncCall - mutex sync.Mutex -} - -// SendCoinsFromAccountToModule delegates to the next hook function in the -// queue and stores the parameter and result values of this invocation. -func (m *MockBankKeeper) SendCoinsFromAccountToModule(v0 types.Context, v1 types.AccAddress, v2 string, v3 types.Coins) error { - r0 := m.SendCoinsFromAccountToModuleFunc.nextHook()(v0, v1, v2, v3) - m.SendCoinsFromAccountToModuleFunc.appendCall(BankKeeperSendCoinsFromAccountToModuleFuncCall{v0, v1, v2, v3, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the -// SendCoinsFromAccountToModule method of the parent MockBankKeeper instance -// is invoked and the hook queue is empty. -func (f *BankKeeperSendCoinsFromAccountToModuleFunc) SetDefaultHook(hook func(types.Context, types.AccAddress, string, types.Coins) error) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// SendCoinsFromAccountToModule method of the parent MockBankKeeper instance -// invokes the hook at the front of the queue and discards it. After the -// queue is empty, the default hook function is invoked for any future -// action. -func (f *BankKeeperSendCoinsFromAccountToModuleFunc) PushHook(hook func(types.Context, types.AccAddress, string, types.Coins) error) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *BankKeeperSendCoinsFromAccountToModuleFunc) SetDefaultReturn(r0 error) { - f.SetDefaultHook(func(types.Context, types.AccAddress, string, types.Coins) error { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *BankKeeperSendCoinsFromAccountToModuleFunc) PushReturn(r0 error) { - f.PushHook(func(types.Context, types.AccAddress, string, types.Coins) error { - return r0 - }) -} - -func (f *BankKeeperSendCoinsFromAccountToModuleFunc) nextHook() func(types.Context, types.AccAddress, string, types.Coins) error { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *BankKeeperSendCoinsFromAccountToModuleFunc) appendCall(r0 BankKeeperSendCoinsFromAccountToModuleFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of -// BankKeeperSendCoinsFromAccountToModuleFuncCall objects describing the -// invocations of this function. -func (f *BankKeeperSendCoinsFromAccountToModuleFunc) History() []BankKeeperSendCoinsFromAccountToModuleFuncCall { - f.mutex.Lock() - history := make([]BankKeeperSendCoinsFromAccountToModuleFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// BankKeeperSendCoinsFromAccountToModuleFuncCall is an object that -// describes an invocation of method SendCoinsFromAccountToModule on an -// instance of MockBankKeeper. -type BankKeeperSendCoinsFromAccountToModuleFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 types.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 types.AccAddress - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 string - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 types.Coins - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c BankKeeperSendCoinsFromAccountToModuleFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c BankKeeperSendCoinsFromAccountToModuleFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// BankKeeperSendCoinsFromModuleToAccountFunc describes the behavior when -// the SendCoinsFromModuleToAccount method of the parent MockBankKeeper -// instance is invoked. -type BankKeeperSendCoinsFromModuleToAccountFunc struct { - defaultHook func(types.Context, string, types.AccAddress, types.Coins) error - hooks []func(types.Context, string, types.AccAddress, types.Coins) error - history []BankKeeperSendCoinsFromModuleToAccountFuncCall - mutex sync.Mutex -} - -// SendCoinsFromModuleToAccount delegates to the next hook function in the -// queue and stores the parameter and result values of this invocation. -func (m *MockBankKeeper) SendCoinsFromModuleToAccount(v0 types.Context, v1 string, v2 types.AccAddress, v3 types.Coins) error { - r0 := m.SendCoinsFromModuleToAccountFunc.nextHook()(v0, v1, v2, v3) - m.SendCoinsFromModuleToAccountFunc.appendCall(BankKeeperSendCoinsFromModuleToAccountFuncCall{v0, v1, v2, v3, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the -// SendCoinsFromModuleToAccount method of the parent MockBankKeeper instance -// is invoked and the hook queue is empty. -func (f *BankKeeperSendCoinsFromModuleToAccountFunc) SetDefaultHook(hook func(types.Context, string, types.AccAddress, types.Coins) error) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// SendCoinsFromModuleToAccount method of the parent MockBankKeeper instance -// invokes the hook at the front of the queue and discards it. After the -// queue is empty, the default hook function is invoked for any future -// action. -func (f *BankKeeperSendCoinsFromModuleToAccountFunc) PushHook(hook func(types.Context, string, types.AccAddress, types.Coins) error) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *BankKeeperSendCoinsFromModuleToAccountFunc) SetDefaultReturn(r0 error) { - f.SetDefaultHook(func(types.Context, string, types.AccAddress, types.Coins) error { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *BankKeeperSendCoinsFromModuleToAccountFunc) PushReturn(r0 error) { - f.PushHook(func(types.Context, string, types.AccAddress, types.Coins) error { - return r0 - }) -} - -func (f *BankKeeperSendCoinsFromModuleToAccountFunc) nextHook() func(types.Context, string, types.AccAddress, types.Coins) error { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook +// SendCoinsFromModuleToAccount indicates an expected call of SendCoinsFromModuleToAccount. +func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromModuleToAccount", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromModuleToAccount), ctx, senderModule, recipientAddr, amt) } -func (f *BankKeeperSendCoinsFromModuleToAccountFunc) appendCall(r0 BankKeeperSendCoinsFromModuleToAccountFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of -// BankKeeperSendCoinsFromModuleToAccountFuncCall objects describing the -// invocations of this function. -func (f *BankKeeperSendCoinsFromModuleToAccountFunc) History() []BankKeeperSendCoinsFromModuleToAccountFuncCall { - f.mutex.Lock() - history := make([]BankKeeperSendCoinsFromModuleToAccountFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// BankKeeperSendCoinsFromModuleToAccountFuncCall is an object that -// describes an invocation of method SendCoinsFromModuleToAccount on an -// instance of MockBankKeeper. -type BankKeeperSendCoinsFromModuleToAccountFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 types.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 types.AccAddress - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 types.Coins - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c BankKeeperSendCoinsFromModuleToAccountFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c BankKeeperSendCoinsFromModuleToAccountFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// MockLeverageKeeper is a mock implementation of the LeverageKeeper -// interface (from the package github.com/umee-network/umee/v6/x/metoken) -// used for unit testing. +// MockLeverageKeeper is a mock of LeverageKeeper interface. type MockLeverageKeeper struct { - // GetAllSuppliedFunc is an instance of a mock function object - // controlling the behavior of the method GetAllSupplied. - GetAllSuppliedFunc *LeverageKeeperGetAllSuppliedFunc - // GetTokenSettingsFunc is an instance of a mock function object - // controlling the behavior of the method GetTokenSettings. - GetTokenSettingsFunc *LeverageKeeperGetTokenSettingsFunc - // GetTotalSupplyFunc is an instance of a mock function object - // controlling the behavior of the method GetTotalSupply. - GetTotalSupplyFunc *LeverageKeeperGetTotalSupplyFunc - // ModuleMaxWithdrawFunc is an instance of a mock function object - // controlling the behavior of the method ModuleMaxWithdraw. - ModuleMaxWithdrawFunc *LeverageKeeperModuleMaxWithdrawFunc - // SupplyFromModuleFunc is an instance of a mock function object - // controlling the behavior of the method SupplyFromModule. - SupplyFromModuleFunc *LeverageKeeperSupplyFromModuleFunc - // ToTokenFunc is an instance of a mock function object controlling the - // behavior of the method ToToken. - ToTokenFunc *LeverageKeeperToTokenFunc - // ToUTokenFunc is an instance of a mock function object controlling the - // behavior of the method ToUToken. - ToUTokenFunc *LeverageKeeperToUTokenFunc - // WithdrawToModuleFunc is an instance of a mock function object - // controlling the behavior of the method WithdrawToModule. - WithdrawToModuleFunc *LeverageKeeperWithdrawToModuleFunc -} - -// NewMockLeverageKeeper creates a new mock of the LeverageKeeper interface. -// All methods return zero values for all results, unless overwritten. -func NewMockLeverageKeeper() *MockLeverageKeeper { - return &MockLeverageKeeper{ - GetAllSuppliedFunc: &LeverageKeeperGetAllSuppliedFunc{ - defaultHook: func(types.Context, types.AccAddress) (r0 types.Coins, r1 error) { - return - }, - }, - GetTokenSettingsFunc: &LeverageKeeperGetTokenSettingsFunc{ - defaultHook: func(types.Context, string) (r0 types1.Token, r1 error) { - return - }, - }, - GetTotalSupplyFunc: &LeverageKeeperGetTotalSupplyFunc{ - defaultHook: func(types.Context, string) (r0 types.Coin, r1 error) { - return - }, - }, - ModuleMaxWithdrawFunc: &LeverageKeeperModuleMaxWithdrawFunc{ - defaultHook: func(types.Context, types.Coin) (r0 math.Int, r1 error) { - return - }, - }, - SupplyFromModuleFunc: &LeverageKeeperSupplyFromModuleFunc{ - defaultHook: func(types.Context, string, types.Coin) (r0 types.Coin, r1 bool, r2 error) { - return - }, - }, - ToTokenFunc: &LeverageKeeperToTokenFunc{ - defaultHook: func(types.Context, types.Coin) (r0 types.Coin, r1 error) { - return - }, - }, - ToUTokenFunc: &LeverageKeeperToUTokenFunc{ - defaultHook: func(types.Context, types.Coin) (r0 types.Coin, r1 error) { - return - }, - }, - WithdrawToModuleFunc: &LeverageKeeperWithdrawToModuleFunc{ - defaultHook: func(types.Context, string, types.Coin) (r0 types.Coin, r1 bool, r2 error) { - return - }, - }, - } -} - -// NewStrictMockLeverageKeeper creates a new mock of the LeverageKeeper -// interface. All methods panic on invocation, unless overwritten. -func NewStrictMockLeverageKeeper() *MockLeverageKeeper { - return &MockLeverageKeeper{ - GetAllSuppliedFunc: &LeverageKeeperGetAllSuppliedFunc{ - defaultHook: func(types.Context, types.AccAddress) (types.Coins, error) { - panic("unexpected invocation of MockLeverageKeeper.GetAllSupplied") - }, - }, - GetTokenSettingsFunc: &LeverageKeeperGetTokenSettingsFunc{ - defaultHook: func(types.Context, string) (types1.Token, error) { - panic("unexpected invocation of MockLeverageKeeper.GetTokenSettings") - }, - }, - GetTotalSupplyFunc: &LeverageKeeperGetTotalSupplyFunc{ - defaultHook: func(types.Context, string) (types.Coin, error) { - panic("unexpected invocation of MockLeverageKeeper.GetTotalSupply") - }, - }, - ModuleMaxWithdrawFunc: &LeverageKeeperModuleMaxWithdrawFunc{ - defaultHook: func(types.Context, types.Coin) (math.Int, error) { - panic("unexpected invocation of MockLeverageKeeper.ModuleMaxWithdraw") - }, - }, - SupplyFromModuleFunc: &LeverageKeeperSupplyFromModuleFunc{ - defaultHook: func(types.Context, string, types.Coin) (types.Coin, bool, error) { - panic("unexpected invocation of MockLeverageKeeper.SupplyFromModule") - }, - }, - ToTokenFunc: &LeverageKeeperToTokenFunc{ - defaultHook: func(types.Context, types.Coin) (types.Coin, error) { - panic("unexpected invocation of MockLeverageKeeper.ToToken") - }, - }, - ToUTokenFunc: &LeverageKeeperToUTokenFunc{ - defaultHook: func(types.Context, types.Coin) (types.Coin, error) { - panic("unexpected invocation of MockLeverageKeeper.ToUToken") - }, - }, - WithdrawToModuleFunc: &LeverageKeeperWithdrawToModuleFunc{ - defaultHook: func(types.Context, string, types.Coin) (types.Coin, bool, error) { - panic("unexpected invocation of MockLeverageKeeper.WithdrawToModule") - }, - }, - } -} - -// NewMockLeverageKeeperFrom creates a new mock of the MockLeverageKeeper -// interface. All methods delegate to the given implementation, unless -// overwritten. -func NewMockLeverageKeeperFrom(i metoken.LeverageKeeper) *MockLeverageKeeper { - return &MockLeverageKeeper{ - GetAllSuppliedFunc: &LeverageKeeperGetAllSuppliedFunc{ - defaultHook: i.GetAllSupplied, - }, - GetTokenSettingsFunc: &LeverageKeeperGetTokenSettingsFunc{ - defaultHook: i.GetTokenSettings, - }, - GetTotalSupplyFunc: &LeverageKeeperGetTotalSupplyFunc{ - defaultHook: i.GetTotalSupply, - }, - ModuleMaxWithdrawFunc: &LeverageKeeperModuleMaxWithdrawFunc{ - defaultHook: i.ModuleMaxWithdraw, - }, - SupplyFromModuleFunc: &LeverageKeeperSupplyFromModuleFunc{ - defaultHook: i.SupplyFromModule, - }, - ToTokenFunc: &LeverageKeeperToTokenFunc{ - defaultHook: i.ToToken, - }, - ToUTokenFunc: &LeverageKeeperToUTokenFunc{ - defaultHook: i.ToUToken, - }, - WithdrawToModuleFunc: &LeverageKeeperWithdrawToModuleFunc{ - defaultHook: i.WithdrawToModule, - }, - } -} - -// LeverageKeeperGetAllSuppliedFunc describes the behavior when the -// GetAllSupplied method of the parent MockLeverageKeeper instance is -// invoked. -type LeverageKeeperGetAllSuppliedFunc struct { - defaultHook func(types.Context, types.AccAddress) (types.Coins, error) - hooks []func(types.Context, types.AccAddress) (types.Coins, error) - history []LeverageKeeperGetAllSuppliedFuncCall - mutex sync.Mutex -} - -// GetAllSupplied delegates to the next hook function in the queue and -// stores the parameter and result values of this invocation. -func (m *MockLeverageKeeper) GetAllSupplied(v0 types.Context, v1 types.AccAddress) (types.Coins, error) { - r0, r1 := m.GetAllSuppliedFunc.nextHook()(v0, v1) - m.GetAllSuppliedFunc.appendCall(LeverageKeeperGetAllSuppliedFuncCall{v0, v1, r0, r1}) - return r0, r1 -} - -// SetDefaultHook sets function that is called when the GetAllSupplied -// method of the parent MockLeverageKeeper instance is invoked and the hook -// queue is empty. -func (f *LeverageKeeperGetAllSuppliedFunc) SetDefaultHook(hook func(types.Context, types.AccAddress) (types.Coins, error)) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// GetAllSupplied method of the parent MockLeverageKeeper instance invokes -// the hook at the front of the queue and discards it. After the queue is -// empty, the default hook function is invoked for any future action. -func (f *LeverageKeeperGetAllSuppliedFunc) PushHook(hook func(types.Context, types.AccAddress) (types.Coins, error)) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *LeverageKeeperGetAllSuppliedFunc) SetDefaultReturn(r0 types.Coins, r1 error) { - f.SetDefaultHook(func(types.Context, types.AccAddress) (types.Coins, error) { - return r0, r1 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *LeverageKeeperGetAllSuppliedFunc) PushReturn(r0 types.Coins, r1 error) { - f.PushHook(func(types.Context, types.AccAddress) (types.Coins, error) { - return r0, r1 - }) -} - -func (f *LeverageKeeperGetAllSuppliedFunc) nextHook() func(types.Context, types.AccAddress) (types.Coins, error) { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *LeverageKeeperGetAllSuppliedFunc) appendCall(r0 LeverageKeeperGetAllSuppliedFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of LeverageKeeperGetAllSuppliedFuncCall -// objects describing the invocations of this function. -func (f *LeverageKeeperGetAllSuppliedFunc) History() []LeverageKeeperGetAllSuppliedFuncCall { - f.mutex.Lock() - history := make([]LeverageKeeperGetAllSuppliedFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// LeverageKeeperGetAllSuppliedFuncCall is an object that describes an -// invocation of method GetAllSupplied on an instance of MockLeverageKeeper. -type LeverageKeeperGetAllSuppliedFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 types.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 types.AccAddress - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 types.Coins - // Result1 is the value of the 2nd result returned from this method - // invocation. - Result1 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c LeverageKeeperGetAllSuppliedFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c LeverageKeeperGetAllSuppliedFuncCall) Results() []interface{} { - return []interface{}{c.Result0, c.Result1} -} - -// LeverageKeeperGetTokenSettingsFunc describes the behavior when the -// GetTokenSettings method of the parent MockLeverageKeeper instance is -// invoked. -type LeverageKeeperGetTokenSettingsFunc struct { - defaultHook func(types.Context, string) (types1.Token, error) - hooks []func(types.Context, string) (types1.Token, error) - history []LeverageKeeperGetTokenSettingsFuncCall - mutex sync.Mutex -} - -// GetTokenSettings delegates to the next hook function in the queue and -// stores the parameter and result values of this invocation. -func (m *MockLeverageKeeper) GetTokenSettings(v0 types.Context, v1 string) (types1.Token, error) { - r0, r1 := m.GetTokenSettingsFunc.nextHook()(v0, v1) - m.GetTokenSettingsFunc.appendCall(LeverageKeeperGetTokenSettingsFuncCall{v0, v1, r0, r1}) - return r0, r1 -} - -// SetDefaultHook sets function that is called when the GetTokenSettings -// method of the parent MockLeverageKeeper instance is invoked and the hook -// queue is empty. -func (f *LeverageKeeperGetTokenSettingsFunc) SetDefaultHook(hook func(types.Context, string) (types1.Token, error)) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// GetTokenSettings method of the parent MockLeverageKeeper instance invokes -// the hook at the front of the queue and discards it. After the queue is -// empty, the default hook function is invoked for any future action. -func (f *LeverageKeeperGetTokenSettingsFunc) PushHook(hook func(types.Context, string) (types1.Token, error)) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *LeverageKeeperGetTokenSettingsFunc) SetDefaultReturn(r0 types1.Token, r1 error) { - f.SetDefaultHook(func(types.Context, string) (types1.Token, error) { - return r0, r1 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *LeverageKeeperGetTokenSettingsFunc) PushReturn(r0 types1.Token, r1 error) { - f.PushHook(func(types.Context, string) (types1.Token, error) { - return r0, r1 - }) -} - -func (f *LeverageKeeperGetTokenSettingsFunc) nextHook() func(types.Context, string) (types1.Token, error) { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *LeverageKeeperGetTokenSettingsFunc) appendCall(r0 LeverageKeeperGetTokenSettingsFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of LeverageKeeperGetTokenSettingsFuncCall -// objects describing the invocations of this function. -func (f *LeverageKeeperGetTokenSettingsFunc) History() []LeverageKeeperGetTokenSettingsFuncCall { - f.mutex.Lock() - history := make([]LeverageKeeperGetTokenSettingsFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// LeverageKeeperGetTokenSettingsFuncCall is an object that describes an -// invocation of method GetTokenSettings on an instance of -// MockLeverageKeeper. -type LeverageKeeperGetTokenSettingsFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 types.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 types1.Token - // Result1 is the value of the 2nd result returned from this method - // invocation. - Result1 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c LeverageKeeperGetTokenSettingsFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c LeverageKeeperGetTokenSettingsFuncCall) Results() []interface{} { - return []interface{}{c.Result0, c.Result1} -} - -// LeverageKeeperGetTotalSupplyFunc describes the behavior when the -// GetTotalSupply method of the parent MockLeverageKeeper instance is -// invoked. -type LeverageKeeperGetTotalSupplyFunc struct { - defaultHook func(types.Context, string) (types.Coin, error) - hooks []func(types.Context, string) (types.Coin, error) - history []LeverageKeeperGetTotalSupplyFuncCall - mutex sync.Mutex -} - -// GetTotalSupply delegates to the next hook function in the queue and -// stores the parameter and result values of this invocation. -func (m *MockLeverageKeeper) GetTotalSupply(v0 types.Context, v1 string) (types.Coin, error) { - r0, r1 := m.GetTotalSupplyFunc.nextHook()(v0, v1) - m.GetTotalSupplyFunc.appendCall(LeverageKeeperGetTotalSupplyFuncCall{v0, v1, r0, r1}) - return r0, r1 -} - -// SetDefaultHook sets function that is called when the GetTotalSupply -// method of the parent MockLeverageKeeper instance is invoked and the hook -// queue is empty. -func (f *LeverageKeeperGetTotalSupplyFunc) SetDefaultHook(hook func(types.Context, string) (types.Coin, error)) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// GetTotalSupply method of the parent MockLeverageKeeper instance invokes -// the hook at the front of the queue and discards it. After the queue is -// empty, the default hook function is invoked for any future action. -func (f *LeverageKeeperGetTotalSupplyFunc) PushHook(hook func(types.Context, string) (types.Coin, error)) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *LeverageKeeperGetTotalSupplyFunc) SetDefaultReturn(r0 types.Coin, r1 error) { - f.SetDefaultHook(func(types.Context, string) (types.Coin, error) { - return r0, r1 - }) + ctrl *gomock.Controller + recorder *MockLeverageKeeperMockRecorder } -// PushReturn calls PushHook with a function that returns the given values. -func (f *LeverageKeeperGetTotalSupplyFunc) PushReturn(r0 types.Coin, r1 error) { - f.PushHook(func(types.Context, string) (types.Coin, error) { - return r0, r1 - }) +// MockLeverageKeeperMockRecorder is the mock recorder for MockLeverageKeeper. +type MockLeverageKeeperMockRecorder struct { + mock *MockLeverageKeeper } -func (f *LeverageKeeperGetTotalSupplyFunc) nextHook() func(types.Context, string) (types.Coin, error) { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook +// NewMockLeverageKeeper creates a new mock instance. +func NewMockLeverageKeeper(ctrl *gomock.Controller) *MockLeverageKeeper { + mock := &MockLeverageKeeper{ctrl: ctrl} + mock.recorder = &MockLeverageKeeperMockRecorder{mock} + return mock } -func (f *LeverageKeeperGetTotalSupplyFunc) appendCall(r0 LeverageKeeperGetTotalSupplyFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockLeverageKeeper) EXPECT() *MockLeverageKeeperMockRecorder { + return m.recorder } -// History returns a sequence of LeverageKeeperGetTotalSupplyFuncCall -// objects describing the invocations of this function. -func (f *LeverageKeeperGetTotalSupplyFunc) History() []LeverageKeeperGetTotalSupplyFuncCall { - f.mutex.Lock() - history := make([]LeverageKeeperGetTotalSupplyFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history +// GetAllSupplied mocks base method. +func (m *MockLeverageKeeper) GetAllSupplied(ctx types.Context, supplierAddr types.AccAddress) (types.Coins, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAllSupplied", ctx, supplierAddr) + ret0, _ := ret[0].(types.Coins) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// LeverageKeeperGetTotalSupplyFuncCall is an object that describes an -// invocation of method GetTotalSupply on an instance of MockLeverageKeeper. -type LeverageKeeperGetTotalSupplyFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 types.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 types.Coin - // Result1 is the value of the 2nd result returned from this method - // invocation. - Result1 error +// GetAllSupplied indicates an expected call of GetAllSupplied. +func (mr *MockLeverageKeeperMockRecorder) GetAllSupplied(ctx, supplierAddr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllSupplied", reflect.TypeOf((*MockLeverageKeeper)(nil).GetAllSupplied), ctx, supplierAddr) } -// Args returns an interface slice containing the arguments of this -// invocation. -func (c LeverageKeeperGetTotalSupplyFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} +// GetTokenSettings mocks base method. +func (m *MockLeverageKeeper) GetTokenSettings(ctx types.Context, denom string) (types0.Token, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTokenSettings", ctx, denom) + ret0, _ := ret[0].(types0.Token) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// Results returns an interface slice containing the results of this -// invocation. -func (c LeverageKeeperGetTotalSupplyFuncCall) Results() []interface{} { - return []interface{}{c.Result0, c.Result1} +// GetTokenSettings indicates an expected call of GetTokenSettings. +func (mr *MockLeverageKeeperMockRecorder) GetTokenSettings(ctx, denom interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenSettings", reflect.TypeOf((*MockLeverageKeeper)(nil).GetTokenSettings), ctx, denom) } -// LeverageKeeperModuleMaxWithdrawFunc describes the behavior when the -// ModuleMaxWithdraw method of the parent MockLeverageKeeper instance is -// invoked. -type LeverageKeeperModuleMaxWithdrawFunc struct { - defaultHook func(types.Context, types.Coin) (math.Int, error) - hooks []func(types.Context, types.Coin) (math.Int, error) - history []LeverageKeeperModuleMaxWithdrawFuncCall - mutex sync.Mutex +// GetTotalSupply mocks base method. +func (m *MockLeverageKeeper) GetTotalSupply(ctx types.Context, denom string) (types.Coin, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTotalSupply", ctx, denom) + ret0, _ := ret[0].(types.Coin) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// ModuleMaxWithdraw delegates to the next hook function in the queue and -// stores the parameter and result values of this invocation. -func (m *MockLeverageKeeper) ModuleMaxWithdraw(v0 types.Context, v1 types.Coin) (math.Int, error) { - r0, r1 := m.ModuleMaxWithdrawFunc.nextHook()(v0, v1) - m.ModuleMaxWithdrawFunc.appendCall(LeverageKeeperModuleMaxWithdrawFuncCall{v0, v1, r0, r1}) - return r0, r1 +// GetTotalSupply indicates an expected call of GetTotalSupply. +func (mr *MockLeverageKeeperMockRecorder) GetTotalSupply(ctx, denom interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTotalSupply", reflect.TypeOf((*MockLeverageKeeper)(nil).GetTotalSupply), ctx, denom) } -// SetDefaultHook sets function that is called when the ModuleMaxWithdraw -// method of the parent MockLeverageKeeper instance is invoked and the hook -// queue is empty. -func (f *LeverageKeeperModuleMaxWithdrawFunc) SetDefaultHook(hook func(types.Context, types.Coin) (math.Int, error)) { - f.defaultHook = hook +// ModuleMaxWithdraw mocks base method. +func (m *MockLeverageKeeper) ModuleMaxWithdraw(ctx types.Context, spendableUTokens types.Coin) (math.Int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ModuleMaxWithdraw", ctx, spendableUTokens) + ret0, _ := ret[0].(math.Int) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// PushHook adds a function to the end of hook queue. Each invocation of the -// ModuleMaxWithdraw method of the parent MockLeverageKeeper instance -// invokes the hook at the front of the queue and discards it. After the -// queue is empty, the default hook function is invoked for any future -// action. -func (f *LeverageKeeperModuleMaxWithdrawFunc) PushHook(hook func(types.Context, types.Coin) (math.Int, error)) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() +// ModuleMaxWithdraw indicates an expected call of ModuleMaxWithdraw. +func (mr *MockLeverageKeeperMockRecorder) ModuleMaxWithdraw(ctx, spendableUTokens interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ModuleMaxWithdraw", reflect.TypeOf((*MockLeverageKeeper)(nil).ModuleMaxWithdraw), ctx, spendableUTokens) } -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *LeverageKeeperModuleMaxWithdrawFunc) SetDefaultReturn(r0 math.Int, r1 error) { - f.SetDefaultHook(func(types.Context, types.Coin) (math.Int, error) { - return r0, r1 - }) +// SupplyFromModule mocks base method. +func (m *MockLeverageKeeper) SupplyFromModule(ctx types.Context, fromModule string, coin types.Coin) (types.Coin, bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SupplyFromModule", ctx, fromModule, coin) + ret0, _ := ret[0].(types.Coin) + ret1, _ := ret[1].(bool) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 } -// PushReturn calls PushHook with a function that returns the given values. -func (f *LeverageKeeperModuleMaxWithdrawFunc) PushReturn(r0 math.Int, r1 error) { - f.PushHook(func(types.Context, types.Coin) (math.Int, error) { - return r0, r1 - }) +// SupplyFromModule indicates an expected call of SupplyFromModule. +func (mr *MockLeverageKeeperMockRecorder) SupplyFromModule(ctx, fromModule, coin interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SupplyFromModule", reflect.TypeOf((*MockLeverageKeeper)(nil).SupplyFromModule), ctx, fromModule, coin) } -func (f *LeverageKeeperModuleMaxWithdrawFunc) nextHook() func(types.Context, types.Coin) (math.Int, error) { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *LeverageKeeperModuleMaxWithdrawFunc) appendCall(r0 LeverageKeeperModuleMaxWithdrawFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of LeverageKeeperModuleMaxWithdrawFuncCall -// objects describing the invocations of this function. -func (f *LeverageKeeperModuleMaxWithdrawFunc) History() []LeverageKeeperModuleMaxWithdrawFuncCall { - f.mutex.Lock() - history := make([]LeverageKeeperModuleMaxWithdrawFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history +// ToToken mocks base method. +func (m *MockLeverageKeeper) ToToken(ctx types.Context, uToken types.Coin) (types.Coin, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ToToken", ctx, uToken) + ret0, _ := ret[0].(types.Coin) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// LeverageKeeperModuleMaxWithdrawFuncCall is an object that describes an -// invocation of method ModuleMaxWithdraw on an instance of -// MockLeverageKeeper. -type LeverageKeeperModuleMaxWithdrawFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 types.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 types.Coin - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 math.Int - // Result1 is the value of the 2nd result returned from this method - // invocation. - Result1 error +// ToToken indicates an expected call of ToToken. +func (mr *MockLeverageKeeperMockRecorder) ToToken(ctx, uToken interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToToken", reflect.TypeOf((*MockLeverageKeeper)(nil).ToToken), ctx, uToken) } -// Args returns an interface slice containing the arguments of this -// invocation. -func (c LeverageKeeperModuleMaxWithdrawFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} +// ToUToken mocks base method. +func (m *MockLeverageKeeper) ToUToken(ctx types.Context, token types.Coin) (types.Coin, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ToUToken", ctx, token) + ret0, _ := ret[0].(types.Coin) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// Results returns an interface slice containing the results of this -// invocation. -func (c LeverageKeeperModuleMaxWithdrawFuncCall) Results() []interface{} { - return []interface{}{c.Result0, c.Result1} +// ToUToken indicates an expected call of ToUToken. +func (mr *MockLeverageKeeperMockRecorder) ToUToken(ctx, token interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToUToken", reflect.TypeOf((*MockLeverageKeeper)(nil).ToUToken), ctx, token) } -// LeverageKeeperSupplyFromModuleFunc describes the behavior when the -// SupplyFromModule method of the parent MockLeverageKeeper instance is -// invoked. -type LeverageKeeperSupplyFromModuleFunc struct { - defaultHook func(types.Context, string, types.Coin) (types.Coin, bool, error) - hooks []func(types.Context, string, types.Coin) (types.Coin, bool, error) - history []LeverageKeeperSupplyFromModuleFuncCall - mutex sync.Mutex +// WithdrawToModule mocks base method. +func (m *MockLeverageKeeper) WithdrawToModule(ctx types.Context, toModule string, uToken types.Coin) (types.Coin, bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WithdrawToModule", ctx, toModule, uToken) + ret0, _ := ret[0].(types.Coin) + ret1, _ := ret[1].(bool) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 } -// SupplyFromModule delegates to the next hook function in the queue and -// stores the parameter and result values of this invocation. -func (m *MockLeverageKeeper) SupplyFromModule(v0 types.Context, v1 string, v2 types.Coin) (types.Coin, bool, error) { - r0, r1, r2 := m.SupplyFromModuleFunc.nextHook()(v0, v1, v2) - m.SupplyFromModuleFunc.appendCall(LeverageKeeperSupplyFromModuleFuncCall{v0, v1, v2, r0, r1, r2}) - return r0, r1, r2 +// WithdrawToModule indicates an expected call of WithdrawToModule. +func (mr *MockLeverageKeeperMockRecorder) WithdrawToModule(ctx, toModule, uToken interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WithdrawToModule", reflect.TypeOf((*MockLeverageKeeper)(nil).WithdrawToModule), ctx, toModule, uToken) } -// SetDefaultHook sets function that is called when the SupplyFromModule -// method of the parent MockLeverageKeeper instance is invoked and the hook -// queue is empty. -func (f *LeverageKeeperSupplyFromModuleFunc) SetDefaultHook(hook func(types.Context, string, types.Coin) (types.Coin, bool, error)) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// SupplyFromModule method of the parent MockLeverageKeeper instance invokes -// the hook at the front of the queue and discards it. After the queue is -// empty, the default hook function is invoked for any future action. -func (f *LeverageKeeperSupplyFromModuleFunc) PushHook(hook func(types.Context, string, types.Coin) (types.Coin, bool, error)) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *LeverageKeeperSupplyFromModuleFunc) SetDefaultReturn(r0 types.Coin, r1 bool, r2 error) { - f.SetDefaultHook(func(types.Context, string, types.Coin) (types.Coin, bool, error) { - return r0, r1, r2 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *LeverageKeeperSupplyFromModuleFunc) PushReturn(r0 types.Coin, r1 bool, r2 error) { - f.PushHook(func(types.Context, string, types.Coin) (types.Coin, bool, error) { - return r0, r1, r2 - }) -} - -func (f *LeverageKeeperSupplyFromModuleFunc) nextHook() func(types.Context, string, types.Coin) (types.Coin, bool, error) { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *LeverageKeeperSupplyFromModuleFunc) appendCall(r0 LeverageKeeperSupplyFromModuleFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of LeverageKeeperSupplyFromModuleFuncCall -// objects describing the invocations of this function. -func (f *LeverageKeeperSupplyFromModuleFunc) History() []LeverageKeeperSupplyFromModuleFuncCall { - f.mutex.Lock() - history := make([]LeverageKeeperSupplyFromModuleFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// LeverageKeeperSupplyFromModuleFuncCall is an object that describes an -// invocation of method SupplyFromModule on an instance of -// MockLeverageKeeper. -type LeverageKeeperSupplyFromModuleFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 types.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 types.Coin - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 types.Coin - // Result1 is the value of the 2nd result returned from this method - // invocation. - Result1 bool - // Result2 is the value of the 3rd result returned from this method - // invocation. - Result2 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c LeverageKeeperSupplyFromModuleFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c LeverageKeeperSupplyFromModuleFuncCall) Results() []interface{} { - return []interface{}{c.Result0, c.Result1, c.Result2} -} - -// LeverageKeeperToTokenFunc describes the behavior when the ToToken method -// of the parent MockLeverageKeeper instance is invoked. -type LeverageKeeperToTokenFunc struct { - defaultHook func(types.Context, types.Coin) (types.Coin, error) - hooks []func(types.Context, types.Coin) (types.Coin, error) - history []LeverageKeeperToTokenFuncCall - mutex sync.Mutex -} - -// ToToken delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockLeverageKeeper) ToToken(v0 types.Context, v1 types.Coin) (types.Coin, error) { - r0, r1 := m.ToTokenFunc.nextHook()(v0, v1) - m.ToTokenFunc.appendCall(LeverageKeeperToTokenFuncCall{v0, v1, r0, r1}) - return r0, r1 -} - -// SetDefaultHook sets function that is called when the ToToken method of -// the parent MockLeverageKeeper instance is invoked and the hook queue is -// empty. -func (f *LeverageKeeperToTokenFunc) SetDefaultHook(hook func(types.Context, types.Coin) (types.Coin, error)) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// ToToken method of the parent MockLeverageKeeper instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *LeverageKeeperToTokenFunc) PushHook(hook func(types.Context, types.Coin) (types.Coin, error)) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *LeverageKeeperToTokenFunc) SetDefaultReturn(r0 types.Coin, r1 error) { - f.SetDefaultHook(func(types.Context, types.Coin) (types.Coin, error) { - return r0, r1 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *LeverageKeeperToTokenFunc) PushReturn(r0 types.Coin, r1 error) { - f.PushHook(func(types.Context, types.Coin) (types.Coin, error) { - return r0, r1 - }) -} - -func (f *LeverageKeeperToTokenFunc) nextHook() func(types.Context, types.Coin) (types.Coin, error) { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *LeverageKeeperToTokenFunc) appendCall(r0 LeverageKeeperToTokenFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of LeverageKeeperToTokenFuncCall objects -// describing the invocations of this function. -func (f *LeverageKeeperToTokenFunc) History() []LeverageKeeperToTokenFuncCall { - f.mutex.Lock() - history := make([]LeverageKeeperToTokenFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// LeverageKeeperToTokenFuncCall is an object that describes an invocation -// of method ToToken on an instance of MockLeverageKeeper. -type LeverageKeeperToTokenFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 types.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 types.Coin - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 types.Coin - // Result1 is the value of the 2nd result returned from this method - // invocation. - Result1 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c LeverageKeeperToTokenFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c LeverageKeeperToTokenFuncCall) Results() []interface{} { - return []interface{}{c.Result0, c.Result1} -} - -// LeverageKeeperToUTokenFunc describes the behavior when the ToUToken -// method of the parent MockLeverageKeeper instance is invoked. -type LeverageKeeperToUTokenFunc struct { - defaultHook func(types.Context, types.Coin) (types.Coin, error) - hooks []func(types.Context, types.Coin) (types.Coin, error) - history []LeverageKeeperToUTokenFuncCall - mutex sync.Mutex -} - -// ToUToken delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockLeverageKeeper) ToUToken(v0 types.Context, v1 types.Coin) (types.Coin, error) { - r0, r1 := m.ToUTokenFunc.nextHook()(v0, v1) - m.ToUTokenFunc.appendCall(LeverageKeeperToUTokenFuncCall{v0, v1, r0, r1}) - return r0, r1 -} - -// SetDefaultHook sets function that is called when the ToUToken method of -// the parent MockLeverageKeeper instance is invoked and the hook queue is -// empty. -func (f *LeverageKeeperToUTokenFunc) SetDefaultHook(hook func(types.Context, types.Coin) (types.Coin, error)) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// ToUToken method of the parent MockLeverageKeeper instance invokes the -// hook at the front of the queue and discards it. After the queue is empty, -// the default hook function is invoked for any future action. -func (f *LeverageKeeperToUTokenFunc) PushHook(hook func(types.Context, types.Coin) (types.Coin, error)) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *LeverageKeeperToUTokenFunc) SetDefaultReturn(r0 types.Coin, r1 error) { - f.SetDefaultHook(func(types.Context, types.Coin) (types.Coin, error) { - return r0, r1 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *LeverageKeeperToUTokenFunc) PushReturn(r0 types.Coin, r1 error) { - f.PushHook(func(types.Context, types.Coin) (types.Coin, error) { - return r0, r1 - }) -} - -func (f *LeverageKeeperToUTokenFunc) nextHook() func(types.Context, types.Coin) (types.Coin, error) { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *LeverageKeeperToUTokenFunc) appendCall(r0 LeverageKeeperToUTokenFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of LeverageKeeperToUTokenFuncCall objects -// describing the invocations of this function. -func (f *LeverageKeeperToUTokenFunc) History() []LeverageKeeperToUTokenFuncCall { - f.mutex.Lock() - history := make([]LeverageKeeperToUTokenFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// LeverageKeeperToUTokenFuncCall is an object that describes an invocation -// of method ToUToken on an instance of MockLeverageKeeper. -type LeverageKeeperToUTokenFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 types.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 types.Coin - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 types.Coin - // Result1 is the value of the 2nd result returned from this method - // invocation. - Result1 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c LeverageKeeperToUTokenFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c LeverageKeeperToUTokenFuncCall) Results() []interface{} { - return []interface{}{c.Result0, c.Result1} -} - -// LeverageKeeperWithdrawToModuleFunc describes the behavior when the -// WithdrawToModule method of the parent MockLeverageKeeper instance is -// invoked. -type LeverageKeeperWithdrawToModuleFunc struct { - defaultHook func(types.Context, string, types.Coin) (types.Coin, bool, error) - hooks []func(types.Context, string, types.Coin) (types.Coin, bool, error) - history []LeverageKeeperWithdrawToModuleFuncCall - mutex sync.Mutex -} - -// WithdrawToModule delegates to the next hook function in the queue and -// stores the parameter and result values of this invocation. -func (m *MockLeverageKeeper) WithdrawToModule(v0 types.Context, v1 string, v2 types.Coin) (types.Coin, bool, error) { - r0, r1, r2 := m.WithdrawToModuleFunc.nextHook()(v0, v1, v2) - m.WithdrawToModuleFunc.appendCall(LeverageKeeperWithdrawToModuleFuncCall{v0, v1, v2, r0, r1, r2}) - return r0, r1, r2 -} - -// SetDefaultHook sets function that is called when the WithdrawToModule -// method of the parent MockLeverageKeeper instance is invoked and the hook -// queue is empty. -func (f *LeverageKeeperWithdrawToModuleFunc) SetDefaultHook(hook func(types.Context, string, types.Coin) (types.Coin, bool, error)) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// WithdrawToModule method of the parent MockLeverageKeeper instance invokes -// the hook at the front of the queue and discards it. After the queue is -// empty, the default hook function is invoked for any future action. -func (f *LeverageKeeperWithdrawToModuleFunc) PushHook(hook func(types.Context, string, types.Coin) (types.Coin, bool, error)) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *LeverageKeeperWithdrawToModuleFunc) SetDefaultReturn(r0 types.Coin, r1 bool, r2 error) { - f.SetDefaultHook(func(types.Context, string, types.Coin) (types.Coin, bool, error) { - return r0, r1, r2 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *LeverageKeeperWithdrawToModuleFunc) PushReturn(r0 types.Coin, r1 bool, r2 error) { - f.PushHook(func(types.Context, string, types.Coin) (types.Coin, bool, error) { - return r0, r1, r2 - }) -} - -func (f *LeverageKeeperWithdrawToModuleFunc) nextHook() func(types.Context, string, types.Coin) (types.Coin, bool, error) { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *LeverageKeeperWithdrawToModuleFunc) appendCall(r0 LeverageKeeperWithdrawToModuleFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of LeverageKeeperWithdrawToModuleFuncCall -// objects describing the invocations of this function. -func (f *LeverageKeeperWithdrawToModuleFunc) History() []LeverageKeeperWithdrawToModuleFuncCall { - f.mutex.Lock() - history := make([]LeverageKeeperWithdrawToModuleFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// LeverageKeeperWithdrawToModuleFuncCall is an object that describes an -// invocation of method WithdrawToModule on an instance of -// MockLeverageKeeper. -type LeverageKeeperWithdrawToModuleFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 types.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 types.Coin - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 types.Coin - // Result1 is the value of the 2nd result returned from this method - // invocation. - Result1 bool - // Result2 is the value of the 3rd result returned from this method - // invocation. - Result2 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c LeverageKeeperWithdrawToModuleFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c LeverageKeeperWithdrawToModuleFuncCall) Results() []interface{} { - return []interface{}{c.Result0, c.Result1, c.Result2} -} - -// MockOracleKeeper is a mock implementation of the OracleKeeper interface -// (from the package github.com/umee-network/umee/v6/x/metoken) used for -// unit testing. +// MockOracleKeeper is a mock of OracleKeeper interface. type MockOracleKeeper struct { - // AllMedianPricesFunc is an instance of a mock function object - // controlling the behavior of the method AllMedianPrices. - AllMedianPricesFunc *OracleKeeperAllMedianPricesFunc - // SetExchangeRateWithEventFunc is an instance of a mock function object - // controlling the behavior of the method SetExchangeRateWithEvent. - SetExchangeRateWithEventFunc *OracleKeeperSetExchangeRateWithEventFunc -} - -// NewMockOracleKeeper creates a new mock of the OracleKeeper interface. All -// methods return zero values for all results, unless overwritten. -func NewMockOracleKeeper() *MockOracleKeeper { - return &MockOracleKeeper{ - AllMedianPricesFunc: &OracleKeeperAllMedianPricesFunc{ - defaultHook: func(types.Context) (r0 types2.Prices) { - return - }, - }, - SetExchangeRateWithEventFunc: &OracleKeeperSetExchangeRateWithEventFunc{ - defaultHook: func(types.Context, string, math.LegacyDec) { - return - }, - }, - } -} - -// NewStrictMockOracleKeeper creates a new mock of the OracleKeeper -// interface. All methods panic on invocation, unless overwritten. -func NewStrictMockOracleKeeper() *MockOracleKeeper { - return &MockOracleKeeper{ - AllMedianPricesFunc: &OracleKeeperAllMedianPricesFunc{ - defaultHook: func(types.Context) types2.Prices { - panic("unexpected invocation of MockOracleKeeper.AllMedianPrices") - }, - }, - SetExchangeRateWithEventFunc: &OracleKeeperSetExchangeRateWithEventFunc{ - defaultHook: func(types.Context, string, math.LegacyDec) { - panic("unexpected invocation of MockOracleKeeper.SetExchangeRateWithEvent") - }, - }, - } -} - -// NewMockOracleKeeperFrom creates a new mock of the MockOracleKeeper -// interface. All methods delegate to the given implementation, unless -// overwritten. -func NewMockOracleKeeperFrom(i metoken.OracleKeeper) *MockOracleKeeper { - return &MockOracleKeeper{ - AllMedianPricesFunc: &OracleKeeperAllMedianPricesFunc{ - defaultHook: i.AllMedianPrices, - }, - SetExchangeRateWithEventFunc: &OracleKeeperSetExchangeRateWithEventFunc{ - defaultHook: i.SetExchangeRateWithEvent, - }, - } + ctrl *gomock.Controller + recorder *MockOracleKeeperMockRecorder } -// OracleKeeperAllMedianPricesFunc describes the behavior when the -// AllMedianPrices method of the parent MockOracleKeeper instance is -// invoked. -type OracleKeeperAllMedianPricesFunc struct { - defaultHook func(types.Context) types2.Prices - hooks []func(types.Context) types2.Prices - history []OracleKeeperAllMedianPricesFuncCall - mutex sync.Mutex +// MockOracleKeeperMockRecorder is the mock recorder for MockOracleKeeper. +type MockOracleKeeperMockRecorder struct { + mock *MockOracleKeeper } -// AllMedianPrices delegates to the next hook function in the queue and -// stores the parameter and result values of this invocation. -func (m *MockOracleKeeper) AllMedianPrices(v0 types.Context) types2.Prices { - r0 := m.AllMedianPricesFunc.nextHook()(v0) - m.AllMedianPricesFunc.appendCall(OracleKeeperAllMedianPricesFuncCall{v0, r0}) - return r0 +// NewMockOracleKeeper creates a new mock instance. +func NewMockOracleKeeper(ctrl *gomock.Controller) *MockOracleKeeper { + mock := &MockOracleKeeper{ctrl: ctrl} + mock.recorder = &MockOracleKeeperMockRecorder{mock} + return mock } -// SetDefaultHook sets function that is called when the AllMedianPrices -// method of the parent MockOracleKeeper instance is invoked and the hook -// queue is empty. -func (f *OracleKeeperAllMedianPricesFunc) SetDefaultHook(hook func(types.Context) types2.Prices) { - f.defaultHook = hook +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockOracleKeeper) EXPECT() *MockOracleKeeperMockRecorder { + return m.recorder } -// PushHook adds a function to the end of hook queue. Each invocation of the -// AllMedianPrices method of the parent MockOracleKeeper instance invokes -// the hook at the front of the queue and discards it. After the queue is -// empty, the default hook function is invoked for any future action. -func (f *OracleKeeperAllMedianPricesFunc) PushHook(hook func(types.Context) types2.Prices) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *OracleKeeperAllMedianPricesFunc) SetDefaultReturn(r0 types2.Prices) { - f.SetDefaultHook(func(types.Context) types2.Prices { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *OracleKeeperAllMedianPricesFunc) PushReturn(r0 types2.Prices) { - f.PushHook(func(types.Context) types2.Prices { - return r0 - }) -} - -func (f *OracleKeeperAllMedianPricesFunc) nextHook() func(types.Context) types2.Prices { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *OracleKeeperAllMedianPricesFunc) appendCall(r0 OracleKeeperAllMedianPricesFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of OracleKeeperAllMedianPricesFuncCall objects -// describing the invocations of this function. -func (f *OracleKeeperAllMedianPricesFunc) History() []OracleKeeperAllMedianPricesFuncCall { - f.mutex.Lock() - history := make([]OracleKeeperAllMedianPricesFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// OracleKeeperAllMedianPricesFuncCall is an object that describes an -// invocation of method AllMedianPrices on an instance of MockOracleKeeper. -type OracleKeeperAllMedianPricesFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 types.Context - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 types2.Prices -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c OracleKeeperAllMedianPricesFuncCall) Args() []interface{} { - return []interface{}{c.Arg0} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c OracleKeeperAllMedianPricesFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// OracleKeeperSetExchangeRateWithEventFunc describes the behavior when the -// SetExchangeRateWithEvent method of the parent MockOracleKeeper instance -// is invoked. -type OracleKeeperSetExchangeRateWithEventFunc struct { - defaultHook func(types.Context, string, math.LegacyDec) - hooks []func(types.Context, string, math.LegacyDec) - history []OracleKeeperSetExchangeRateWithEventFuncCall - mutex sync.Mutex -} - -// SetExchangeRateWithEvent delegates to the next hook function in the queue -// and stores the parameter and result values of this invocation. -func (m *MockOracleKeeper) SetExchangeRateWithEvent(v0 types.Context, v1 string, v2 math.LegacyDec) { - m.SetExchangeRateWithEventFunc.nextHook()(v0, v1, v2) - m.SetExchangeRateWithEventFunc.appendCall(OracleKeeperSetExchangeRateWithEventFuncCall{v0, v1, v2}) - return -} - -// SetDefaultHook sets function that is called when the -// SetExchangeRateWithEvent method of the parent MockOracleKeeper instance -// is invoked and the hook queue is empty. -func (f *OracleKeeperSetExchangeRateWithEventFunc) SetDefaultHook(hook func(types.Context, string, math.LegacyDec)) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// SetExchangeRateWithEvent method of the parent MockOracleKeeper instance -// invokes the hook at the front of the queue and discards it. After the -// queue is empty, the default hook function is invoked for any future -// action. -func (f *OracleKeeperSetExchangeRateWithEventFunc) PushHook(hook func(types.Context, string, math.LegacyDec)) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *OracleKeeperSetExchangeRateWithEventFunc) SetDefaultReturn() { - f.SetDefaultHook(func(types.Context, string, math.LegacyDec) { - return - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *OracleKeeperSetExchangeRateWithEventFunc) PushReturn() { - f.PushHook(func(types.Context, string, math.LegacyDec) { - return - }) -} - -func (f *OracleKeeperSetExchangeRateWithEventFunc) nextHook() func(types.Context, string, math.LegacyDec) { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *OracleKeeperSetExchangeRateWithEventFunc) appendCall(r0 OracleKeeperSetExchangeRateWithEventFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of -// OracleKeeperSetExchangeRateWithEventFuncCall objects describing the -// invocations of this function. -func (f *OracleKeeperSetExchangeRateWithEventFunc) History() []OracleKeeperSetExchangeRateWithEventFuncCall { - f.mutex.Lock() - history := make([]OracleKeeperSetExchangeRateWithEventFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history +// AllMedianPrices mocks base method. +func (m *MockOracleKeeper) AllMedianPrices(ctx types.Context) types1.Prices { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AllMedianPrices", ctx) + ret0, _ := ret[0].(types1.Prices) + return ret0 } -// OracleKeeperSetExchangeRateWithEventFuncCall is an object that describes -// an invocation of method SetExchangeRateWithEvent on an instance of -// MockOracleKeeper. -type OracleKeeperSetExchangeRateWithEventFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 types.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 math.LegacyDec +// AllMedianPrices indicates an expected call of AllMedianPrices. +func (mr *MockOracleKeeperMockRecorder) AllMedianPrices(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AllMedianPrices", reflect.TypeOf((*MockOracleKeeper)(nil).AllMedianPrices), ctx) } -// Args returns an interface slice containing the arguments of this -// invocation. -func (c OracleKeeperSetExchangeRateWithEventFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} +// SetExchangeRateWithEvent mocks base method. +func (m *MockOracleKeeper) SetExchangeRateWithEvent(ctx types.Context, denom string, rate types.Dec) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetExchangeRateWithEvent", ctx, denom, rate) } -// Results returns an interface slice containing the results of this -// invocation. -func (c OracleKeeperSetExchangeRateWithEventFuncCall) Results() []interface{} { - return []interface{}{} +// SetExchangeRateWithEvent indicates an expected call of SetExchangeRateWithEvent. +func (mr *MockOracleKeeperMockRecorder) SetExchangeRateWithEvent(ctx, denom, rate interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetExchangeRateWithEvent", reflect.TypeOf((*MockOracleKeeper)(nil).SetExchangeRateWithEvent), ctx, denom, rate) } From d3bc89a5742b0d4ab29b80f85f488e8b51eeda4d Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Tue, 7 Nov 2023 15:40:06 -0300 Subject: [PATCH 03/18] e2e test added --- tests/e2e/e2e_metoken_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/e2e/e2e_metoken_test.go b/tests/e2e/e2e_metoken_test.go index 7835612de0..d2b64c7a44 100644 --- a/tests/e2e/e2e_metoken_test.go +++ b/tests/e2e/e2e_metoken_test.go @@ -113,6 +113,22 @@ func (s *E2ETest) TestMetokenSwapAndRedeem() { s.checkMetokenBalance(testAddr.String(), mocks.MeUSDDenom) }, ) + + // After adding an index to x/metoken registry the price is informed to x/oracle every endBlock (~12s) + s.Require().Eventually( + func() bool { + exchangeRates, err := s.QueryExchangeRate(s.UmeeREST(), mocks.MeUSDDenom) + if err != nil { + return false + } + + if exchangeRates.AmountOf(mocks.MeUSDDenom).IsZero() { + return false + } + return true + }, + 2*time.Minute, time.Second, "ensure me/USD has prices", + ) } func (s *E2ETest) checkMetokenBalance(valAddr, denom string) { From de39df2810ccf321d0b465c89a62af5bdd067d55 Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Tue, 7 Nov 2023 15:41:02 -0300 Subject: [PATCH 04/18] e2e frequency changed --- tests/e2e/e2e_metoken_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/e2e_metoken_test.go b/tests/e2e/e2e_metoken_test.go index d2b64c7a44..6e73840521 100644 --- a/tests/e2e/e2e_metoken_test.go +++ b/tests/e2e/e2e_metoken_test.go @@ -127,7 +127,7 @@ func (s *E2ETest) TestMetokenSwapAndRedeem() { } return true }, - 2*time.Minute, time.Second, "ensure me/USD has prices", + 2*time.Minute, 12*time.Second, "ensure me/USD has prices", ) } From 225b434926a7b98e236d4515930be06a626a5560 Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Tue, 7 Nov 2023 16:57:46 -0300 Subject: [PATCH 05/18] remove e2e test --- tests/e2e/e2e_metoken_test.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/tests/e2e/e2e_metoken_test.go b/tests/e2e/e2e_metoken_test.go index 6e73840521..7835612de0 100644 --- a/tests/e2e/e2e_metoken_test.go +++ b/tests/e2e/e2e_metoken_test.go @@ -113,22 +113,6 @@ func (s *E2ETest) TestMetokenSwapAndRedeem() { s.checkMetokenBalance(testAddr.String(), mocks.MeUSDDenom) }, ) - - // After adding an index to x/metoken registry the price is informed to x/oracle every endBlock (~12s) - s.Require().Eventually( - func() bool { - exchangeRates, err := s.QueryExchangeRate(s.UmeeREST(), mocks.MeUSDDenom) - if err != nil { - return false - } - - if exchangeRates.AmountOf(mocks.MeUSDDenom).IsZero() { - return false - } - return true - }, - 2*time.Minute, 12*time.Second, "ensure me/USD has prices", - ) } func (s *E2ETest) checkMetokenBalance(valAddr, denom string) { From 65cdfad94128475c6b7451ca7753147055a65f8f Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Tue, 7 Nov 2023 17:25:15 -0300 Subject: [PATCH 06/18] adding symbol denom --- x/metoken/keeper/price.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/x/metoken/keeper/price.go b/x/metoken/keeper/price.go index 5e29891a4e..13ff2504ba 100644 --- a/x/metoken/keeper/price.go +++ b/x/metoken/keeper/price.go @@ -111,7 +111,18 @@ func (k Keeper) SetPricesToOracle() error { continue } - k.oracleKeeper.SetExchangeRateWithEvent(*k.ctx, index.Denom, iPrice.Price) + indexToken, err := k.leverageKeeper.GetTokenSettings(*k.ctx, index.Denom) + if err != nil { + k.Logger().Debug( + "setting price to oracle: couldn't get token settings", + "denom", index.Denom, + "error", err.Error(), + "block_time", k.ctx.BlockTime(), + ) + continue + } + + k.oracleKeeper.SetExchangeRateWithEvent(*k.ctx, indexToken.SymbolDenom, iPrice.Price) } return nil From 633a6ec758d5706dbea73be75f3f1f52a4ce8953 Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Mon, 13 Nov 2023 11:53:24 -0300 Subject: [PATCH 07/18] e2e test added --- tests/e2e/e2e_metoken_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/e2e/e2e_metoken_test.go b/tests/e2e/e2e_metoken_test.go index 7835612de0..c651901dab 100644 --- a/tests/e2e/e2e_metoken_test.go +++ b/tests/e2e/e2e_metoken_test.go @@ -113,6 +113,34 @@ func (s *E2ETest) TestMetokenSwapAndRedeem() { s.checkMetokenBalance(testAddr.String(), mocks.MeUSDDenom) }, ) + + s.Run( + "add_metoken_to_leverage", func() { + tokens := []ltypes.Token{ + mocks.ValidToken(mocks.MeUSDDenom, mocks.MeUSDDenom, 6), + } + + err := grpc.LeverageRegistryUpdate(s.AccountClient(0), tokens, nil) + s.Require().NoError(err) + s.checkMetokenPriceInOracle(mocks.MeUSDDenom) + }, + ) +} + +func (s *E2ETest) checkMetokenPriceInOracle(denom string) { + s.Require().Eventually( + func() bool { + exchangeRates, err := s.QueryExchangeRate(s.UmeeREST(), denom) + if err != nil { + return false + } + if exchangeRates.AmountOf(denom).IsZero() { + return false + } + return true + }, + 2*time.Minute, 12*time.Second, "fetching metoken price", + ) } func (s *E2ETest) checkMetokenBalance(valAddr, denom string) { From 6c2b42ef9bbcbfe3023b763704ce306ebfe7edbe Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Mon, 13 Nov 2023 11:56:33 -0300 Subject: [PATCH 08/18] rollback mock script --- contrib/scripts/mockgen.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/scripts/mockgen.sh b/contrib/scripts/mockgen.sh index b48a212a03..224afa112d 100644 --- a/contrib/scripts/mockgen.sh +++ b/contrib/scripts/mockgen.sh @@ -2,7 +2,7 @@ mockgen_cmd="go run github.com/golang/mock/mockgen" -$mockgen_cmd -source ./../../x/ugov/keeper_interfaces.go -package mocks -destination ./../..//x/ugov/mocks/keepers.go -$mockgen_cmd -source ./../../x/uibc/expected_keepers.go -package mocks -destination ./../..//x/uibc/mocks/keepers.go -$mockgen_cmd -source ./../../x/metoken/expected_keepers.go -package mocks -destination ./../../x/metoken/mocks/keepers.go -$mockgen_cmd -source ./../../app/inflation/expected_keepers.go -package mocks -destination ./../..//app/inflation/mocks/keepers.go +$mockgen_cmd -source ./x/ugov/keeper_interfaces.go -package mocks -destination ./x/ugov/mocks/keepers.go +$mockgen_cmd -source ./x/uibc/expected_keepers.go -package mocks -destination ./x/uibc/mocks/keepers.go +$mockgen_cmd -source ./x/metoken/expected_keepers.go -package mocks -destination ./x/metoken/mocks/keepers.go +$mockgen_cmd -source ./app/inflation/expected_keepers.go -package mocks -destination ./app/inflation/mocks/keepers.go From bdc778ba9ac674e4ccf654060d0e4043a7cf68ea Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Mon, 13 Nov 2023 12:48:04 -0300 Subject: [PATCH 09/18] fix e2e test --- tests/e2e/e2e_metoken_test.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/e2e/e2e_metoken_test.go b/tests/e2e/e2e_metoken_test.go index c651901dab..57a36d1117 100644 --- a/tests/e2e/e2e_metoken_test.go +++ b/tests/e2e/e2e_metoken_test.go @@ -25,6 +25,7 @@ func (s *E2ETest) TestMetokenSwapAndRedeem() { mocks.ValidToken(mocks.USDTBaseDenom, mocks.USDTSymbolDenom, 6), mocks.ValidToken(mocks.USDCBaseDenom, mocks.USDCSymbolDenom, 6), mocks.ValidToken(mocks.ISTBaseDenom, mocks.ISTSymbolDenom, 6), + mocks.ValidToken(mocks.MeUSDDenom, mocks.MeUSDDenom, 6), } err := grpc.LeverageRegistryUpdate(s.AccountClient(0), tokens, nil) @@ -115,13 +116,7 @@ func (s *E2ETest) TestMetokenSwapAndRedeem() { ) s.Run( - "add_metoken_to_leverage", func() { - tokens := []ltypes.Token{ - mocks.ValidToken(mocks.MeUSDDenom, mocks.MeUSDDenom, 6), - } - - err := grpc.LeverageRegistryUpdate(s.AccountClient(0), tokens, nil) - s.Require().NoError(err) + "metoken_price_on_oracle", func() { s.checkMetokenPriceInOracle(mocks.MeUSDDenom) }, ) From 694125e8baaac01a4fa0ee229e5e805a7e31818d Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Mon, 13 Nov 2023 13:02:33 -0300 Subject: [PATCH 10/18] lint --- x/metoken/keeper/mocks_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/x/metoken/keeper/mocks_test.go b/x/metoken/keeper/mocks_test.go index 89703f86b3..bfd4fe63f8 100644 --- a/x/metoken/keeper/mocks_test.go +++ b/x/metoken/keeper/mocks_test.go @@ -19,7 +19,6 @@ func (o Oracle) AllMedianPrices(_ sdk.Context) otypes.Prices { } func (o Oracle) SetExchangeRateWithEvent(_ sdk.Context, _ string, _ sdk.Dec) { - return } func NewOracleMock() Oracle { From 8c3e9cf91d824162dc376af1b7dc2cccfed6a607 Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Mon, 13 Nov 2023 16:56:30 -0300 Subject: [PATCH 11/18] pr comments --- x/metoken/keeper/mocks_test.go | 11 ++++++++++- x/metoken/keeper/price.go | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/x/metoken/keeper/mocks_test.go b/x/metoken/keeper/mocks_test.go index bfd4fe63f8..32f3f90e69 100644 --- a/x/metoken/keeper/mocks_test.go +++ b/x/metoken/keeper/mocks_test.go @@ -18,7 +18,16 @@ func (o Oracle) AllMedianPrices(_ sdk.Context) otypes.Prices { return o.prices } -func (o Oracle) SetExchangeRateWithEvent(_ sdk.Context, _ string, _ sdk.Dec) { +func (o Oracle) SetExchangeRateWithEvent(_ sdk.Context, denom string, rate sdk.Dec) { + o.prices = append( + o.prices, otypes.Price{ + ExchangeRateTuple: otypes.NewExchangeRateTuple( + denom, + rate, + ), + BlockNum: uint64(1), + }, + ) } func NewOracleMock() Oracle { diff --git a/x/metoken/keeper/price.go b/x/metoken/keeper/price.go index 13ff2504ba..c0146d0024 100644 --- a/x/metoken/keeper/price.go +++ b/x/metoken/keeper/price.go @@ -102,7 +102,7 @@ func (k Keeper) SetPricesToOracle() error { for _, index := range indexes { iPrice, err := k.Prices(index) if err != nil { - k.Logger().Debug( + k.Logger().Error( "setting price to oracle: couldn't calculate the price", "denom", index.Denom, "error", err.Error(), @@ -113,7 +113,7 @@ func (k Keeper) SetPricesToOracle() error { indexToken, err := k.leverageKeeper.GetTokenSettings(*k.ctx, index.Denom) if err != nil { - k.Logger().Debug( + k.Logger().Error( "setting price to oracle: couldn't get token settings", "denom", index.Denom, "error", err.Error(), From afdfcaf8f90d3410d79f511a76bfe6431c4507df Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Mon, 13 Nov 2023 19:03:06 -0300 Subject: [PATCH 12/18] intest --- tests/e2e/e2e_metoken_test.go | 7 ------ x/metoken/keeper/intest/keeper_test.go | 7 ++++++ x/metoken/keeper/intest/price_test.go | 30 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 x/metoken/keeper/intest/price_test.go diff --git a/tests/e2e/e2e_metoken_test.go b/tests/e2e/e2e_metoken_test.go index 57a36d1117..6e43a5cf33 100644 --- a/tests/e2e/e2e_metoken_test.go +++ b/tests/e2e/e2e_metoken_test.go @@ -25,7 +25,6 @@ func (s *E2ETest) TestMetokenSwapAndRedeem() { mocks.ValidToken(mocks.USDTBaseDenom, mocks.USDTSymbolDenom, 6), mocks.ValidToken(mocks.USDCBaseDenom, mocks.USDCSymbolDenom, 6), mocks.ValidToken(mocks.ISTBaseDenom, mocks.ISTSymbolDenom, 6), - mocks.ValidToken(mocks.MeUSDDenom, mocks.MeUSDDenom, 6), } err := grpc.LeverageRegistryUpdate(s.AccountClient(0), tokens, nil) @@ -114,12 +113,6 @@ func (s *E2ETest) TestMetokenSwapAndRedeem() { s.checkMetokenBalance(testAddr.String(), mocks.MeUSDDenom) }, ) - - s.Run( - "metoken_price_on_oracle", func() { - s.checkMetokenPriceInOracle(mocks.MeUSDDenom) - }, - ) } func (s *E2ETest) checkMetokenPriceInOracle(denom string) { diff --git a/x/metoken/keeper/intest/keeper_test.go b/x/metoken/keeper/intest/keeper_test.go index 7096180e60..b5d1a9b2f9 100644 --- a/x/metoken/keeper/intest/keeper_test.go +++ b/x/metoken/keeper/intest/keeper_test.go @@ -52,6 +52,7 @@ func initTestSuite(t *testing.T, registry []metoken.Index, balances []metoken.In AllMedianPrices(gomock.Any()). Return(mocks.ValidPrices()). AnyTimes() + oracleMock.EXPECT().SetExchangeRateWithEvent(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() kb := keeper.NewKeeperBuilder( app.AppCodec(), @@ -108,6 +109,12 @@ func initTestSuite(t *testing.T, registry []metoken.Index, balances []metoken.In mocks.ValidToken(mocks.ETHBaseDenom, mocks.ETHSymbolDenom, 18), ), ) + require.NoError( + app.LeverageKeeper.SetTokenSettings( + ctx, + mocks.ValidToken(mocks.MeUSDDenom, mocks.MeUSDDenom, 6), + ), + ) return &KeeperTestSuite{ ctx: ctx, diff --git a/x/metoken/keeper/intest/price_test.go b/x/metoken/keeper/intest/price_test.go new file mode 100644 index 0000000000..3a6df76d45 --- /dev/null +++ b/x/metoken/keeper/intest/price_test.go @@ -0,0 +1,30 @@ +package intest + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/umee-network/umee/v6/util/checkers" + "github.com/umee-network/umee/v6/x/metoken" + "github.com/umee-network/umee/v6/x/metoken/mocks" +) + +func TestPrice_SetPricesToOracle(t *testing.T) { + index := mocks.StableIndex(mocks.MeUSDDenom) + + s := initTestSuite(t, nil, nil) + msgServer, ctx, app := s.msgServer, s.ctx, s.app + + _, err := msgServer.GovUpdateRegistry( + ctx, &metoken.MsgGovUpdateRegistry{ + Authority: checkers.GovModuleAddr, + AddIndex: []metoken.Index{index}, + UpdateIndex: nil, + }, + ) + require := require.New(t) + require.NoError(err) + + err = app.MetokenKeeperB.Keeper(&ctx).SetPricesToOracle() + require.NoError(err) +} From 6af1f3131668fcc9da73ffffb5c6bc79418dd6e2 Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Tue, 14 Nov 2023 10:18:49 -0300 Subject: [PATCH 13/18] fix test --- x/metoken/keeper/mocks_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/metoken/keeper/mocks_test.go b/x/metoken/keeper/mocks_test.go index 32f3f90e69..90341e0571 100644 --- a/x/metoken/keeper/mocks_test.go +++ b/x/metoken/keeper/mocks_test.go @@ -18,7 +18,7 @@ func (o Oracle) AllMedianPrices(_ sdk.Context) otypes.Prices { return o.prices } -func (o Oracle) SetExchangeRateWithEvent(_ sdk.Context, denom string, rate sdk.Dec) { +func (o *Oracle) SetExchangeRateWithEvent(_ sdk.Context, denom string, rate sdk.Dec) { o.prices = append( o.prices, otypes.Price{ ExchangeRateTuple: otypes.NewExchangeRateTuple( From 2dc6d34519749ae5e314de140f7be43761d9f42c Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Tue, 14 Nov 2023 10:19:52 -0300 Subject: [PATCH 14/18] fix test --- x/metoken/keeper/mocks_test.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/x/metoken/keeper/mocks_test.go b/x/metoken/keeper/mocks_test.go index 90341e0571..bfd4fe63f8 100644 --- a/x/metoken/keeper/mocks_test.go +++ b/x/metoken/keeper/mocks_test.go @@ -18,16 +18,7 @@ func (o Oracle) AllMedianPrices(_ sdk.Context) otypes.Prices { return o.prices } -func (o *Oracle) SetExchangeRateWithEvent(_ sdk.Context, denom string, rate sdk.Dec) { - o.prices = append( - o.prices, otypes.Price{ - ExchangeRateTuple: otypes.NewExchangeRateTuple( - denom, - rate, - ), - BlockNum: uint64(1), - }, - ) +func (o Oracle) SetExchangeRateWithEvent(_ sdk.Context, _ string, _ sdk.Dec) { } func NewOracleMock() Oracle { From fce3cb24d7687bee2717294e36ed3950e549023e Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Tue, 14 Nov 2023 10:28:09 -0300 Subject: [PATCH 15/18] fix --- x/metoken/expected_keepers.go | 2 +- x/metoken/keeper/price.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x/metoken/expected_keepers.go b/x/metoken/expected_keepers.go index 5c021ece9d..0fbe27a669 100644 --- a/x/metoken/expected_keepers.go +++ b/x/metoken/expected_keepers.go @@ -34,5 +34,5 @@ type LeverageKeeper interface { // OracleKeeper interface for price feed. type OracleKeeper interface { AllMedianPrices(ctx sdk.Context) otypes.Prices - SetExchangeRateWithEvent(ctx sdk.Context, denom string, rate sdk.Dec) + SetExchangeRate(ctx sdk.Context, denom string, rate sdk.Dec) } diff --git a/x/metoken/keeper/price.go b/x/metoken/keeper/price.go index c0146d0024..16d2c6ca54 100644 --- a/x/metoken/keeper/price.go +++ b/x/metoken/keeper/price.go @@ -122,7 +122,7 @@ func (k Keeper) SetPricesToOracle() error { continue } - k.oracleKeeper.SetExchangeRateWithEvent(*k.ctx, indexToken.SymbolDenom, iPrice.Price) + k.oracleKeeper.SetExchangeRate(*k.ctx, indexToken.SymbolDenom, iPrice.Price) } return nil From ae2fcc2747c67640c356f68994321eddcbed8037 Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Tue, 14 Nov 2023 10:51:59 -0300 Subject: [PATCH 16/18] fix test --- x/metoken/keeper/mocks_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/metoken/keeper/mocks_test.go b/x/metoken/keeper/mocks_test.go index bfd4fe63f8..a99f520f48 100644 --- a/x/metoken/keeper/mocks_test.go +++ b/x/metoken/keeper/mocks_test.go @@ -18,7 +18,7 @@ func (o Oracle) AllMedianPrices(_ sdk.Context) otypes.Prices { return o.prices } -func (o Oracle) SetExchangeRateWithEvent(_ sdk.Context, _ string, _ sdk.Dec) { +func (o Oracle) SetExchangeRate(_ sdk.Context, _ string, _ sdk.Dec) { } func NewOracleMock() Oracle { From 48ea310e574ef893610e498ae3956d8f5eb675cb Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Tue, 14 Nov 2023 11:12:51 -0300 Subject: [PATCH 17/18] fix test2 --- x/metoken/mocks/keepers.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/x/metoken/mocks/keepers.go b/x/metoken/mocks/keepers.go index 89d12951af..fa015700f6 100644 --- a/x/metoken/mocks/keepers.go +++ b/x/metoken/mocks/keepers.go @@ -275,14 +275,14 @@ func (mr *MockOracleKeeperMockRecorder) AllMedianPrices(ctx interface{}) *gomock return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AllMedianPrices", reflect.TypeOf((*MockOracleKeeper)(nil).AllMedianPrices), ctx) } -// SetExchangeRateWithEvent mocks base method. -func (m *MockOracleKeeper) SetExchangeRateWithEvent(ctx types.Context, denom string, rate types.Dec) { +// SetExchangeRate mocks base method. +func (m *MockOracleKeeper) SetExchangeRate(ctx types.Context, denom string, rate types.Dec) { m.ctrl.T.Helper() - m.ctrl.Call(m, "SetExchangeRateWithEvent", ctx, denom, rate) + m.ctrl.Call(m, "SetExchangeRate", ctx, denom, rate) } -// SetExchangeRateWithEvent indicates an expected call of SetExchangeRateWithEvent. -func (mr *MockOracleKeeperMockRecorder) SetExchangeRateWithEvent(ctx, denom, rate interface{}) *gomock.Call { +// SetExchangeRate indicates an expected call of SetExchangeRate. +func (mr *MockOracleKeeperMockRecorder) SetExchangeRate(ctx, denom, rate interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetExchangeRateWithEvent", reflect.TypeOf((*MockOracleKeeper)(nil).SetExchangeRateWithEvent), ctx, denom, rate) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetExchangeRate", reflect.TypeOf((*MockOracleKeeper)(nil).SetExchangeRate), ctx, denom, rate) } From 336d25b6305cbac9f6262c9f4853e90d75277130 Mon Sep 17 00:00:00 2001 From: Egor Kostetskiy Date: Tue, 14 Nov 2023 11:18:19 -0300 Subject: [PATCH 18/18] fix test3 --- x/metoken/keeper/intest/keeper_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/metoken/keeper/intest/keeper_test.go b/x/metoken/keeper/intest/keeper_test.go index b5d1a9b2f9..d6cf7e5610 100644 --- a/x/metoken/keeper/intest/keeper_test.go +++ b/x/metoken/keeper/intest/keeper_test.go @@ -52,7 +52,7 @@ func initTestSuite(t *testing.T, registry []metoken.Index, balances []metoken.In AllMedianPrices(gomock.Any()). Return(mocks.ValidPrices()). AnyTimes() - oracleMock.EXPECT().SetExchangeRateWithEvent(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() + oracleMock.EXPECT().SetExchangeRate(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() kb := keeper.NewKeeperBuilder( app.AppCodec(),