Skip to content

Commit

Permalink
test UpdateParams
Browse files Browse the repository at this point in the history
  • Loading branch information
DongLieu committed Dec 9, 2024
1 parent eedee12 commit 8b0d155
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
5 changes: 4 additions & 1 deletion x/oracle/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import (

apptesting "github.com/onomyprotocol/reserve/app/apptesting"
"github.com/onomyprotocol/reserve/x/oracle/keeper"
"github.com/onomyprotocol/reserve/x/oracle/types"
testifysuite "github.com/stretchr/testify/suite"
)

type KeeperTestSuite struct {
apptesting.KeeperTestHelper
k keeper.Keeper
k keeper.Keeper
msgServer types.MsgServer
}

func TestKeeperTestSuite(t *testing.T) {
Expand All @@ -20,4 +22,5 @@ func TestKeeperTestSuite(t *testing.T) {
func (s *KeeperTestSuite) SetupTest() {
s.Setup()
s.k = s.App.OracleKeeper
s.msgServer = keeper.NewMsgServerImpl(s.k)
}
47 changes: 25 additions & 22 deletions x/oracle/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
package keeper_test

// import (
// "context"
// "testing"

// "github.com/stretchr/testify/require"

// keepertest "github.com/onomyprotocol/reserve/testutil/keeper"
// "github.com/onomyprotocol/reserve/x/oracle/keeper"
// "github.com/onomyprotocol/reserve/x/oracle/types"
// )

// func setupMsgServer(t testing.TB) (keeper.Keeper, types.MsgServer, context.Context) {
// k, ctx := keepertest.OracleKeeper(t)
// return k, keeper.NewMsgServerImpl(k), ctx
// }

// func TestMsgServer(t *testing.T) {
// k, ms, ctx := setupMsgServer(t)
// require.NotNil(t, ms)
// require.NotNil(t, ctx)
// require.NotEmpty(t, k)
// }
import (
"time"

"github.com/onomyprotocol/reserve/x/oracle/types"
)

func (s *KeeperTestSuite) TestUpdateParams() {
s.SetupTest()

paramDefault := s.k.GetParams(s.Ctx)
s.Require().Equal(paramDefault.AllowedPriceDelay, types.DefauAllowedPriceDelay)

allowedPriceDelayUpdate := time.Hour * 10

msgUpdateParams := types.MsgUpdateParams{
Authority: s.k.GetAuthority(),
Params: types.NewParams(allowedPriceDelayUpdate),
}

_, err := s.msgServer.UpdateParams(s.Ctx, &msgUpdateParams)
s.Require().NoError(err)

paramsNew := s.k.GetParams(s.Ctx)
s.Require().Equal(paramsNew.AllowedPriceDelay, allowedPriceDelayUpdate)
}

0 comments on commit 8b0d155

Please sign in to comment.