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

Rebranding #120

Merged
merged 18 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
removed MultiversX from Proxy, Notifee, ShardCoordinator 2
  • Loading branch information
raduchis committed Jan 26, 2023
commit d570806f2a3725b97ee45b4b70022b2b4c99264a
56 changes: 28 additions & 28 deletions blockchain/baseProxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ import (
"github.com/stretchr/testify/require"
)

func createMockArgsMultiversXBaseProxy() argsBaseProxy {
func createMockArgsBaseProxy() argsBaseProxy {
return argsBaseProxy{
httpClientWrapper: &testsCommon.HTTPClientWrapperStub{},
expirationTime: time.Second,
endpointProvider: endpointProviders.NewNodeEndpointProvider(),
}
}

func TestNewMultiversXBaseProxy(t *testing.T) {
func TestNewBaseProxy(t *testing.T) {
t.Parallel()

t.Run("nil http client wrapper", func(t *testing.T) {
t.Parallel()

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.httpClientWrapper = nil
baseProxy, err := newBaseProxy(args)

Expand All @@ -42,7 +42,7 @@ func TestNewMultiversXBaseProxy(t *testing.T) {
t.Run("invalid caching duration", func(t *testing.T) {
t.Parallel()

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.expirationTime = time.Second - time.Nanosecond
baseProxy, err := newBaseProxy(args)

Expand All @@ -52,7 +52,7 @@ func TestNewMultiversXBaseProxy(t *testing.T) {
t.Run("nil endpoint provider", func(t *testing.T) {
t.Parallel()

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.endpointProvider = nil
baseProxy, err := newBaseProxy(args)

Expand All @@ -62,15 +62,15 @@ func TestNewMultiversXBaseProxy(t *testing.T) {
t.Run("should work", func(t *testing.T) {
t.Parallel()

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
baseProxy, err := newBaseProxy(args)

assert.False(t, check.IfNil(baseProxy))
assert.Nil(t, err)
})
}

func TestMultiversXBaseProxy_GetNetworkConfig(t *testing.T) {
func TestBaseProxy_GetNetworkConfig(t *testing.T) {
t.Parallel()

expectedReturnedNetworkConfig := &data.NetworkConfig{
Expand Down Expand Up @@ -110,7 +110,7 @@ func TestMultiversXBaseProxy_GetNetworkConfig(t *testing.T) {
return networkConfigBytes, http.StatusOK, nil
}

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.httpClientWrapper = mockWrapper
args.expirationTime = minimumCachingInterval * 2
baseProxy, _ := newBaseProxy(args)
Expand All @@ -134,7 +134,7 @@ func TestMultiversXBaseProxy_GetNetworkConfig(t *testing.T) {
return networkConfigBytes, http.StatusOK, nil
}

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.httpClientWrapper = mockWrapper
args.expirationTime = minimumCachingInterval * 2
baseProxy, _ := newBaseProxy(args)
Expand All @@ -159,7 +159,7 @@ func TestMultiversXBaseProxy_GetNetworkConfig(t *testing.T) {
return nil, http.StatusBadRequest, expectedErr
}

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.httpClientWrapper = mockWrapper
baseProxy, _ := newBaseProxy(args)

Expand All @@ -180,7 +180,7 @@ func TestMultiversXBaseProxy_GetNetworkConfig(t *testing.T) {
return []byte("malformed data"), http.StatusOK, nil
}

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.httpClientWrapper = mockWrapper
baseProxy, _ := newBaseProxy(args)

Expand Down Expand Up @@ -211,7 +211,7 @@ func TestMultiversXBaseProxy_GetNetworkConfig(t *testing.T) {
return erroredNetworkConfigBytes, http.StatusOK, nil
}

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.httpClientWrapper = mockWrapper
baseProxy, _ := newBaseProxy(args)

Expand All @@ -232,7 +232,7 @@ func TestMultiversXBaseProxy_GetNetworkConfig(t *testing.T) {
return nil, http.StatusOK, nil
}

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.httpClientWrapper = mockWrapper
args.expirationTime = minimumCachingInterval * 2
baseProxy, _ := newBaseProxy(args)
Expand All @@ -249,14 +249,14 @@ func TestMultiversXBaseProxy_GetNetworkConfig(t *testing.T) {
})
}

func TestMultiversXBaseProxy_GetNetworkStatus(t *testing.T) {
func TestBaseProxy_GetNetworkStatus(t *testing.T) {
t.Parallel()

expectedErr := errors.New("expected error")
t.Run("get errors", func(t *testing.T) {
t.Parallel()

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{
GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) {
return nil, http.StatusBadRequest, expectedErr
Expand All @@ -272,7 +272,7 @@ func TestMultiversXBaseProxy_GetNetworkStatus(t *testing.T) {
t.Run("malformed response - node endpoint provider", func(t *testing.T) {
t.Parallel()

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{
GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) {
return []byte("malformed response"), http.StatusOK, nil
Expand All @@ -288,7 +288,7 @@ func TestMultiversXBaseProxy_GetNetworkStatus(t *testing.T) {
t.Run("malformed response - proxy endpoint provider", func(t *testing.T) {
t.Parallel()

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.endpointProvider = endpointProviders.NewProxyEndpointProvider()
args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{
GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) {
Expand All @@ -314,7 +314,7 @@ func TestMultiversXBaseProxy_GetNetworkStatus(t *testing.T) {
}
respBytes, _ := json.Marshal(resp)

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{
GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) {
return respBytes, http.StatusOK, nil
Expand All @@ -339,7 +339,7 @@ func TestMultiversXBaseProxy_GetNetworkStatus(t *testing.T) {
}
respBytes, _ := json.Marshal(resp)

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.endpointProvider = endpointProviders.NewProxyEndpointProvider()
args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{
GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) {
Expand All @@ -356,7 +356,7 @@ func TestMultiversXBaseProxy_GetNetworkStatus(t *testing.T) {
t.Run("GetNodeStatus returns nil network status - node endpoint provider", func(t *testing.T) {
t.Parallel()

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{
GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) {
return getNetworkStatusBytes(nil), http.StatusOK, nil
Expand All @@ -372,7 +372,7 @@ func TestMultiversXBaseProxy_GetNetworkStatus(t *testing.T) {
t.Run("GetNodeStatus returns nil network status - proxy endpoint provider", func(t *testing.T) {
t.Parallel()

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.endpointProvider = endpointProviders.NewProxyEndpointProvider()
args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{
GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) {
Expand Down Expand Up @@ -402,7 +402,7 @@ func TestMultiversXBaseProxy_GetNetworkStatus(t *testing.T) {
ShardID: core.MetachainShardId,
}

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{
GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) {
return getNodeStatusBytes(providedNetworkStatus), http.StatusOK, nil
Expand Down Expand Up @@ -430,7 +430,7 @@ func TestMultiversXBaseProxy_GetNetworkStatus(t *testing.T) {
CrossCheckBlockHeight: "aaa",
}

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{
GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) {
return getNodeStatusBytes(providedNetworkStatus), http.StatusOK, nil
Expand Down Expand Up @@ -458,7 +458,7 @@ func TestMultiversXBaseProxy_GetNetworkStatus(t *testing.T) {
ShardID: core.MetachainShardId, // this won't be tested in this test
}

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.endpointProvider = endpointProviders.NewProxyEndpointProvider()
args.httpClientWrapper = &testsCommon.HTTPClientWrapperStub{
GetHTTPCalled: func(ctx context.Context, endpoint string) ([]byte, int, error) {
Expand Down Expand Up @@ -495,7 +495,7 @@ func getNodeStatusBytes(status *data.NetworkStatus) []byte {
return respBytes
}

func TestMultiversXBaseProxy_GetShardOfAddress(t *testing.T) {
func TestBaseProxy_GetShardOfAddress(t *testing.T) {
t.Parallel()

t.Run("invalid address", func(t *testing.T) {
Expand Down Expand Up @@ -576,17 +576,17 @@ func createBaseProxyForGetShardOfAddress(numShards uint32, errGet error) *basePr
return networkConfigBytes, http.StatusOK, nil
}

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
args.httpClientWrapper = mockWrapper
baseProxy, _ := newBaseProxy(args)

return baseProxy
}

func TestMultiversXBaseProxy_GetRestAPIEntityType(t *testing.T) {
func TestBaseProxy_GetRestAPIEntityType(t *testing.T) {
t.Parallel()

args := createMockArgsMultiversXBaseProxy()
args := createMockArgsBaseProxy()
baseProxy, _ := newBaseProxy(args)

assert.Equal(t, args.endpointProvider.GetRestAPIEntityType(), baseProxy.GetRestAPIEntityType())
Expand Down
2 changes: 1 addition & 1 deletion blockchain/finalityProvider/proxyFinalityProvider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestExtractNonceOfShardID(t *testing.T) {
})
}

func TestMultiversXBaseProxy_CheckShardFinalization(t *testing.T) {
func TestBaseProxy_CheckShardFinalization(t *testing.T) {
t.Parallel()

t.Run("invalid maxNoncesDelta", func(t *testing.T) {
Expand Down
Loading