mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
replace timers with chan signals
This commit is contained in:
parent
9b3bf9ac3a
commit
6f9a6504e4
1 changed files with 8 additions and 4 deletions
|
|
@ -158,12 +158,14 @@ func TestResubscribeWithErrorHandler(t *testing.T) {
|
|||
func TestResubscribeWithCompletedSubscription(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
innerSubDone := make(chan struct{}, 1)
|
||||
quitProducerAck := make(chan struct{})
|
||||
quitProducer := make(chan struct{})
|
||||
|
||||
sub := ResubscribeErr(100*time.Millisecond, func(ctx context.Context, lastErr error) (Subscription, error) {
|
||||
return NewSubscription(func(unsubscribed <-chan struct{}) error {
|
||||
select {
|
||||
case <-time.After(2 * time.Second):
|
||||
innerSubDone <- struct{}{}
|
||||
case <-quitProducer:
|
||||
quitProducerAck <- struct{}{}
|
||||
return nil
|
||||
case <-unsubscribed:
|
||||
return nil
|
||||
|
|
@ -171,6 +173,8 @@ func TestResubscribeWithCompletedSubscription(t *testing.T) {
|
|||
}), nil
|
||||
})
|
||||
|
||||
<-innerSubDone
|
||||
// Ensure producer has started and exited before Unsubscribe
|
||||
close(quitProducer)
|
||||
<-quitProducerAck
|
||||
sub.Unsubscribe()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue