Skip to content

Commit

Permalink
fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
sstanculeanu committed Feb 8, 2022
1 parent 6a36170 commit d6fb1a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
7 changes: 2 additions & 5 deletions dataRetriever/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,8 @@ var ErrNilEpochNotifier = errors.New("nil EpochNotifier")
// ErrNilPeerAuthenticationPool signals that a nil peer authentication pool has been provided
var ErrNilPeerAuthenticationPool = errors.New("nil peer authentication pool")

// ErrNilHeartbeatPool signals that a nil heartbeat pool has been provided
var ErrNilHeartbeatPool = errors.New("nil heartbeat pool")

// ErrNotFound signals that a data is missing
var ErrNotFound = errors.New("data not found")
// ErrPeerAuthNotFound signals that no peer authentication found
var ErrPeerAuthNotFound = errors.New("peer authentication not found")

// ErrNilNodesCoordinator signals a nil nodes coordinator has been provided
var ErrNilNodesCoordinator = errors.New("nil nodes coordinator")
Expand Down
6 changes: 3 additions & 3 deletions dataRetriever/resolvers/peerAuthenticationResolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (res *peerAuthenticationResolver) RequestDataFromHashArray(hashes [][]byte,
)
}

// ProcessReceivedMessage will be the callback func from the p2p.Messenger and will be called each time a new message was received
// ProcessReceivedMessage represents the callback func from the p2p.Messenger that is called each time a new message is received
// (for the topic this validator was registered to, usually a request topic)
func (res *peerAuthenticationResolver) ProcessReceivedMessage(message p2p.MessageP2P, fromConnectedPeer core.PeerID) error {
err := res.canProcessMessage(message, fromConnectedPeer)
Expand Down Expand Up @@ -287,7 +287,7 @@ func (res *peerAuthenticationResolver) fetchPeerAuthenticationSlicesForPublicKey
}

if len(peerAuths) == 0 {
return nil, dataRetriever.ErrNotFound
return nil, dataRetriever.ErrPeerAuthNotFound
}

return peerAuths, nil
Expand All @@ -300,7 +300,7 @@ func (res *peerAuthenticationResolver) fetchPeerAuthenticationAsByteSlice(pk []b
return res.marshalizer.Marshal(value)
}

return nil, dataRetriever.ErrNotFound
return nil, dataRetriever.ErrPeerAuthNotFound
}

// IsInterfaceNil returns true if there is no value under the interface
Expand Down
8 changes: 4 additions & 4 deletions dataRetriever/resolvers/peerAuthenticationResolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func TestNewPeerAuthenticationResolver(t *testing.T) {
})
}

func Test_peerAuthenticationResolver_ProcessReceivedMessage(t *testing.T) {
func TestPeerAuthenticationResolver_ProcessReceivedMessage(t *testing.T) {
t.Parallel()

t.Run("nil message should error", func(t *testing.T) {
Expand Down Expand Up @@ -275,7 +275,7 @@ func Test_peerAuthenticationResolver_ProcessReceivedMessage(t *testing.T) {
epoch := uint32(0)
chunkIndex := uint32(0)
err = res.ProcessReceivedMessage(createRequestMsgWithChunkIndex(dataRetriever.ChunkType, []byte(""), epoch, chunkIndex), fromConnectedPeer)
assert.True(t, errors.Is(err, dataRetriever.ErrNotFound))
assert.True(t, errors.Is(err, dataRetriever.ErrPeerAuthNotFound))
expectedSubstrErr := fmt.Sprintf("%s %d", "from chunk", chunkIndex)
assert.True(t, strings.Contains(fmt.Sprintf("%s", err), expectedSubstrErr))
assert.False(t, wasSent)
Expand Down Expand Up @@ -535,7 +535,7 @@ func Test_peerAuthenticationResolver_ProcessReceivedMessage(t *testing.T) {
})
}

func Test_peerAuthenticationResolver_RequestShouldError(t *testing.T) {
func TestPeerAuthenticationResolver_RequestShouldError(t *testing.T) {
t.Parallel()

arg := createMockArgPeerAuthenticationResolver()
Expand Down Expand Up @@ -571,7 +571,7 @@ func Test_peerAuthenticationResolver_RequestShouldError(t *testing.T) {

}

func Test_peerAuthenticationResolver_RequestShouldWork(t *testing.T) {
func TestPeerAuthenticationResolver_RequestShouldWork(t *testing.T) {
t.Parallel()

arg := createMockArgPeerAuthenticationResolver()
Expand Down

0 comments on commit d6fb1a2

Please sign in to comment.