Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/docker/main/docker-06a09a4df5
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmkowalski authored Sep 4, 2024
2 parents 2a17a4e + 6a9abba commit 83e1ab8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
7 changes: 7 additions & 0 deletions .golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ linters:
- unused

linters-settings:
gosec:
excludes:
- G115 # Potential integer overflow when converting between integer types

issues:
# List of regexps of issue texts to exclude, empty list by default.
Expand All @@ -108,6 +111,10 @@ issues:
linters:
- gosec

- path: doc\.go
linters:
- revive

# Exclude some "staticcheck" messages
- linters:
- staticcheck
Expand Down
7 changes: 3 additions & 4 deletions transports/p2p/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1243,9 +1243,8 @@ out:
// local peer is not forcibly disconnecting and the
// remote peer has not disconnected.
if p.shouldHandleReadError(err) {
errMsg := fmt.Sprintf("Can't read message from %s: %v", p, err)
if err != io.ErrUnexpectedEOF {
p.cfg.Log.Error().Msgf(errMsg)
p.cfg.Log.Error().Msgf("Can't read message from %s: %v", p, err)
}

// Push a reject message for the malformed message and disconnect
Expand All @@ -1255,8 +1254,8 @@ out:
// at least that much of the message was valid, but that is not
// currently exposed by wire, so just used malformed for the
// command.
p.PushRejectMsg("malformed", wire.RejectMalformed, errMsg, nil,
true)
p.PushRejectMsg("malformed", wire.RejectMalformed,
fmt.Sprintf("Can't read message from %s: %v", p, err), nil, true)

p.Disconnect()
}
Expand Down
32 changes: 17 additions & 15 deletions transports/websocket/websocket_notification.integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ import (
"github.com/kinbiko/jsonassert"
)

const (
expectedEvent = `{
"operation": "ADD",
"header": {
"hash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
"version": 1,
"height": 1,
"merkleRoot": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
"creationTimestamp": "2009-01-09T02:54:25Z",
"nonce": 2573394689,
"state": "LONGEST_CHAIN",
"work": 8590065666,
"prevBlockHash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
}
}`
)

func TestShouldNotifyWebsocketAboutNewHeader(t *testing.T) {
// setup
p, cleanup := testapp.NewTestBlockHeaderService(t, testapp.WithAPIAuthorizationDisabled())
Expand All @@ -32,21 +49,6 @@ func TestShouldNotifyWebsocketAboutNewHeader(t *testing.T) {
msg, err := wait.ForString(onMsg, time.Second)
assert.NoError(t, err)

expectedEvent := `{
"operation": "ADD",
"header": {
"hash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
"version": 1,
"height": 1,
"merkleRoot": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
"creationTimestamp": "2009-01-09T02:54:25Z",
"nonce": 2573394689,
"state": "LONGEST_CHAIN",
"work": 8590065666,
"prevBlockHash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
}
}`

json := jsonassert.New(t)
json.Assertf(msg, expectedEvent)
}

0 comments on commit 83e1ab8

Please sign in to comment.