Merge branch 'ethereum:master' into rlp-review

This commit is contained in:
David Theodore 2024-05-25 13:21:49 -05:00 committed by GitHub
commit 8d966db77f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 8 deletions

View file

@ -103,14 +103,14 @@ func TestExpDecaySample(t *testing.T) {
} }
snap := sample.Snapshot() snap := sample.Snapshot()
if have, want := int(snap.Count()), tc.updates; have != want { if have, want := int(snap.Count()), tc.updates; have != want {
t.Errorf("have %d want %d", have, want) t.Errorf("unexpected count: have %d want %d", have, want)
} }
if have, want := snap.Size(), min(tc.updates, tc.reservoirSize); have != want { if have, want := snap.Size(), min(tc.updates, tc.reservoirSize); have != want {
t.Errorf("have %d want %d", have, want) t.Errorf("unexpected size: have %d want %d", have, want)
} }
values := snap.(*sampleSnapshot).values values := snap.(*sampleSnapshot).values
if have, want := len(values), min(tc.updates, tc.reservoirSize); have != want { if have, want := len(values), min(tc.updates, tc.reservoirSize); have != want {
t.Errorf("have %d want %d", have, want) t.Errorf("unexpected values length: have %d want %d", have, want)
} }
for _, v := range values { for _, v := range values {
if v > int64(tc.updates) || v < 0 { if v > int64(tc.updates) || v < 0 {
@ -125,12 +125,12 @@ func TestExpDecaySample(t *testing.T) {
// The priority becomes +Inf quickly after starting if this is done, // The priority becomes +Inf quickly after starting if this is done,
// effectively freezing the set of samples until a rescale step happens. // effectively freezing the set of samples until a rescale step happens.
func TestExpDecaySampleNanosecondRegression(t *testing.T) { func TestExpDecaySampleNanosecondRegression(t *testing.T) {
sw := NewExpDecaySample(100, 0.99) sw := NewExpDecaySample(1000, 0.99)
for i := 0; i < 100; i++ { for i := 0; i < 1000; i++ {
sw.Update(10) sw.Update(10)
} }
time.Sleep(1 * time.Millisecond) time.Sleep(1 * time.Millisecond)
for i := 0; i < 100; i++ { for i := 0; i < 1000; i++ {
sw.Update(20) sw.Update(20)
} }
s := sw.Snapshot() s := sw.Snapshot()
@ -251,6 +251,9 @@ func benchmarkSample(b *testing.B, s Sample) {
} }
func testExpDecaySampleStatistics(t *testing.T, s SampleSnapshot) { func testExpDecaySampleStatistics(t *testing.T, s SampleSnapshot) {
if sum := s.Sum(); sum != 496598 {
t.Errorf("s.Sum(): 496598 != %v\n", sum)
}
if count := s.Count(); count != 10000 { if count := s.Count(); count != 10000 {
t.Errorf("s.Count(): 10000 != %v\n", count) t.Errorf("s.Count(): 10000 != %v\n", count)
} }

View file

@ -364,7 +364,7 @@ func TestTable_revalidateSyncRecord(t *testing.T) {
transport.updateRecord(n2) transport.updateRecord(n2)
// Wait for revalidation. We wait for the node to be revalidated two times // Wait for revalidation. We wait for the node to be revalidated two times
// in order to synchronize with the update in the able. // in order to synchronize with the update in the table.
waitForRevalidationPing(t, transport, tab, n2.ID()) waitForRevalidationPing(t, transport, tab, n2.ID())
waitForRevalidationPing(t, transport, tab, n2.ID()) waitForRevalidationPing(t, transport, tab, n2.ID())

View file

@ -405,7 +405,7 @@ func (srv *Server) DiscoveryV4() *discover.UDPv4 {
return srv.discv4 return srv.discv4
} }
// DiscoveryV4 returns the discovery v5 instance, if configured. // DiscoveryV5 returns the discovery v5 instance, if configured.
func (srv *Server) DiscoveryV5() *discover.UDPv5 { func (srv *Server) DiscoveryV5() *discover.UDPv5 {
return srv.discv5 return srv.discv5
} }