Skip to content

Commit

Permalink
update service module
Browse files Browse the repository at this point in the history
  • Loading branch information
avery committed Nov 13, 2024
1 parent 77215d5 commit 8b34544
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
2 changes: 0 additions & 2 deletions modules/service/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module mods.irisnet.org/modules/service

go 1.21

toolchain go1.23.1

require (
cosmossdk.io/api v0.7.5
cosmossdk.io/core v0.11.1
Expand Down
6 changes: 2 additions & 4 deletions modules/service/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

"mods.irisnet.org/modules/service/types"
)

Expand Down Expand Up @@ -67,11 +65,11 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
}

// GetServiceDepositAccount returns the service depost ModuleAccount
func (k Keeper) GetServiceDepositAccount(ctx sdk.Context) authtypes.ModuleAccountI {
func (k Keeper) GetServiceDepositAccount(ctx sdk.Context) sdk.ModuleAccountI {
return k.accountKeeper.GetModuleAccount(ctx, types.DepositAccName)
}

// GetServiceRequestAccount returns the service request ModuleAccount
func (k Keeper) GetServiceRequestAccount(ctx sdk.Context) authtypes.ModuleAccountI {
func (k Keeper) GetServiceRequestAccount(ctx sdk.Context) sdk.ModuleAccountI {
return k.accountKeeper.GetModuleAccount(ctx, types.RequestAccName)
}
1 change: 1 addition & 0 deletions modules/service/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ func (suite *KeeperTestSuite) TestRegisterCallback() {

func (suite *KeeperTestSuite) TestKeeperRequestContext() {
consumer := testConsumer

providers := []sdk.AccAddress{testProvider}

suite.setServiceDefinition()
Expand Down
2 changes: 1 addition & 1 deletion modules/service/simulation/operations.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package simulation

import (
"cosmossdk.io/math"
"errors"
"fmt"
"math/rand"

"cosmossdk.io/math"
tmbytes "github.com/cometbft/cometbft/libs/bytes"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
Expand Down
25 changes: 14 additions & 11 deletions modules/service/types/expected_keeper.go
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
package types

import (
"context"

"cosmossdk.io/core/address"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

// BankKeeper defines the expected bank keeper (noalias)
type BankKeeper interface {
MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
MintCoins(ctx context.Context, moduleName string, amt sdk.Coins) error
BurnCoins(ctx context.Context, moduleName string, amt sdk.Coins) error

GetSupply(ctx sdk.Context, denom string) sdk.Coin
GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
GetSupply(ctx context.Context, denom string) sdk.Coin
GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin

SendCoinsFromModuleToAccount(
ctx sdk.Context,
ctx context.Context,
senderModule string,
recipientAddr sdk.AccAddress,
amt sdk.Coins,
) error
SendCoinsFromAccountToModule(
ctx sdk.Context,
ctx context.Context,
senderAddr sdk.AccAddress,
recipientModule string,
amt sdk.Coins,
) error
SendCoinsFromModuleToModule(
ctx sdk.Context,
ctx context.Context,
senderModule, recipientModule string,
amt sdk.Coins,
) error

SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins
GetBlockedAddresses() map[string]bool
}

// AccountKeeper defines the expected account keeper (noalias)
type AccountKeeper interface {
GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
GetModuleAddress(name string) sdk.AccAddress
GetModuleAccount(ctx sdk.Context, name string) authtypes.ModuleAccountI
GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI
AddressCodec() address.Codec
}
11 changes: 6 additions & 5 deletions modules/service/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"
"testing"

"cosmossdk.io/math"
"github.com/cometbft/cometbft/crypto/tmhash"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
Expand All @@ -13,8 +14,8 @@ import (
var (
emptyAddress = ""

testCoin1 = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000))
testCoin2 = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))
testCoin1 = sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10000))
testCoin2 = sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))

testServiceName = "test-service"
testServiceDesc = "test-service-desc"
Expand Down Expand Up @@ -296,7 +297,7 @@ func TestMsgBindServiceType(t *testing.T) {
// TestMsgBindServiceValidation tests ValidateBasic for MsgBindService
func TestMsgBindServiceValidation(t *testing.T) {
invalidLongName := strings.Repeat("s", MaxNameLength+1)
invalidDeposit := sdk.Coins{sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-1)}}
invalidDeposit := sdk.Coins{sdk.Coin{Denom: "stake", Amount: math.NewInt(-1)}}
invalidQoS := uint64(0)

invalidPricing := `{"price":"1stake","other":"notallowedfield"}`
Expand Down Expand Up @@ -1084,7 +1085,7 @@ func TestMsgCallServiceType(t *testing.T) {
// TestMsgCallServiceValidation tests ValidateBasic for MsgCallService
func TestMsgCallServiceValidation(t *testing.T) {
invalidLongName := strings.Repeat("s", MaxNameLength+1)
invalidDenomCoins := sdk.Coins{sdk.Coin{Denom: "eth+min", Amount: sdk.NewInt(1000)}}
invalidDenomCoins := sdk.Coins{sdk.Coin{Denom: "eth+min", Amount: math.NewInt(1000)}}

invalidDuplicateProviders := []string{testProvider, testProvider}
invalidInput := "iris-usdt"
Expand Down Expand Up @@ -1558,7 +1559,7 @@ func TestMsgUpdateRequestContextValidation(t *testing.T) {
invalidTimeout := int64(-1)
invalidLessRepeatedFreq := uint64(testTimeout) - 10
invalidRepeatedTotal := int64(-2)
invalidDenomCoins := sdk.Coins{sdk.Coin{Denom: "eth+min", Amount: sdk.NewInt(1000)}}
invalidDenomCoins := sdk.Coins{sdk.Coin{Denom: "eth+min", Amount: math.NewInt(1000)}}

testMsgs := []*MsgUpdateRequestContext{
NewMsgUpdateRequestContext(
Expand Down

0 comments on commit 8b34544

Please sign in to comment.