Skip to content

Commit

Permalink
remove len check for cache test
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyonur committed Oct 16, 2024
1 parent f8470b2 commit 95c10a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions network/p2p/acp118/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (h *Handler) AppRequest(

msgID := msg.ID()
if signatureBytes, ok := h.signatureCache.Get(msgID); ok {
return responseBytesFromSignature(signatureBytes)
return signatureToResponse(signatureBytes)
}

if err := h.verifier.Verify(ctx, msg, request.Justification); err != nil {
Expand All @@ -101,10 +101,10 @@ func (h *Handler) AppRequest(
}

h.signatureCache.Put(msgID, signature)
return responseBytesFromSignature(signature)
return signatureToResponse(signature)
}

func responseBytesFromSignature(signature []byte) ([]byte, *common.AppError) {
func signatureToResponse(signature []byte) ([]byte, *common.AppError) {
response := &sdk.SignatureResponse{
Signature: signature,
}
Expand Down
7 changes: 3 additions & 4 deletions network/p2p/acp118/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,9 @@ func TestHandler(t *testing.T) {

require.True(bls.Verify(pk, signature, request.Message))

if tt.cacher.Len() > 0 {
// Ensure the cache is populated with correct signature
sig, ok := tt.cacher.Get(unsignedMessage.ID())
require.True(ok)
// Ensure the cache is populated with correct signature
sig, ok := tt.cacher.Get(unsignedMessage.ID())
if ok {
require.Equal(sig, response.Signature)
}
}
Expand Down

0 comments on commit 95c10a3

Please sign in to comment.