From: Shengjing Zhu <zhsj@debian.org>
Date: Mon, 9 Nov 2020 20:00:54 +0800
Subject: Use proto.Equal to compare proto

new protoc-gen-go seems not exporting some fields, so upstream code is affected

Forwarded: not-needed
---
 app/router/command/command_test.go    | 12 ++++++------
 proxy/vless/encoding/encoding_test.go |  5 +++--
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/app/router/command/command_test.go b/app/router/command/command_test.go
index c933bca..0a4779f 100644
--- a/app/router/command/command_test.go
+++ b/app/router/command/command_test.go
@@ -6,8 +6,8 @@ import (
 	"time"
 
 	"github.com/golang/mock/gomock"
+	"github.com/golang/protobuf/proto"
 	"github.com/google/go-cmp/cmp"
-	"github.com/google/go-cmp/cmp/cmpopts"
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/test/bufconn"
 	"v2ray.com/core/app/router"
@@ -126,7 +126,7 @@ func TestServiceSubscribeRoutingStats(t *testing.T) {
 				if err != nil {
 					return err
 				}
-				if r := cmp.Diff(msg, tc, cmpopts.IgnoreUnexported(RoutingContext{})); r != "" {
+				if r := cmp.Diff(msg, tc, cmp.Comparer(proto.Equal)); r != "" {
 					t.Error(r)
 				}
 			}
@@ -173,7 +173,7 @@ func TestServiceSubscribeRoutingStats(t *testing.T) {
 					OutboundGroupTags: tc.OutboundGroupTags,
 					OutboundTag:       tc.OutboundTag,
 				}
-				if r := cmp.Diff(msg, stat, cmpopts.IgnoreUnexported(RoutingContext{})); r != "" {
+				if r := cmp.Diff(msg, stat, cmp.Comparer(proto.Equal)); r != "" {
 					t.Error(r)
 				}
 			}
@@ -291,7 +291,7 @@ func TestSerivceTestRoute(t *testing.T) {
 				if err != nil {
 					return err
 				}
-				if r := cmp.Diff(route, tc, cmpopts.IgnoreUnexported(RoutingContext{})); r != "" {
+				if r := cmp.Diff(route, tc, cmp.Comparer(proto.Equal)); r != "" {
 					t.Error(r)
 				}
 			}
@@ -322,13 +322,13 @@ func TestSerivceTestRoute(t *testing.T) {
 					OutboundGroupTags: tc.OutboundGroupTags,
 					OutboundTag:       tc.OutboundTag,
 				}
-				if r := cmp.Diff(route, stat, cmpopts.IgnoreUnexported(RoutingContext{})); r != "" {
+				if r := cmp.Diff(route, stat, cmp.Comparer(proto.Equal)); r != "" {
 					t.Error(r)
 				}
 				select { // Check that routing result has been published to statistics channel
 				case msg, received := <-sub:
 					if route, ok := msg.(routing.Route); received && ok {
-						if r := cmp.Diff(AsProtobufMessage(nil)(route), tc, cmpopts.IgnoreUnexported(RoutingContext{})); r != "" {
+						if r := cmp.Diff(AsProtobufMessage(nil)(route), tc, cmp.Comparer(proto.Equal)); r != "" {
 							t.Error(r)
 						}
 					} else {
diff --git a/proxy/vless/encoding/encoding_test.go b/proxy/vless/encoding/encoding_test.go
index 496112a..d038272 100644
--- a/proxy/vless/encoding/encoding_test.go
+++ b/proxy/vless/encoding/encoding_test.go
@@ -3,6 +3,7 @@ package encoding_test
 import (
 	"testing"
 
+	"github.com/golang/protobuf/proto"
 	"github.com/google/go-cmp/cmp"
 	"v2ray.com/core/common"
 	"v2ray.com/core/common/buf"
@@ -51,7 +52,7 @@ func TestRequestSerialization(t *testing.T) {
 	if r := cmp.Diff(actualRequest, expectedRequest, cmp.AllowUnexported(protocol.ID{})); r != "" {
 		t.Error(r)
 	}
-	if r := cmp.Diff(actualAddons, expectedAddons); r != "" {
+	if r := cmp.Diff(actualAddons, expectedAddons, cmp.Comparer(proto.Equal)); r != "" {
 		t.Error(r)
 	}
 }
@@ -119,7 +120,7 @@ func TestMuxRequest(t *testing.T) {
 	if r := cmp.Diff(actualRequest, expectedRequest, cmp.AllowUnexported(protocol.ID{})); r != "" {
 		t.Error(r)
 	}
-	if r := cmp.Diff(actualAddons, expectedAddons); r != "" {
+	if r := cmp.Diff(actualAddons, expectedAddons, cmp.Comparer(proto.Equal)); r != "" {
 		t.Error(r)
 	}
 }
