File: tcp_transport_test.go

package info (click to toggle)
golang-github-hashicorp-raft 0.0~git20160317.0.3359516-1~bpo8+1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 428 kB
  • sloc: makefile: 16
file content (24 lines) | stat: -rw-r--r-- 569 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package raft

import (
	"net"
	"testing"
)

func TestTCPTransport_BadAddr(t *testing.T) {
	_, err := NewTCPTransportWithLogger("0.0.0.0:0", nil, 1, 0, newTestLogger(t))
	if err != errNotAdvertisable {
		t.Fatalf("err: %v", err)
	}
}

func TestTCPTransport_WithAdvertise(t *testing.T) {
	addr := &net.TCPAddr{IP: []byte{127, 0, 0, 1}, Port: 12345}
	trans, err := NewTCPTransportWithLogger("0.0.0.0:0", addr, 1, 0, newTestLogger(t))
	if err != nil {
		t.Fatalf("err: %v", err)
	}
	if trans.LocalAddr() != "127.0.0.1:12345" {
		t.Fatalf("bad: %v", trans.LocalAddr())
	}
}