From ae840dca6f707b50ba26a88d2827ad9bb9adbe86 Mon Sep 17 00:00:00 2001 From: Loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com> Date: Sun, 4 Apr 2021 09:33:38 +0800 Subject: [PATCH] Chore: refine test (#855) copy from branch v5 --- proxy/vless/encoding/encoding_test.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/proxy/vless/encoding/encoding_test.go b/proxy/vless/encoding/encoding_test.go index 7463a001e..4276dc6e1 100644 --- a/proxy/vless/encoding/encoding_test.go +++ b/proxy/vless/encoding/encoding_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "google.golang.org/protobuf/testing/protocmp" "github.com/v2fly/v2ray-core/v4/common" "github.com/v2fly/v2ray-core/v4/common/buf" @@ -53,10 +54,7 @@ func TestRequestSerialization(t *testing.T) { t.Error(r) } - addonsComparer := func(x, y *Addons) bool { - return (x.Flow == y.Flow) && (cmp.Equal(x.Seed, y.Seed)) - } - if r := cmp.Diff(actualAddons, expectedAddons, cmp.Comparer(addonsComparer)); r != "" { + if r := cmp.Diff(actualAddons, expectedAddons, protocmp.Transform()); r != "" { t.Error(r) } } @@ -125,10 +123,7 @@ func TestMuxRequest(t *testing.T) { t.Error(r) } - addonsComparer := func(x, y *Addons) bool { - return (x.Flow == y.Flow) && (cmp.Equal(x.Seed, y.Seed)) - } - if r := cmp.Diff(actualAddons, expectedAddons, cmp.Comparer(addonsComparer)); r != "" { + if r := cmp.Diff(actualAddons, expectedAddons, protocmp.Transform()); r != "" { t.Error(r) } }