mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
588dea83b7
* test coverage and updates to config twiddlers * LoadChainConfigFile error if SetActive conflicts * lint * wip working around test issues * more fixes, mass test updates * lint * linting * thanks deepsource! * fix undeclared vars * fixing more undefined * fix a bug, make a bug, repeat * gaz * use stock mainnet in case fork schedule matters * remove unused KnownConfigs * post-merge cleanup * eliminating OverrideBeaconConfig outside tests * more cleanup of OverrideBeaconConfig outside tests * config for interop w/ genesis gen support * improve var name * API on package instead of exported value * cleanup remainders of "registry" naming * Nishant feedback * add ropstein to configset * lint * lint #2 * ✂️ * revert accidental commented line * check if active is nil (replace called on empty) * Nishant feedback * replace OverrideBeaconConfig call * update interop instructions w/ new flag * don't let interop replace config set via cli flags Co-authored-by: kasey <kasey@users.noreply.github.com>
63 lines
1.8 KiB
Go
63 lines
1.8 KiB
Go
package p2p
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/ethereum/go-ethereum/crypto"
|
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
|
"github.com/prysmaticlabs/prysm/config/params"
|
|
"github.com/prysmaticlabs/prysm/testing/assert"
|
|
"github.com/prysmaticlabs/prysm/testing/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) {
|
|
params.SetupTestConfigCleanup(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)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestSerializeENR(t *testing.T) {
|
|
params.SetupTestConfigCleanup(t)
|
|
t.Run("Ok", func(t *testing.T) {
|
|
key, err := crypto.GenerateKey()
|
|
require.NoError(t, err)
|
|
db, err := enode.OpenDB("")
|
|
require.NoError(t, err)
|
|
lNode := enode.NewLocalNode(db, key)
|
|
record := lNode.Node().Record()
|
|
s, err := SerializeENR(record)
|
|
require.NoError(t, err)
|
|
assert.NotEqual(t, "", s)
|
|
})
|
|
|
|
t.Run("Nil record", func(t *testing.T) {
|
|
_, err := SerializeENR(nil)
|
|
require.NotNil(t, err)
|
|
assert.ErrorContains(t, "could not serialize nil record", err)
|
|
})
|
|
}
|