mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
Use ShouldBeNil to check for nil values
This commit is contained in:
parent
e45e8e555b
commit
3a050c6bb3
3 changed files with 26 additions and 26 deletions
|
@ -553,7 +553,7 @@ func TestInvalidGeoipFile(t *testing.T) {
|
|||
log.Printf("loading geo ip databases returned error: %v", err)
|
||||
}
|
||||
ctx.metrics.UpdateCountryStats("127.0.0.1", "", NATUnrestricted)
|
||||
So(ctx.metrics.geoipdb, ShouldEqual, nil)
|
||||
So(ctx.metrics.geoipdb, ShouldBeNil)
|
||||
|
||||
})
|
||||
}
|
||||
|
@ -566,7 +566,7 @@ func TestMetrics(t *testing.T) {
|
|||
i := &IPC{ctx}
|
||||
|
||||
err := ctx.metrics.LoadGeoipDatabases("test_geoip", "test_geoip6")
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
//Test addition of proxy polls
|
||||
Convey("for proxy polls", func() {
|
||||
|
|
|
@ -123,13 +123,13 @@ func TestDecodeProxyPollRequest(t *testing.T) {
|
|||
func TestEncodeProxyPollRequests(t *testing.T) {
|
||||
Convey("Context", t, func() {
|
||||
b, err := EncodeProxyPollRequest("ymbcCMto7KHNGYlp", "standalone", "unknown", 16)
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
sid, proxyType, natType, clients, err := DecodeProxyPollRequest(b)
|
||||
So(sid, ShouldEqual, "ymbcCMto7KHNGYlp")
|
||||
So(proxyType, ShouldEqual, "standalone")
|
||||
So(natType, ShouldEqual, "unknown")
|
||||
So(clients, ShouldEqual, 16)
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -180,18 +180,18 @@ func TestDecodeProxyPollResponse(t *testing.T) {
|
|||
func TestEncodeProxyPollResponse(t *testing.T) {
|
||||
Convey("Context", t, func() {
|
||||
b, err := EncodePollResponse("fake offer", true, "restricted")
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
offer, natType, err := DecodePollResponse(b)
|
||||
So(offer, ShouldEqual, "fake offer")
|
||||
So(natType, ShouldEqual, "restricted")
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
b, err = EncodePollResponse("", false, "unknown")
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
offer, natType, err = DecodePollResponse(b)
|
||||
So(offer, ShouldEqual, "")
|
||||
So(natType, ShouldEqual, "unknown")
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -267,11 +267,11 @@ func TestDecodeProxyAnswerRequest(t *testing.T) {
|
|||
func TestEncodeProxyAnswerRequest(t *testing.T) {
|
||||
Convey("Context", t, func() {
|
||||
b, err := EncodeAnswerRequest("test answer", "test sid")
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
answer, sid, err := DecodeAnswerRequest(b)
|
||||
So(answer, ShouldEqual, "test answer")
|
||||
So(sid, ShouldEqual, "test sid")
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -309,16 +309,16 @@ func TestDecodeProxyAnswerResponse(t *testing.T) {
|
|||
func TestEncodeProxyAnswerResponse(t *testing.T) {
|
||||
Convey("Context", t, func() {
|
||||
b, err := EncodeAnswerResponse(true)
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
success, err := DecodeAnswerResponse(b)
|
||||
So(success, ShouldEqual, true)
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
b, err = EncodeAnswerResponse(false)
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
success, err = DecodeAnswerResponse(b)
|
||||
So(success, ShouldEqual, false)
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,7 @@ func TestEncodeClientPollRequests(t *testing.T) {
|
|||
Fingerprint: test.fingerprint,
|
||||
}
|
||||
b, err := req1.EncodeClientPollRequest()
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
req2, err := DecodeClientPollRequest(b)
|
||||
So(err, ShouldHaveSameTypeAs, test.err)
|
||||
if test.err == nil {
|
||||
|
@ -455,18 +455,18 @@ func TestEncodeClientPollResponse(t *testing.T) {
|
|||
Answer: "fake answer",
|
||||
}
|
||||
b, err := resp1.EncodePollResponse()
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
resp2, err := DecodeClientPollResponse(b)
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
So(resp1, ShouldResemble, resp2)
|
||||
|
||||
resp1 = &ClientPollResponse{
|
||||
Error: "failed",
|
||||
}
|
||||
b, err = resp1.EncodePollResponse()
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
resp2, err = DecodeClientPollResponse(b)
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
So(resp1, ShouldResemble, resp2)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ func TestBrokerInteractions(t *testing.T) {
|
|||
Convey("Proxy connections to broker", t, func() {
|
||||
var err error
|
||||
broker, err = newSignalingServer("localhost", false)
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
tokens = newTokens(0)
|
||||
|
||||
//Mock peerConnection
|
||||
|
@ -359,7 +359,7 @@ func TestBrokerInteractions(t *testing.T) {
|
|||
var err error
|
||||
|
||||
b, err := messages.EncodePollResponse(sampleOffer, true, "unknown")
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
broker.transport = &MockTransport{
|
||||
http.StatusOK,
|
||||
b,
|
||||
|
@ -373,7 +373,7 @@ func TestBrokerInteractions(t *testing.T) {
|
|||
var err error
|
||||
|
||||
b := []byte("test")
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
broker.transport = &MockTransport{
|
||||
http.StatusOK,
|
||||
b,
|
||||
|
@ -386,17 +386,17 @@ func TestBrokerInteractions(t *testing.T) {
|
|||
var err error
|
||||
|
||||
b, err := messages.EncodeAnswerResponse(true)
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
broker.transport = &MockTransport{
|
||||
http.StatusOK,
|
||||
b,
|
||||
}
|
||||
|
||||
err = broker.sendAnswer(sampleAnswer, pc)
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
b, err = messages.EncodeAnswerResponse(false)
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
broker.transport = &MockTransport{
|
||||
http.StatusOK,
|
||||
b,
|
||||
|
@ -486,7 +486,7 @@ func TestUtilityFuncs(t *testing.T) {
|
|||
bytes := make([]byte, 6)
|
||||
n, err := c2.Read(bytes)
|
||||
So(n, ShouldEqual, 6)
|
||||
So(err, ShouldEqual, nil)
|
||||
So(err, ShouldBeNil)
|
||||
So(bytes, ShouldResemble, []byte("Hello!"))
|
||||
s1.Close()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue