Skip to content

Commit

Permalink
[test] fix unit test (#298)
Browse files Browse the repository at this point in the history
# Description

fix random ci test failed

```
panic: send on closed channel

goroutine 422 [running]:
github.com/dogechain-lab/dogechain/protocol.(*syncPeerClient).handleStatusUpdate(0xc000160cf0, {0xfb7720, 0xc0025efc80}, {0xc000b6ca80, 0xc000bdf701})
	/home/runner/work/dogechain/dogechain/protocol/client.go:225 +0x3ec
```

# Changes include

- [x] Bugfix (non-breaking change that solves an issue)

# Testing

- [x] I have tested this code with the official test suite
  • Loading branch information
0xcb9ff9 authored Feb 13, 2023
1 parent ae617e5 commit 33ffd6e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions protocol/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,14 @@ func TestPeerConnectionUpdateEventCh(t *testing.T) {

go func() {
defer wgForConnectingStatus.Done()
wgForGossip.Wait()

for status := range client.GetPeerStatusUpdateCh() {
newStatuses = append(newStatuses, status)

if len(newStatuses) > 0 {
break
}
}
}()

Expand All @@ -377,9 +382,6 @@ func TestPeerConnectionUpdateEventCh(t *testing.T) {
// wait until 2 messages are propagated
wgForGossip.Wait()

// close to terminate goroutine
close(client.peerStatusUpdateCh)

// wait until collecting routine is done
wgForConnectingStatus.Wait()

Expand Down

0 comments on commit 33ffd6e

Please sign in to comment.