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 1d46cf2 commit 2a47585
Show file tree
Hide file tree
Showing 2 changed files with 5 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

0 comments on commit 2a47585

Please sign in to comment.