Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Service] NIT followups to AddService in #316 #338

Merged
merged 25 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ require (
github.com/athanorlabs/go-dleq v0.1.0
github.com/cometbft/cometbft v0.37.2
github.com/cometbft/cometbft-db v0.8.0
github.com/cosmos/cosmos-proto v1.0.0-beta.2
github.com/cosmos/cosmos-sdk v0.47.3
github.com/cosmos/gogoproto v1.4.11
github.com/cosmos/ibc-go/v7 v7.1.0
Expand All @@ -48,7 +47,6 @@ require (
golang.org/x/crypto v0.15.0
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
golang.org/x/sync v0.5.0
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb
google.golang.org/grpc v1.59.0
gopkg.in/yaml.v2 v2.4.0
)
Expand Down Expand Up @@ -92,6 +90,7 @@ require (
github.com/containerd/cgroups v1.1.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.2 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v0.20.0 // indirect
Expand Down Expand Up @@ -286,6 +285,7 @@ require (
google.golang.org/api v0.143.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
1 change: 1 addition & 0 deletions pkg/relayer/proxy/relay_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
sdkerrors "cosmossdk.io/errors"
ring_secp256k1 "github.com/athanorlabs/go-dleq/secp256k1"
ring "github.com/noot/ring-go"

"github.com/pokt-network/poktroll/x/service/types"
sharedtypes "github.com/pokt-network/poktroll/x/shared/types"
)
Expand Down
2 changes: 1 addition & 1 deletion x/service/client/cli/tx_add_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ gateways and suppliers to use. The service id MUST be unique - or the command
will fail, however the name you use to describe it does not have to be unique.

Example:
$ poktrolld tx service add-service "srv1" "service_one" --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE) --home=$(POKTROLLD_HOME)`,
$ poktrolld tx service add-service "svc1" "service_one" --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE) --home=$(POKTROLLD_HOME)`,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) (err error) {
serviceIdStr := args[0]
Expand Down
8 changes: 4 additions & 4 deletions x/service/client/cli/tx_add_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ func TestCLI_AddService(t *testing.T) {

// Prepare two valid services
svc1 := sharedtypes.Service{
Id: "srv1",
Id: "svc1",
Name: "service name",
}
svc2 := sharedtypes.Service{
Id: "srv2",
Id: "svc2",
Name: "service name 2",
}
// Add srv2 to the network
// Add svc2 to the network
args := []string{
svc2.Id,
svc2.Name,
Expand Down Expand Up @@ -89,7 +89,7 @@ func TestCLI_AddService(t *testing.T) {
{
desc: "invalid - missing service name",
supplierAddress: account.Address.String(),
service: sharedtypes.Service{Id: "srv1"}, // Name intentionally omitted
service: sharedtypes.Service{Id: "svc1"}, // Name intentionally omitted
err: types.ErrServiceMissingName,
},
{
Expand Down
18 changes: 9 additions & 9 deletions x/service/keeper/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ func init() {
cmd.InitSDKConfig()
}

func createNservices(keeper *keeper.Keeper, ctx sdk.Context, n int) []sharedtypes.Service {
func createNServices(keeper *keeper.Keeper, ctx sdk.Context, n int) []sharedtypes.Service {
services := make([]sharedtypes.Service, n)
for i := range services {
services[i].Id = fmt.Sprintf("srvId%d", i)
services[i].Name = fmt.Sprintf("srvName%d", i)
services[i].Id = fmt.Sprintf("svcId%d", i)
services[i].Name = fmt.Sprintf("svcName%d", i)

keeper.SetService(ctx, services[i])
}
Expand All @@ -42,22 +42,22 @@ func TestServiceModuleAddress(t *testing.T) {

func TestServiceGet(t *testing.T) {
keeper, ctx := keepertest.ServiceKeeper(t)
services := createNservices(keeper, ctx, 10)
for _, item := range services {
services := createNServices(keeper, ctx, 10)
for _, service := range services {
service, found := keeper.GetService(ctx,
item.Id,
service.Id,
)
require.True(t, found)
require.Equal(t,
nullify.Fill(&item),
nullify.Fill(&service),
nullify.Fill(&service),
)
}
}

func TestServiceRemove(t *testing.T) {
keeper, ctx := keepertest.ServiceKeeper(t)
services := createNservices(keeper, ctx, 10)
services := createNServices(keeper, ctx, 10)
for _, service := range services {
keeper.RemoveService(ctx,
service.Id,
Expand All @@ -71,7 +71,7 @@ func TestServiceRemove(t *testing.T) {

func TestServiceGetAll(t *testing.T) {
keeper, ctx := keepertest.ServiceKeeper(t)
services := createNservices(keeper, ctx, 10)
services := createNServices(keeper, ctx, 10)
require.ElementsMatch(t,
nullify.Fill(services),
nullify.Fill(keeper.GetAllServices(ctx)),
Expand Down
4 changes: 2 additions & 2 deletions x/service/simulation/add_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func SimulateMsgAddService(
msg := &types.MsgAddService{
Address: simAccount.Address.String(),
Service: sharedtypes.Service{
Id: fmt.Sprintf("srvId%d", rndNum),
Name: fmt.Sprintf("servName%d", rndNum),
Id: fmt.Sprintf("svcId%d", rndNum),
Name: fmt.Sprintf("svcName%d", rndNum),
},
}

Expand Down
8 changes: 4 additions & 4 deletions x/service/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (

func TestGenesisState_Validate(t *testing.T) {
svc1 := &sharedtypes.Service{
Id: "srvId1",
Name: "srvName1",
Id: "svcId1",
Name: "svcName1",
}

svc2 := &sharedtypes.Service{
Id: "srvId2",
Name: "srvName2",
Id: "svcId2",
Name: "svcName2",
}

tests := []struct {
Expand Down
4 changes: 2 additions & 2 deletions x/service/types/message_add_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ func TestMsgAddService_ValidateBasic(t *testing.T) {
desc: "valid service supplier address - no service name",
msg: MsgAddService{
Address: sample.AccAddress(),
Service: sharedtypes.Service{Id: "srv1"}, // Name intentionally omitted
Service: sharedtypes.Service{Id: "svc1"}, // Name intentionally omitted
},
expectedErr: ErrServiceMissingName,
}, {
desc: "valid service supplier address and service",
msg: MsgAddService{
Address: sample.AccAddress(),
Service: sharedtypes.Service{Id: "srv1", Name: "service name"},
Service: sharedtypes.Service{Id: "svc1", Name: "service name"},
},
expectedErr: nil,
},
Expand Down
2 changes: 1 addition & 1 deletion x/shared/helpers/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestIsValidService(t *testing.T) {
{
desc: "Valid ID and empty Name",

serviceId: "Srv",
serviceId: "svc",
serviceName: "", // Valid because the service name can be empty

expectedIsValid: true,
Expand Down
Loading