1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
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)
}
}
|