mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-24 22:32:15 +00:00
* init of (2/2) common errors * Remove instances of cmn.Error (2/2) - Replace usage of cmnError and errorWrap - ref #3862 Signed-off-by: Marko Baricevic <marbar3778@yahoo.com> * comment wording * simplify IsErrXXX functions * log panic along with stopping the MConnection
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package privval
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/tendermint/tendermint/crypto/ed25519"
|
|
)
|
|
|
|
func getDialerTestCases(t *testing.T) []dialerTestCase {
|
|
tcpAddr := GetFreeLocalhostAddrPort()
|
|
unixFilePath, err := testUnixAddr()
|
|
require.NoError(t, err)
|
|
unixAddr := fmt.Sprintf("unix://%s", unixFilePath)
|
|
|
|
return []dialerTestCase{
|
|
{
|
|
addr: tcpAddr,
|
|
dialer: DialTCPFn(tcpAddr, testTimeoutReadWrite, ed25519.GenPrivKey()),
|
|
},
|
|
{
|
|
addr: unixAddr,
|
|
dialer: DialUnixFn(unixFilePath),
|
|
},
|
|
}
|
|
}
|
|
|
|
func TestIsConnTimeoutForFundamentalTimeouts(t *testing.T) {
|
|
// Generate a networking timeout
|
|
tcpAddr := GetFreeLocalhostAddrPort()
|
|
dialer := DialTCPFn(tcpAddr, time.Millisecond, ed25519.GenPrivKey())
|
|
_, err := dialer()
|
|
assert.Error(t, err)
|
|
assert.True(t, IsConnTimeout(err))
|
|
}
|
|
|
|
func TestIsConnTimeoutForWrappedConnTimeouts(t *testing.T) {
|
|
tcpAddr := GetFreeLocalhostAddrPort()
|
|
dialer := DialTCPFn(tcpAddr, time.Millisecond, ed25519.GenPrivKey())
|
|
_, err := dialer()
|
|
assert.Error(t, err)
|
|
err = errors.Wrap(ErrConnectionTimeout, err.Error())
|
|
assert.True(t, IsConnTimeout(err))
|
|
}
|