mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
74101612ce
* first working implementation * assertions tests * adds to requires * merges assert and require tests into a single suite * gazelle * Merge branch 'merge-assert-require-tests' into assert-logs-contains-move-to-assertions * gazelle * updates references * fixes build issue * Merge branch 'master' into assert-logs-contains-move-to-assertions * Merge refs/heads/master into assert-logs-contains-move-to-assertions * Merge branch 'master' into assert-logs-contains-move-to-assertions * fixes build issue * Merge branch 'assert-logs-contains-move-to-assertions' of github.com:prysmaticlabs/prysm into assert-logs-contains-move-to-assertions * Merge refs/heads/master into assert-logs-contains-move-to-assertions * Merge refs/heads/master into assert-logs-contains-move-to-assertions
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package p2p
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
logTest "github.com/sirupsen/logrus/hooks/test"
|
|
)
|
|
|
|
// Test `verifyConnectivity` function by trying to connect to google.com (successfully)
|
|
// and then by connecting to an unreachable IP and ensuring that a log is emitted
|
|
func TestVerifyConnectivity(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
cases := []struct {
|
|
address string
|
|
port uint
|
|
expectedConnectivity bool
|
|
name string
|
|
}{
|
|
{"142.250.68.46", 80, true, "Dialing a reachable IP: 142.250.68.46:80"}, // google.com
|
|
{"123.123.123.123", 19000, false, "Dialing an unreachable IP: 123.123.123.123:19000"},
|
|
}
|
|
for _, tc := range cases {
|
|
t.Run(fmt.Sprintf(tc.name),
|
|
func(t *testing.T) {
|
|
verifyConnectivity(tc.address, tc.port, "tcp")
|
|
logMessage := "IP address is not accessible"
|
|
if tc.expectedConnectivity {
|
|
require.LogsDoNotContain(t, hook, logMessage)
|
|
} else {
|
|
require.LogsContain(t, hook, logMessage)
|
|
}
|
|
})
|
|
}
|
|
}
|