func testDevLoop(t *testing.T, addr string) { s1, err := pair.NewSocket() if err != nil { t.Errorf("Failed to open S1: %v", err) return } defer s1.Close() s1.AddTransport(tcp.NewTransport()) s1.AddTransport(inproc.NewTransport()) s1.AddTransport(ipc.NewTransport()) s1.AddTransport(tlstcp.NewTransport()) s1.AddTransport(ws.NewTransport()) s1.AddTransport(wss.NewTransport()) options := make(map[string]interface{}) if strings.HasPrefix(addr, "wss://") || strings.HasPrefix(addr, "tls+tcp://") { options[mangos.OptionTLSConfig] = srvCfg } if err := s1.ListenOptions(addr, options); err != nil { t.Errorf("Failed listening to %s: %v", addr, err) return } if err := mangos.Device(s1, s1); err != nil { t.Errorf("Device failed: %v", err) return } RunTests(t, addr, deviceCaseClient()) }
// AddTransports adds all known transports to the given socket. func AddTransports(sock mangos.Socket) { sock.AddTransport(tcp.NewTransport()) sock.AddTransport(inproc.NewTransport()) sock.AddTransport(ipc.NewTransport()) sock.AddTransport(tlstcp.NewTransport()) sock.AddTransport(ws.NewTransport()) sock.AddTransport(wss.NewTransport()) }
func testDevChain(t *testing.T, addr1 string, addr2 string, addr3 string) { // This tests using multiple devices across a few transports. // It looks like this: addr1->addr2->addr3 <==> addr3->addr2->addr1 var err error s := make([]mangos.Socket, 5) for i := 0; i < 5; i++ { if s[i], err = pair.NewSocket(); err != nil { t.Errorf("Failed to open S1_1: %v", err) return } defer s[i].Close() s[i].AddTransport(tcp.NewTransport()) s[i].AddTransport(inproc.NewTransport()) s[i].AddTransport(tlstcp.NewTransport()) s[i].AddTransport(ipc.NewTransport()) s[i].AddTransport(ws.NewTransport()) } if err = s[0].Listen(addr1); err != nil { t.Errorf("s[0] Listen: %v", err) return } if err = s[1].Dial(addr2); err != nil { t.Errorf("s[1] Dial: %v", err) return } if err = s[2].Listen(addr2); err != nil { t.Errorf("s[2] Listen: %v", err) return } if err = s[3].Dial(addr3); err != nil { t.Errorf("s[3] Dial: %v", err) return } if err = s[4].Listen(addr3); err != nil { t.Errorf("s[4] Listen: %v", err) return } if err = mangos.Device(s[0], s[1]); err != nil { t.Errorf("s[0],s[1] Device: %v", err) return } if err = mangos.Device(s[2], s[3]); err != nil { t.Errorf("s[2],s[3] Device: %v", err) return } if err = mangos.Device(s[4], nil); err != nil { t.Errorf("s[4] Device: %v", err) return } RunTests(t, addr1, deviceCaseClient()) }
// NewTransport allocates a new wss:// transport. func NewTransport() mangos.Transport { w := &wssTran{w: ws.NewTransport()} return w }
func TestMaxRxWS(t *testing.T) { testMaxRx(t, AddrTestWS, ws.NewTransport()) }