p2p/conn: add a test for MakeSecretConnection (#4829)

Refs #4154
This commit is contained in:
Anton Kaliaev
2020-06-03 16:28:23 +04:00
committed by GitHub
parent c8483531d8
commit 994912211c
4 changed files with 353 additions and 88 deletions
+5 -1
View File
@@ -2,6 +2,7 @@ package async
import (
"fmt"
"runtime"
"sync/atomic"
)
@@ -143,7 +144,10 @@ func Parallel(tasks ...Task) (trs *TaskResultSet, ok bool) {
if pnk := recover(); pnk != nil {
atomic.AddInt32(numPanics, 1)
// Send panic to taskResultCh.
taskResultCh <- TaskResult{nil, fmt.Errorf("panic in task %v", pnk)}
const size = 64 << 10
buf := make([]byte, size)
buf = buf[:runtime.Stack(buf, false)]
taskResultCh <- TaskResult{nil, fmt.Errorf("panic in task %v : %s", pnk, buf)}
// Closing taskResultCh lets trs.Wait() work.
close(taskResultCh)
// Decrement waitgroup.
+1 -1
View File
@@ -139,7 +139,7 @@ func checkResult(t *testing.T, taskResultSet *TaskResultSet, index int,
case err != nil:
assert.Equal(t, err.Error(), taskResult.Error.Error(), taskName)
case pnk != nil:
assert.Equal(t, pnk, taskResult.Error.Error(), taskName)
assert.Contains(t, taskResult.Error.Error(), pnk, taskName)
default:
assert.Nil(t, taskResult.Error, taskName)
}