Skip to content

Commit

Permalink
intest
Browse files Browse the repository at this point in the history
  • Loading branch information
kosegor committed Nov 13, 2023
1 parent 8c3e9cf commit afdfcaf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
7 changes: 0 additions & 7 deletions tests/e2e/e2e_metoken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions x/metoken/keeper/intest/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down
30 changes: 30 additions & 0 deletions x/metoken/keeper/intest/price_test.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit afdfcaf

Please sign in to comment.