Stubbing OutboundVersionNegotiationTest

Actually committing enable features work!
This commit is contained in:
Sarah Jamie Lewis 2018-01-02 09:23:20 -08:00
parent 6d449e230f
commit 049a0ea15f
7 changed files with 78 additions and 33 deletions

View File

@ -8,8 +8,8 @@ import (
"github.com/s-rah/go-ricochet/identity"
"log"
"net"
"time"
"sync"
"time"
)
// RicochetApplication bundles many useful constructs that are

View File

@ -36,7 +36,7 @@ func (ach *AutoConnectionHandler) OnClosed(err error) {
func (ach *AutoConnectionHandler) GetSupportedChannelTypes() []string {
supported := []string{}
for k,_ := range ach.handlerMap {
for k := range ach.handlerMap {
supported = append(supported, k)
}
return supported

View File

@ -1,10 +1,10 @@
package goricochet
import (
"github.com/s-rah/go-ricochet/utils"
"io"
"net"
"testing"
"github.com/s-rah/go-ricochet/utils"
)
func TestBadProtcolLength(t *testing.T) {

View File

@ -0,0 +1,31 @@
package goricochet
import (
"github.com/s-rah/go-ricochet/utils"
"net"
"testing"
"time"
)
func TestInvalidResponse(t *testing.T) {
go func() {
ln, _ := net.Listen("tcp", "127.0.0.1:12000")
conn, _ := ln.Accept()
b := make([]byte, 4)
n, err := conn.Read(b)
if n == 4 && err == nil {
conn.Write([]byte{0xFF})
}
conn.Close()
}()
time.Sleep(time.Second * 1)
conn, err := net.Dial("tcp", ":12000")
if err != nil {
t.Fatal(err)
}
defer conn.Close()
_, err = NegotiateVersionOutbound(conn, "")
if err != utils.VersionNegotiationFailed {
t.Errorf("Expected VersionNegotiationFailed got %v", err)
}
}

View File

@ -10,7 +10,7 @@ other for outbound connections.
## Version Negotiation
File: [ricochet_test.go](./inbound_version_negotiation_test.go)
File: [inbound_version_negotiation_test.go](./inbound_version_negotiation_test.go)
### Invalid Protocol
@ -33,3 +33,17 @@ Assuming the inbound listener receives a valid protocol message, and that messag
contains a known supported version. Then the connection should remain open.
# Outbound
File: [outbound_version_negotiation_test.go](./outbound_version_negotiation_test.go)
### No Compatible Version Found
If the outbound connection receives a response that does not match one of the versions
they sent out in their supporting list. Then then must close the connection `TestInvalidResponse`
### Successful Version Negotiation
Assuming the outbound connection receives a valid protocol message, and that message
contains a known supported version. Then the connection should remain open.