Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions warp/handlers/signature_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func TestMessageSignatureHandler(t *testing.T) {
for name, test := range tests {
t.Run(name, func(t *testing.T) {
handler := NewSignatureRequestHandler(backend, message.Codec)
t.Cleanup(handler.stats.clear)

request, expectedResponse := test.setup()
responseBytes, err := handler.OnMessageSignatureRequest(context.Background(), ids.GenerateTestNodeID(), 1, request)
Expand Down Expand Up @@ -196,6 +197,7 @@ func TestBlockSignatureHandler(t *testing.T) {
for name, test := range tests {
t.Run(name, func(t *testing.T) {
handler := NewSignatureRequestHandler(backend, message.Codec)
t.Cleanup(handler.stats.clear)

request, expectedResponse := test.setup()
responseBytes, err := handler.OnBlockSignatureRequest(context.Background(), ids.GenerateTestNodeID(), 1, request)
Expand All @@ -216,3 +218,14 @@ func TestBlockSignatureHandler(t *testing.T) {
})
}
}

func (h *handlerStats) clear() {
h.messageSignatureRequest.Clear()
h.messageSignatureHit.Clear()
h.messageSignatureMiss.Clear()
h.messageSignatureRequestDuration.Update(0)
h.blockSignatureRequest.Clear()
h.blockSignatureHit.Clear()
h.blockSignatureMiss.Clear()
h.blockSignatureRequestDuration.Update(0)
}
8 changes: 8 additions & 0 deletions warp/verifier_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/ava-labs/coreth/plugin/evm/testutils"
"github.com/ava-labs/coreth/utils"
"github.com/ava-labs/coreth/warp/warptest"
"github.com/ava-labs/libevm/metrics"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
)
Expand Down Expand Up @@ -102,6 +103,7 @@ func TestAddressedCallSignatures(t *testing.T) {
sigCache = &cache.Empty[ids.ID, []byte]{}
}
warpBackend, err := NewBackend(snowCtx.NetworkID, snowCtx.ChainID, warpSigner, warptest.EmptyBlockClient, database, sigCache, [][]byte{offchainMessage.Bytes()})
t.Cleanup(unregisterVerifierStats)
require.NoError(t, err)
handler := acp118.NewCachedHandler(sigCache, warpBackend, warpSigner)

Expand Down Expand Up @@ -222,6 +224,7 @@ func TestBlockSignatures(t *testing.T) {
sigCache,
nil,
)
t.Cleanup(unregisterVerifierStats)
require.NoError(t, err)
handler := acp118.NewCachedHandler(sigCache, warpBackend, warpSigner)

Expand Down Expand Up @@ -258,3 +261,8 @@ func TestBlockSignatures(t *testing.T) {
}
}
}

func unregisterVerifierStats() {
metrics.Unregister("warp_backend_message_parse_fail")
metrics.Unregister("warp_backend_block_validation_fail")
}
Loading