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

Update to Cadence v1.3.0 #6779

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
[Access] Fix mocking in connection unittests
  • Loading branch information
peterargue committed Dec 18, 2024
commit 89a59a76319d0728b2a616b5c135413c0362b5b0
63 changes: 52 additions & 11 deletions engine/access/rpc/connection/connection_test.go
Original file line number Diff line number Diff line change
@@ -40,7 +40,11 @@ func TestProxyAccessAPI(t *testing.T) {

req := &access.PingRequest{}
expected := &access.PingResponse{}
cn.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
cn.handler.
On("Ping",
testifymock.Anything,
testifymock.AnythingOfType("*access.PingRequest")).
Return(expected, nil)

// create the factory
connectionFactory := new(ConnectionFactoryImpl)
@@ -85,7 +89,11 @@ func TestProxyExecutionAPI(t *testing.T) {

req := &execution.PingRequest{}
expected := &execution.PingResponse{}
en.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
en.handler.
On("Ping",
testifymock.Anything,
testifymock.AnythingOfType("*access.PingRequest")).
Return(expected, nil)

// create the factory
connectionFactory := new(ConnectionFactoryImpl)
@@ -130,7 +138,11 @@ func TestProxyAccessAPIConnectionReuse(t *testing.T) {

req := &access.PingRequest{}
expected := &access.PingResponse{}
cn.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
cn.handler.
On("Ping",
testifymock.Anything,
testifymock.AnythingOfType("*access.PingRequest")).
Return(expected, nil)

// create the factory
connectionFactory := new(ConnectionFactoryImpl)
@@ -188,7 +200,11 @@ func TestProxyExecutionAPIConnectionReuse(t *testing.T) {

req := &execution.PingRequest{}
expected := &execution.PingResponse{}
en.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
en.handler.
On("Ping",
testifymock.Anything,
testifymock.AnythingOfType("*access.PingRequest")).
Return(expected, nil)

// create the factory
connectionFactory := new(ConnectionFactoryImpl)
@@ -250,7 +266,12 @@ func TestExecutionNodeClientTimeout(t *testing.T) {
// setup the handler mock to not respond within the timeout
req := &execution.PingRequest{}
resp := &execution.PingResponse{}
en.handler.On("Ping", testifymock.Anything, req).After(timeout+time.Second).Return(resp, nil)
en.handler.
On("Ping",
testifymock.Anything,
testifymock.AnythingOfType("*access.PingRequest")).
After(timeout+time.Second).
Return(resp, nil)

// create the factory
connectionFactory := new(ConnectionFactoryImpl)
@@ -302,7 +323,12 @@ func TestCollectionNodeClientTimeout(t *testing.T) {
// setup the handler mock to not respond within the timeout
req := &access.PingRequest{}
resp := &access.PingResponse{}
cn.handler.On("Ping", testifymock.Anything, req).After(timeout+time.Second).Return(resp, nil)
cn.handler.
On("Ping",
testifymock.Anything,
testifymock.AnythingOfType("*access.PingRequest")).
After(timeout+time.Second).
Return(resp, nil)

// create the factory
connectionFactory := new(ConnectionFactoryImpl)
@@ -353,11 +379,22 @@ func TestConnectionPoolFull(t *testing.T) {
defer cn2.stop(t)
defer cn3.stop(t)

req := &access.PingRequest{}
expected := &access.PingResponse{}
cn1.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
cn2.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
cn3.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
cn1.handler.
On("Ping",
testifymock.Anything,
testifymock.AnythingOfType("*access.PingRequest")).
Return(expected, nil)
cn2.handler.
On("Ping",
testifymock.Anything,
testifymock.AnythingOfType("*access.PingRequest")).
Return(expected, nil)
cn3.handler.
On("Ping",
testifymock.Anything,
testifymock.AnythingOfType("*access.PingRequest")).
Return(expected, nil)

// create the factory
connectionFactory := new(ConnectionFactoryImpl)
@@ -436,7 +473,11 @@ func TestConnectionPoolStale(t *testing.T) {

req := &access.PingRequest{}
expected := &access.PingResponse{}
cn.handler.On("Ping", testifymock.Anything, req).Return(expected, nil)
cn.handler.
On("Ping",
testifymock.Anything,
testifymock.AnythingOfType("*access.PingRequest")).
Return(expected, nil)

// create the factory
connectionFactory := new(ConnectionFactoryImpl)