mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-28 19:31:34 +00:00
rpcsrv: fix TestSubClientWaitWithMissedEvent
Add error channel to prevent data race in the test. Increase waiting interval for subscriptions awaiting up to 2 seconds. Failing is caused by slow subscriptions. Close #2958 Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io> Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
parent
86f16bb931
commit
56e6119f78
1 changed files with 9 additions and 2 deletions
|
@ -2051,9 +2051,14 @@ func testSubClientWaitWithMissedEvent(t *testing.T, local bool) {
|
|||
tx := b1.Transactions[0]
|
||||
|
||||
rcvr := make(chan *state.AppExecResult)
|
||||
errCh := make(chan error) // Error channel for goroutine errors
|
||||
|
||||
go func() {
|
||||
aer, err := act.Wait(tx.Hash(), tx.ValidUntilBlock, nil)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
errCh <- err
|
||||
return
|
||||
}
|
||||
rcvr <- aer
|
||||
}()
|
||||
|
||||
|
@ -2064,7 +2069,7 @@ func testSubClientWaitWithMissedEvent(t *testing.T, local bool) {
|
|||
rpcSrv.subsLock.Lock()
|
||||
defer rpcSrv.subsLock.Unlock()
|
||||
return len(rpcSrv.subscribers) == 1
|
||||
}, time.Second, 100*time.Millisecond)
|
||||
}, 2*time.Second, 100*time.Millisecond)
|
||||
|
||||
rpcSrv.subsLock.Lock()
|
||||
// Suppress normal event delivery.
|
||||
|
@ -2101,6 +2106,8 @@ waitloop:
|
|||
require.Equal(t, trigger.Application, aer.Trigger)
|
||||
require.Equal(t, vmstate.Halt, aer.VMState)
|
||||
break waitloop
|
||||
case err := <-errCh:
|
||||
t.Fatalf("Error waiting for transaction: %v", err)
|
||||
case <-time.NewTimer(chain.GetConfig().TimePerBlock).C:
|
||||
t.Fatal("transaction failed to be awaited")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue