github.com/koko1123/flow-go-1@v0.29.6/network/p2p/conduit/conduit_test.go (about) 1 package conduit_test 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/hashicorp/go-multierror" 8 "github.com/stretchr/testify/require" 9 10 "github.com/koko1123/flow-go-1/network" 11 ) 12 13 func TestWrappedByMultiError(t *testing.T) { 14 var errs *multierror.Error 15 16 err := network.NewPeerUnreachableError(fmt.Errorf("unreachable")) 17 errs = multierror.Append(errs, fmt.Errorf("could not send req: %w", err)) 18 19 require.True(t, network.IsPeerUnreachableError(err)) // Pass 20 require.True(t, network.IsPeerUnreachableError(errs.WrappedErrors()[0])) // Pass 21 } 22 23 func TestNestedWrappedMultiError(t *testing.T) { 24 var innerError *multierror.Error 25 innerError = multierror.Append(innerError, fmt.Errorf("inner error")) 26 innerError = multierror.Append(innerError, fmt.Errorf("inner error")) 27 innerError = multierror.Append(innerError, fmt.Errorf("inner error")) 28 29 err := network.NewPeerUnreachableError(fmt.Errorf("inner: %w", innerError)) 30 require.True(t, network.IsPeerUnreachableError(err)) 31 var outerError *multierror.Error 32 outerError = multierror.Append(outerError, fmt.Errorf("inner: %w", err)) 33 require.True(t, network.AllPeerUnreachableError(outerError.WrappedErrors()...)) 34 }