From dd17f66b00474c3adc35a7933ced2efdf02f47b3 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Wed, 8 Nov 2023 11:37:43 -0800 Subject: [PATCH] Fixing tests --- go.mod | 4 +- proto/pocket/shared/service.proto | 4 +- x/shared/helpers/service_test.go | 75 ------------------------------- 3 files changed, 4 insertions(+), 79 deletions(-) diff --git a/go.mod b/go.mod index 51aa32938..6856b606c 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( cosmossdk.io/math v1.0.1 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.10 github.com/cosmos/ibc-go/v7 v7.1.0 @@ -29,7 +28,6 @@ require ( go.uber.org/multierr v1.11.0 golang.org/x/crypto v0.12.0 golang.org/x/sync v0.3.0 - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 google.golang.org/grpc v1.56.1 gopkg.in/yaml.v2 v2.4.0 ) @@ -73,6 +71,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 @@ -268,6 +267,7 @@ require ( gonum.org/v1/gonum v0.11.0 // indirect google.golang.org/api v0.122.0 // indirect google.golang.org/appengine v1.6.7 // indirect + google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/proto/pocket/shared/service.proto b/proto/pocket/shared/service.proto index 8d6927515..4700035ce 100644 --- a/proto/pocket/shared/service.proto +++ b/proto/pocket/shared/service.proto @@ -19,7 +19,7 @@ message Service { // ApplicationServiceConfig holds the service configuration the application stakes for message ApplicationServiceConfig { - Service service = 1; // The Service for which the application is configured for + Service service = 1; // The Service for which the application is configured // TODO_RESEARCH: There is an opportunity for applications to advertise the max // they're willing to pay for a certain configuration/price, but this is outside of scope. @@ -28,7 +28,7 @@ message ApplicationServiceConfig { // SupplierServiceConfig holds the service configuration the supplier stakes for message SupplierServiceConfig { - Service service = 1; // The Service for which the supplier is configured for + Service service = 1; // The Service for which the supplier is configured repeated SupplierEndpoint endpoints = 2; // List of endpoints for the service // TODO_RESEARCH: There is an opportunity for supplier to advertise the min // they're willing to earn for a certain configuration/price, but this is outside of scope. diff --git a/x/shared/helpers/service_test.go b/x/shared/helpers/service_test.go index b3ff1f8e6..d74b77afa 100644 --- a/x/shared/helpers/service_test.go +++ b/x/shared/helpers/service_test.go @@ -79,77 +79,6 @@ func TestIsValidService(t *testing.T) { } } -func TestIsValidServiceId(t *testing.T) { - tests := []struct { - desc string - - input string - expected bool - }{ - { - desc: "Valid alphanumeric with hyphen", - - input: "Hello-1", - expected: true, - }, - { - desc: "Valid alphanumeric with underscore", - - input: "Hello_2", - expected: true, - }, - { - desc: "Exceeds maximum length", - - input: "hello-world", - expected: false, // exceeds maxServiceIdLength - }, - { - desc: "Contains invalid character '@'", - - input: "Hello@", - expected: false, // contains invalid character '@' - }, - { - desc: "All uppercase", - - input: "HELLO", - expected: true, - }, - { - desc: "Maximum length boundary", - - input: "12345678", - expected: true, // exactly maxServiceIdLength - }, - { - desc: "Above maximum length boundary", - - input: "123456789", - expected: false, // exceeds maxServiceIdLength - }, - { - desc: "Contains invalid character '.'", - - input: "Hello.World", - expected: false, // contains invalid character '.' - }, - { - desc: "Empty string", - - input: "", - expected: false, // empty string - }, - } - - for _, test := range tests { - t.Run(test.desc, func(t *testing.T) { - result := IsValidServiceId(test.input) - require.Equal(t, test.expected, result) - }) - } -} - func TestIsValidServiceName(t *testing.T) { tests := []struct { desc string @@ -196,10 +125,6 @@ func TestIsValidServiceName(t *testing.T) { for _, test := range tests { t.Run(test.desc, func(t *testing.T) { result := IsValidServiceName(test.input) - if result != test.expected { - t.Errorf("%s: For input '%s', expected %v but got %v", test.desc, test.input, test.expected, result) - } - result := IsValidService(service) require.Equal(t, test.expected, result) }) }