veyron/tools/naming: get simulator scripts going again, fix a bug in sort_endpoints.go

- bit rot took out the simulator scripts
- there was a bug in the sort_endpoints code that didn't correctly
  sort endpoints by protocol in the absence of a specific ordering.

Change-Id: I17a4c082f1852baacef2155e3f620bf21cb5a1c4
diff --git a/runtimes/google/ipc/sort_internal_test.go b/runtimes/google/ipc/sort_internal_test.go
index 1995c16..512014e 100644
--- a/runtimes/google/ipc/sort_internal_test.go
+++ b/runtimes/google/ipc/sort_internal_test.go
@@ -82,6 +82,39 @@
 		t.Errorf("got: %v, want %v", got, want)
 	}
 
+	// Everything, since we didn't specify a protocol, but ordered by
+	// the internal metric - see defaultPreferredProtocolOrder.
+	// The order will be the default preferred order for protocols, the
+	// original ordering within each protocol, with protocols that
+	// are not in the default ordering list at the end.
+	got, err = filterAndOrderServers(servers, nil)
+	if err != nil {
+		t.Fatalf("unexpected error: %s", err)
+	}
+
+	want = []string{
+		"/@3@tcp4@127.0.0.1@00000000000000000000000000000000@@@m@@",
+		"/@3@tcp4@127.0.0.2@00000000000000000000000000000000@@@m@@",
+		"/@3@tcp@127.0.0.3@00000000000000000000000000000000@@@m@@",
+		"/@3@tcp@127.0.0.4@00000000000000000000000000000000@@@m@@",
+		"/@3@tcp6@127.0.0.7@00000000000000000000000000000000@@@m@@",
+		"/@3@tcp6@127.0.0.8@00000000000000000000000000000000@@@m@@",
+		"/@3@foobar@127.0.0.10@00000000000000000000000000000000@@@m@@",
+		"/@3@foobar@127.0.0.11@00000000000000000000000000000000@@@m@@",
+	}
+	if !reflect.DeepEqual(got, want) {
+		t.Errorf("got: %v, want %v", got, want)
+	}
+
+	got, err = filterAndOrderServers(servers, []string{})
+	if err != nil {
+		t.Fatalf("unexpected error: %s", err)
+	}
+
+	if !reflect.DeepEqual(got, want) {
+		t.Errorf("got: %v, want %v", got, want)
+	}
+
 	got, err = filterAndOrderServers(servers, []string{"tcp"})
 	if err != nil {
 		t.Fatalf("unexpected error: %s", err)
@@ -94,28 +127,6 @@
 		"/@3@tcp@127.0.0.4@00000000000000000000000000000000@@@m@@",
 	}
 
-	// Everything, since we didn't specify a protocol
-	got, err = filterAndOrderServers(servers, []string{})
-	if err != nil {
-		t.Fatalf("unexpected error: %s", err)
-	}
-	// The order will be the default preferred order for protocols, the
-	// original ordering within each protocol, with protocols that
-	// are not in the default ordering list at the end.
-	want = []string{
-		"/@3@tcp@127.0.0.3@00000000000000000000000000000000@@@m@@",
-		"/@3@tcp@127.0.0.4@00000000000000000000000000000000@@@m@@",
-		"/@3@tcp4@127.0.0.1@00000000000000000000000000000000@@@m@@",
-		"/@3@tcp4@127.0.0.2@00000000000000000000000000000000@@@m@@",
-		"/@3@tcp6@127.0.0.7@00000000000000000000000000000000@@@m@@",
-		"/@3@tcp6@127.0.0.8@00000000000000000000000000000000@@@m@@",
-		"/@3@foobar@127.0.0.10@00000000000000000000000000000000@@@m@@",
-		"/@3@foobar@127.0.0.11@00000000000000000000000000000000@@@m@@",
-	}
-	if !reflect.DeepEqual(got, want) {
-		t.Errorf("got: %v, want %v", got, want)
-	}
-
 	// Ask for all protocols, with no ordering, except for locality
 	servers = []string{}
 	for _, a := range []string{"74.125.69.139", "127.0.0.3", "127.0.0.1", "192.168.1.10", "74.125.142.83"} {