[tor-commits] [pluggable-transports/snowflake] 18/31: Add test for proxy poll with Relay URL

gitolite role git at cupani.torproject.org
Thu Jun 16 17:04:05 UTC 2022


This is an automated email from the git hooks/post-receive script.

shelikhoo pushed a commit to branch main
in repository pluggable-transports/snowflake.

commit 1b48ee14f47f6b5ac4b061c2bd50aaf58b2fff4f
Author: Shelikhoo <xiaokangwang at outlook.com>
AuthorDate: Mon May 2 13:24:39 2022 +0100

    Add test for proxy poll with Relay URL
---
 common/messages/messages_test.go | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/common/messages/messages_test.go b/common/messages/messages_test.go
index 017e959..2fc76df 100644
--- a/common/messages/messages_test.go
+++ b/common/messages/messages_test.go
@@ -194,6 +194,34 @@ func TestEncodeProxyPollResponse(t *testing.T) {
 		So(err, ShouldEqual, nil)
 	})
 }
+
+func TestEncodeProxyPollResponseWithProxyURL(t *testing.T) {
+	Convey("Context", t, func() {
+		b, err := EncodePollResponseWithRelayURL("fake offer", true, "restricted", "wss://test/", "")
+		So(err, ShouldBeNil)
+		offer, natType, err := DecodePollResponse(b)
+		So(err, ShouldNotBeNil)
+
+		offer, natType, relay, err := DecodePollResponseWithRelayURL(b)
+		So(offer, ShouldEqual, "fake offer")
+		So(natType, ShouldEqual, "restricted")
+		So(relay, ShouldEqual, "wss://test/")
+		So(err, ShouldBeNil)
+
+		b, err = EncodePollResponse("", false, "unknown")
+		So(err, ShouldBeNil)
+		offer, natType, relay, err = DecodePollResponseWithRelayURL(b)
+		So(offer, ShouldEqual, "")
+		So(natType, ShouldEqual, "unknown")
+		So(err, ShouldBeNil)
+
+		b, err = EncodePollResponseWithRelayURL("fake offer", false, "restricted", "wss://test/", "test error reason")
+		So(err, ShouldBeNil)
+		offer, natType, relay, err = DecodePollResponseWithRelayURL(b)
+		So(err, ShouldNotBeNil)
+		So(err.Error(), ShouldContainSubstring, "test error reason")
+	})
+}
 func TestDecodeProxyAnswerRequest(t *testing.T) {
 	Convey("Context", t, func() {
 		for _, test := range []struct {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list