mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
Update nat_test.go
This commit is contained in:
parent
0b542721e9
commit
39101e314f
1 changed files with 20 additions and 1 deletions
|
|
@ -18,11 +18,12 @@ package nat
|
|||
|
||||
import (
|
||||
"net"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// This test checks that autodisc doesn't hang and returns
|
||||
// This test ensures that autodisc doesn't hang and returns
|
||||
// consistent results when multiple goroutines call its methods
|
||||
// concurrently.
|
||||
func TestAutoDiscRace(t *testing.T) {
|
||||
|
|
@ -61,3 +62,21 @@ func TestAutoDiscRace(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtIPInKubernetes(t *testing.T) {
|
||||
// Setting up the test environment
|
||||
os.Setenv("KUBERNETES_SERVICE_HOST", "10.0.0.1")
|
||||
defer os.Unsetenv("KUBERNETES_SERVICE_HOST")
|
||||
|
||||
testIP := net.ParseIP("192.0.2.1")
|
||||
extIP := ExtIP(testIP)
|
||||
|
||||
// Verify that the IP is returned unchanged in Kubernetes
|
||||
ip, err := extIP.ExternalIP()
|
||||
if err != nil {
|
||||
t.Fatalf("ExternalIP failed: %v", err)
|
||||
}
|
||||
if !ip.Equal(testIP) {
|
||||
t.Errorf("wrong IP: got %v, want %v", ip, testIP)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue