From 95c10a35e70624393375854cec05af59e11257d9 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Wed, 16 Oct 2024 22:43:00 +0300 Subject: [PATCH] remove len check for cache test --- network/p2p/acp118/handler.go | 6 +++--- network/p2p/acp118/handler_test.go | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/network/p2p/acp118/handler.go b/network/p2p/acp118/handler.go index 8975b093ef68..971f29af9b82 100644 --- a/network/p2p/acp118/handler.go +++ b/network/p2p/acp118/handler.go @@ -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 { @@ -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, } diff --git a/network/p2p/acp118/handler_test.go b/network/p2p/acp118/handler_test.go index 1c74b4b75b40..e58d61a8f6a0 100644 --- a/network/p2p/acp118/handler_test.go +++ b/network/p2p/acp118/handler_test.go @@ -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) } }