Skip to content

Commit

Permalink
fix: node gateway visbility improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
brianluong committed Dec 19, 2023
1 parent 404f169 commit 15bb16d
Show file tree
Hide file tree
Showing 19 changed files with 244 additions and 181 deletions.
6 changes: 3 additions & 3 deletions internal/jsonrpc/jsonrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ type DecodeError struct {
Content []byte // Content that couldn't be decoded.
}

func NewDecodeError(err error, content []byte) DecodeError {
return DecodeError{
func NewDecodeError(err error, content []byte) *DecodeError {
return &DecodeError{
Err: err,
Content: content,
}
}

func (e DecodeError) Error() string {
func (e *DecodeError) Error() string {
return fmt.Sprintf("decode error: %s, content: %s", e.Err.Error(), string(e.Content))
}

Expand Down
13 changes: 10 additions & 3 deletions internal/jsonrpc/jsonrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ func TestEncodeAndDecodeResponses(t *testing.T) {
},
},
},
{
testName: "empty response in batch",
body: ``,
expectedResponse: nil,
},
{
testName: "batch responses",
body: "[" +
Expand Down Expand Up @@ -180,9 +185,11 @@ func TestEncodeAndDecodeResponses(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, tc.expectedResponse, decoded)

encoded, err := decoded.Encode()
if decoded != nil {
encoded, err := decoded.Encode()

assert.Nil(t, err)
assert.Equal(t, tc.body, string(encoded))
assert.Nil(t, err)
assert.Equal(t, tc.body, string(encoded))
}
}
}
2 changes: 1 addition & 1 deletion internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ var (
"Batches are deconstructed to single JSON RPC requests for this metric.",
},
// jsonrpc_method is "batch" for batch requests
[]string{"chain_name", "client", "upstream_id", "url", "jsonrpc_method", "response_code", "jsonrpc_error_code"},
[]string{"chain_name", "client", "upstream_id", "url", "jsonrpc_method", "jsonrpc_error_code"},
)

upstreamRPCDuration = promauto.NewHistogramVec(
Expand Down
23 changes: 17 additions & 6 deletions internal/mocks/BlockHeightChecker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions internal/mocks/Checker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 21 additions & 6 deletions internal/mocks/EthClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions internal/mocks/HTTPClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions internal/mocks/HealthCheckManager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 22 additions & 25 deletions internal/mocks/Router.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 15bb16d

Please sign in to comment.