mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 23:42:23 +00:00
Merge pull request #3377 from nspcc-dev/test-subclient
rpcsrv: fix TestSubClientWaitWithMissedEvent
This commit is contained in:
commit
00ac38b545
1 changed files with 9 additions and 2 deletions
|
@ -2051,9 +2051,14 @@ func testSubClientWaitWithMissedEvent(t *testing.T, local bool) {
|
||||||
tx := b1.Transactions[0]
|
tx := b1.Transactions[0]
|
||||||
|
|
||||||
rcvr := make(chan *state.AppExecResult)
|
rcvr := make(chan *state.AppExecResult)
|
||||||
|
errCh := make(chan error) // Error channel for goroutine errors
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
aer, err := act.Wait(tx.Hash(), tx.ValidUntilBlock, nil)
|
aer, err := act.Wait(tx.Hash(), tx.ValidUntilBlock, nil)
|
||||||
require.NoError(t, err)
|
if err != nil {
|
||||||
|
errCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
rcvr <- aer
|
rcvr <- aer
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -2064,7 +2069,7 @@ func testSubClientWaitWithMissedEvent(t *testing.T, local bool) {
|
||||||
rpcSrv.subsLock.Lock()
|
rpcSrv.subsLock.Lock()
|
||||||
defer rpcSrv.subsLock.Unlock()
|
defer rpcSrv.subsLock.Unlock()
|
||||||
return len(rpcSrv.subscribers) == 1
|
return len(rpcSrv.subscribers) == 1
|
||||||
}, time.Second, 100*time.Millisecond)
|
}, 2*time.Second, 100*time.Millisecond)
|
||||||
|
|
||||||
rpcSrv.subsLock.Lock()
|
rpcSrv.subsLock.Lock()
|
||||||
// Suppress normal event delivery.
|
// Suppress normal event delivery.
|
||||||
|
@ -2101,6 +2106,8 @@ waitloop:
|
||||||
require.Equal(t, trigger.Application, aer.Trigger)
|
require.Equal(t, trigger.Application, aer.Trigger)
|
||||||
require.Equal(t, vmstate.Halt, aer.VMState)
|
require.Equal(t, vmstate.Halt, aer.VMState)
|
||||||
break waitloop
|
break waitloop
|
||||||
|
case err := <-errCh:
|
||||||
|
t.Fatalf("Error waiting for transaction: %v", err)
|
||||||
case <-time.NewTimer(chain.GetConfig().TimePerBlock).C:
|
case <-time.NewTimer(chain.GetConfig().TimePerBlock).C:
|
||||||
t.Fatal("transaction failed to be awaited")
|
t.Fatal("transaction failed to be awaited")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue