2019-10-04 22:46:49 +00:00
|
|
|
package iputils_test
|
2019-01-11 01:08:22 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"regexp"
|
|
|
|
"testing"
|
2019-10-04 22:46:49 +00:00
|
|
|
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/iputils"
|
2020-07-19 21:08:29 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
2019-01-11 01:08:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestExternalIPv4(t *testing.T) {
|
|
|
|
// Regular expression format for IPv4
|
|
|
|
IPv4Format := `\.\d{1,3}\.\d{1,3}\b`
|
2019-10-04 22:46:49 +00:00
|
|
|
test, err := iputils.ExternalIPv4()
|
2020-07-19 21:08:29 +00:00
|
|
|
require.NoError(t, err)
|
2019-01-11 01:08:22 +00:00
|
|
|
|
|
|
|
valid := regexp.MustCompile(IPv4Format)
|
2020-07-19 21:08:29 +00:00
|
|
|
assert.Equal(t, true, valid.MatchString(test))
|
2019-01-11 01:08:22 +00:00
|
|
|
}
|