Skip to content

Commit

Permalink
check total number of slots requested
Browse files Browse the repository at this point in the history
  • Loading branch information
iurii-ssv committed Oct 21, 2024
1 parent 983930f commit 0cdfacd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions beacon/goclient/attest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ func TestGoClient_GetAttestationData(t *testing.T) {
require.Equal(t, gotResult1c.Target.Epoch, gotResult1a.Target.Epoch)
require.Equal(t, gotResult1c.Target.Root, gotResult1a.Target.Root)

uniqueSlots := serverGotRequests.SlowLen()
require.Equal(t, 2, uniqueSlots)
reqCntSlot1, ok := serverGotRequests.Get(slot1)
require.True(t, ok)
require.Equal(t, 1, reqCntSlot1)
Expand Down Expand Up @@ -300,5 +302,7 @@ func TestGoClient_GetAttestationData(t *testing.T) {
reqCnt, _ := serverGotRequests.GetOrSet(slot, 1)
require.Equal(t, 1, reqCnt)
}
uniqueSlots := serverGotRequests.SlowLen()
require.Equal(t, slotsTotalCnt, uniqueSlots)
})
}
3 changes: 3 additions & 0 deletions utils/hashmap/hashmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func (m *Map[Key, Value]) Set(key Key, value Value) {
}

// SlowLen returns the number of elements in the map by iterating over all items.
// This method call doesn't block other operations (for example Set), hence the
// resulting length value returned might or might not reflect the outcome of
// concurrent operations happening with this Map.
//
// This implementation is quite expensive. If it becomes a bottleneck,
// we should consider maintaining an internal atomic counter and
Expand Down

0 comments on commit 0cdfacd

Please sign in to comment.