Skip to content

Commit

Permalink
chore(webapi+gateway): lint and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MStreet3 committed Dec 13, 2024
1 parent 990fd21 commit 2affaf8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions core/capabilities/webapi/outgoing_connector_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/utils/matches"

"github.com/smartcontractkit/chainlink/v2/core/services/gateway/api"
gcmocks "github.com/smartcontractkit/chainlink/v2/core/services/gateway/connector/mocks"
Expand All @@ -36,6 +37,7 @@ func TestHandleSingleNodeRequest(t *testing.T) {
msgID := "msgID"
testURL := "http://localhost:8080"
connector.EXPECT().DonID().Return("donID")
connector.EXPECT().AwaitConnection(matches.AnyContext, "gateway1").Return(nil)
connector.EXPECT().GatewayIDs().Return([]string{"gateway1"})

// build the expected body with the default timeout
Expand Down Expand Up @@ -82,6 +84,7 @@ func TestHandleSingleNodeRequest(t *testing.T) {
msgID := "msgID"
testURL := "http://localhost:8080"
connector.EXPECT().DonID().Return("donID")
connector.EXPECT().AwaitConnection(matches.AnyContext, "gateway1").Return(nil)
connector.EXPECT().GatewayIDs().Return([]string{"gateway1"})

// build the expected body with the defined timeout
Expand Down
4 changes: 2 additions & 2 deletions core/services/gateway/connector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ func (c *gatewayConnector) AwaitConnection(ctx context.Context, gatewayID string
func (c *gatewayConnector) SendToGateway(ctx context.Context, gatewayID string, msg *api.Message) error {
data, err := c.codec.EncodeResponse(msg)
if err != nil {
return fmt.Errorf("error encoding response for gateway %s: %v", gatewayID, err)
return fmt.Errorf("error encoding response for gateway %s: %w", gatewayID, err)
}
gateway, ok := c.gateways[gatewayID]
if !ok {
return fmt.Errorf("invalid Gateway ID %s", gatewayID)
}
if gateway.conn == nil {
return fmt.Errorf("connector not started")
return errors.New("connector not started")
}
return gateway.conn.Write(ctx, websocket.BinaryMessage, data)
}
Expand Down
2 changes: 2 additions & 0 deletions core/services/workflows/syncer/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
gcmocks "github.com/smartcontractkit/chainlink/v2/core/services/gateway/connector/mocks"
"github.com/smartcontractkit/chainlink/v2/core/services/gateway/handlers/capabilities"
ghcapabilities "github.com/smartcontractkit/chainlink/v2/core/services/gateway/handlers/capabilities"
"github.com/smartcontractkit/chainlink/v2/core/utils/matches"
)

type wrapper struct {
Expand Down Expand Up @@ -48,6 +49,7 @@ func TestNewFetcherService(t *testing.T) {
fetcher.och.HandleGatewayMessage(ctx, "gateway1", gatewayResp)
}).Return(nil).Times(1)
connector.EXPECT().DonID().Return("don-id")
connector.EXPECT().AwaitConnection(matches.AnyContext, "gateway1").Return(nil)
connector.EXPECT().GatewayIDs().Return([]string{"gateway1", "gateway2"})

payload, err := fetcher.Fetch(ctx, url)
Expand Down

0 comments on commit 2affaf8

Please sign in to comment.