Skip to content

Commit

Permalink
Fix beacon test localhost resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
KaloyanTanev committed Apr 29, 2024
1 parent dc6c55a commit fcb01fd
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions cmd/testbeacon_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ import (
func TestBeaconTest(t *testing.T) {
port1 := testutil.GetFreePort(t)
endpoint1 := fmt.Sprintf("http://localhost:%v", port1)
ip1 := fmt.Sprintf("127.0.0.1:%v", port1)
port2 := testutil.GetFreePort(t)
endpoint2 := fmt.Sprintf("http://localhost:%v", port2)
ip2 := fmt.Sprintf("127.0.0.1:%v", port2)

mockedBeaconNode := StartHealthyMockedBeaconNode(t)
defer mockedBeaconNode.Close()
Expand Down Expand Up @@ -76,16 +74,16 @@ func TestBeaconTest(t *testing.T) {
expected: testCategoryResult{
Targets: map[string][]testResult{
endpoint1: {
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`dial tcp %v: connect: connection refused`, ip1))}},
{Name: "pingMeasure", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`dial tcp %v: connect: connection refused`, ip1))}},
{Name: "isSynced", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`Get "%v/eth/v1/node/syncing": dial tcp %v: connect: connection refused`, endpoint1, ip1))}},
{Name: "peerCount", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`Get "%v/eth/v1/node/peers?state=connected": dial tcp %v: connect: connection refused`, endpoint1, ip1))}},
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port1))}},
{Name: "pingMeasure", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port1))}},
{Name: "isSynced", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port1))}},
{Name: "peerCount", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port1))}},
},
endpoint2: {
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`dial tcp %v: connect: connection refused`, ip2))}},
{Name: "pingMeasure", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`dial tcp %v: connect: connection refused`, ip2))}},
{Name: "isSynced", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`Get "%v/eth/v1/node/syncing": dial tcp %v: connect: connection refused`, endpoint2, ip2))}},
{Name: "peerCount", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`Get "%v/eth/v1/node/peers?state=connected": dial tcp %v: connect: connection refused`, endpoint2, ip2))}},
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port2))}},
{Name: "pingMeasure", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port2))}},
{Name: "isSynced", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port2))}},
{Name: "peerCount", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port2))}},
},
},
},
Expand Down Expand Up @@ -128,16 +126,16 @@ func TestBeaconTest(t *testing.T) {
expected: testCategoryResult{
Targets: map[string][]testResult{
endpoint1: {
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`dial tcp %v: connect: connection refused`, ip1))}},
{Name: "pingMeasure", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`dial tcp %v: connect: connection refused`, ip1))}},
{Name: "isSynced", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`Get "%v/eth/v1/node/syncing": dial tcp %v: connect: connection refused`, endpoint1, ip1))}},
{Name: "peerCount", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`Get "%v/eth/v1/node/peers?state=connected": dial tcp %v: connect: connection refused`, endpoint1, ip1))}},
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port1))}},
{Name: "pingMeasure", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port1))}},
{Name: "isSynced", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port1))}},
{Name: "peerCount", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port1))}},
},
endpoint2: {
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`dial tcp %v: connect: connection refused`, ip2))}},
{Name: "pingMeasure", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`dial tcp %v: connect: connection refused`, ip2))}},
{Name: "isSynced", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`Get "%v/eth/v1/node/syncing": dial tcp %v: connect: connection refused`, endpoint2, ip2))}},
{Name: "peerCount", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`Get "%v/eth/v1/node/peers?state=connected": dial tcp %v: connect: connection refused`, endpoint2, ip2))}},
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port2))}},
{Name: "pingMeasure", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port2))}},
{Name: "isSynced", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port2))}},
{Name: "peerCount", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port2))}},
},
},
},
Expand Down Expand Up @@ -171,10 +169,10 @@ func TestBeaconTest(t *testing.T) {
expected: testCategoryResult{
Targets: map[string][]testResult{
endpoint1: {
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`dial tcp %v: connect: connection refused`, ip1))}},
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port1))}},
},
endpoint2: {
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`dial tcp %v: connect: connection refused`, ip2))}},
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port2))}},
},
},
},
Expand All @@ -194,16 +192,16 @@ func TestBeaconTest(t *testing.T) {
expected: testCategoryResult{
Targets: map[string][]testResult{
endpoint1: {
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`dial tcp %v: connect: connection refused`, ip1))}},
{Name: "pingMeasure", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`dial tcp %v: connect: connection refused`, ip1))}},
{Name: "isSynced", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`Get "%v/eth/v1/node/syncing": dial tcp %v: connect: connection refused`, endpoint1, ip1))}},
{Name: "peerCount", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`Get "%v/eth/v1/node/peers?state=connected": dial tcp %v: connect: connection refused`, endpoint1, ip1))}},
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port1))}},
{Name: "pingMeasure", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port1))}},
{Name: "isSynced", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port1))}},
{Name: "peerCount", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port1))}},
},
endpoint2: {
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`dial tcp %v: connect: connection refused`, ip2))}},
{Name: "pingMeasure", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`dial tcp %v: connect: connection refused`, ip2))}},
{Name: "isSynced", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`Get "%v/eth/v1/node/syncing": dial tcp %v: connect: connection refused`, endpoint2, ip2))}},
{Name: "peerCount", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`Get "%v/eth/v1/node/peers?state=connected": dial tcp %v: connect: connection refused`, endpoint2, ip2))}},
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port2))}},
{Name: "pingMeasure", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port2))}},
{Name: "isSynced", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port2))}},
{Name: "peerCount", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: testResultError{errors.New(fmt.Sprintf(`%v: connect: connection refused`, port2))}},
},
},
Score: categoryScoreC,
Expand Down

0 comments on commit fcb01fd

Please sign in to comment.