mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
Regular Sync - First Pass (#3201)
* checkpoint * checkpoint * varint prefix for ssz * move the encoding API around a little bit to support reader writer * add a simple test for the happy path subscribe * move wait timeout to testutil * Add inverted topic mapping * Add varint prefixing to ssz network encoder * fix spacing * fix comments * fix comments * make anon methods more clear * clean up log fields * move topic mapping, reformat TODOs, get ready for brutal team review * lint * lint * lint * Update beacon-chain/p2p/gossip_topic_mappings.go Co-Authored-By: Nishant Das <nishdas93@gmail.com> * PR feedback * PR feedback * PR feedback * PR feedback * PR feedback * Update WORKSPACE * Update WORKSPACE
This commit is contained in:
@@ -10,6 +10,7 @@ go_library(
|
||||
"json_to_pb_converter.go",
|
||||
"log.go",
|
||||
"tempdir.go",
|
||||
"wait_timeout.go",
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/shared/testutil",
|
||||
visibility = ["//visibility:public"],
|
||||
|
||||
22
shared/testutil/wait_timeout.go
Normal file
22
shared/testutil/wait_timeout.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// WaitTimeout will wait for a WaitGroup to resolve within a timeout interval.
|
||||
// Returns true if the waitgroup exceeded the timeout.
|
||||
func WaitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool {
|
||||
ch := make(chan struct{})
|
||||
go func() {
|
||||
defer close(ch)
|
||||
wg.Wait()
|
||||
}()
|
||||
select {
|
||||
case <-ch:
|
||||
return false
|
||||
case <-time.After(timeout):
|
||||
return true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user