rpc/server: fix sporadic test failures
It can still be "reading" after test end: subscription_test.go:24: Error Trace: subscription_test.go:24 asm_amd64.s:1374 Error: Received unexpected error: set tcp 127.0.0.1:49874: use of closed network connection Test: TestFilteredNotaryRequestSubscriptions ================== WARNING: DATA RACE Write at 0x00c000e28989 by goroutine 185: testing.tRunner() /opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1126 +0x21a Previous write at 0x00c000e28989 by goroutine 192: testing.(*common).FailNow() /opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:731 +0x4f testing.(*T).FailNow() <autogenerated>:1 +0x44 github.com/stretchr/testify/require.NoError() /home/runner/go/pkg/mod/github.com/stretchr/testify@v1.6.1/require/require.go:1038 +0x104 github.com/nspcc-dev/neo-go/pkg/rpc/server.wsReader() /home/runner/work/neo-go/neo-go/pkg/rpc/server/subscription_test.go:24 +0x187 Goroutine 185 (running) created at: testing.(*T).Run() /opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1168 +0x5bb testing.runTests.func1() /opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1439 +0xa6 testing.tRunner() /opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1123 +0x202 testing.runTests() /opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1437 +0x612 testing.(*M).Run() /opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1345 +0x3b3 main.main() _testmain.go:89 +0x236 Goroutine 192 (finished) created at: github.com/nspcc-dev/neo-go/pkg/rpc/server.initCleanServerAndWSClient() /home/runner/work/neo-go/neo-go/pkg/rpc/server/subscription_test.go:65 +0x294 github.com/nspcc-dev/neo-go/pkg/rpc/server.TestFilteredNotaryRequestSubscriptions() /home/runner/work/neo-go/neo-go/pkg/rpc/server/subscription_test.go:348 +0x68d testing.tRunner() /opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1123 +0x202 ================== testing.go:1038: race detected during execution of test
This commit is contained in:
parent
c2d444ace7
commit
473a1fc24e
1 changed files with 4 additions and 0 deletions
|
@ -21,6 +21,10 @@ const testOverflow = false
|
|||
func wsReader(t *testing.T, ws *websocket.Conn, msgCh chan<- []byte, isFinished *atomic.Bool) {
|
||||
for {
|
||||
err := ws.SetReadDeadline(time.Now().Add(time.Second))
|
||||
if isFinished.Load() {
|
||||
require.Error(t, err)
|
||||
break
|
||||
}
|
||||
require.NoError(t, err)
|
||||
_, body, err := ws.ReadMessage()
|
||||
if isFinished.Load() {
|
||||
|
|
Loading…
Reference in a new issue