mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-23 10:05:17 +00:00
Fix unit test
This commit is contained in:
parent
7afa23be4c
commit
a9ec3877b5
@ -39,22 +39,30 @@ func CreateAndConnectTwo(t testing.TB, verbose bool) (nodeA *Core, nodeB *Core)
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger := GetLoggerWithPrefix("", false)
|
logger := GetLoggerWithPrefix("", false)
|
||||||
|
logger.EnableLevel("debug")
|
||||||
|
|
||||||
if nodeA, err = New(cfgA.Certificate, logger, ListenAddress("tcp://127.0.0.1:0")); err != nil {
|
if nodeA, err = New(cfgA.Certificate, logger); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if nodeB, err = New(cfgB.Certificate, logger, ListenAddress("tcp://127.0.0.1:0")); err != nil {
|
if nodeB, err = New(cfgB.Certificate, logger); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
u, err := url.Parse("tcp://" + nodeA.links.tcp.getAddr().String())
|
nodeAListenURL, err := url.Parse("tcp://localhost:0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
err = nodeB.CallPeer(u, "")
|
nodeAListener, err := nodeA.Listen(nodeAListenURL, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
nodeAURL, err := url.Parse("tcp://" + nodeAListener.Addr().String())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err = nodeB.CallPeer(nodeAURL, ""); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
|
@ -104,20 +104,6 @@ func (l *linkTCP) listen(ctx context.Context, url *url.URL, sintf string) (net.L
|
|||||||
return l.listenconfig.Listen(ctx, "tcp", hostport)
|
return l.listenconfig.Listen(ctx, "tcp", hostport)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the address of the listener.
|
|
||||||
func (l *linkTCP) getAddr() *net.TCPAddr {
|
|
||||||
// TODO: Fix this, because this will currently only give a single address
|
|
||||||
// to multicast.go, which obviously is not great, but right now multicast.go
|
|
||||||
// doesn't have the ability to send more than one address in a packet either
|
|
||||||
var addr *net.TCPAddr
|
|
||||||
phony.Block(l, func() {
|
|
||||||
for li := range l._listeners {
|
|
||||||
addr = li.listener.Addr().(*net.TCPAddr)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return addr
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *linkTCP) dialerFor(dst *net.TCPAddr, sintf string) (*net.Dialer, error) {
|
func (l *linkTCP) dialerFor(dst *net.TCPAddr, sintf string) (*net.Dialer, error) {
|
||||||
if dst.IP.IsLinkLocalUnicast() {
|
if dst.IP.IsLinkLocalUnicast() {
|
||||||
if sintf != "" {
|
if sintf != "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user