github.com/MetalBlockchain/metalgo@v1.11.9/snow/networking/timeout/manager_test.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package timeout 5 6 import ( 7 "sync" 8 "testing" 9 "time" 10 11 "github.com/prometheus/client_golang/prometheus" 12 "github.com/stretchr/testify/require" 13 14 "github.com/MetalBlockchain/metalgo/ids" 15 "github.com/MetalBlockchain/metalgo/snow/networking/benchlist" 16 "github.com/MetalBlockchain/metalgo/utils/timer" 17 ) 18 19 func TestManagerFire(t *testing.T) { 20 benchlist := benchlist.NewNoBenchlist() 21 manager, err := NewManager( 22 &timer.AdaptiveTimeoutConfig{ 23 InitialTimeout: time.Millisecond, 24 MinimumTimeout: time.Millisecond, 25 MaximumTimeout: 10 * time.Second, 26 TimeoutCoefficient: 1.25, 27 TimeoutHalflife: 5 * time.Minute, 28 }, 29 benchlist, 30 prometheus.NewRegistry(), 31 prometheus.NewRegistry(), 32 ) 33 require.NoError(t, err) 34 go manager.Dispatch() 35 defer manager.Stop() 36 37 wg := sync.WaitGroup{} 38 wg.Add(1) 39 40 manager.RegisterRequest( 41 ids.EmptyNodeID, 42 ids.Empty, 43 true, 44 ids.RequestID{}, 45 wg.Done, 46 ) 47 48 wg.Wait() 49 }