mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-24 06:52:32 +00:00

* [NOD-1191] Convert wire protocol to 100% protobuf * [NOD-1191] Simplify wire interface and remove redundant messages * [NOD-1191] Map all proto to wire conversions * [NOD-1203] Create netadapter outside of protocol manager * [NOD-1191] Fix nil errors * [NOD-1191] Fix comments * [NOD-1191] Add converter interface * [NOD-1191] Add missing GetBlockLocator message * [NOD-1191] Change message names that starts with 'get' to 'request' * [NOD-1191] Change message commands values * [NOD-1191] Remove redundant methods * [NOD-1191] Rename message constructors * [NOD-1191] Change message commands to use iota * [NOD-1191] Add missing outputs to protobuf conversion * [NOD-1191] Make block header a required field * [NOD-1191] Rename variables * [NOD-1212] Fix test names * [NOD-1191] Rename flow names * [NOD-1191] Fix infinite loop
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
// Copyright (c) 2013-2016 The btcsuite developers
|
|
// Use of this source code is governed by an ISC
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package wire
|
|
|
|
import (
|
|
"net"
|
|
"testing"
|
|
)
|
|
|
|
// TestNetAddress tests the NetAddress API.
|
|
func TestNetAddress(t *testing.T) {
|
|
ip := net.ParseIP("127.0.0.1")
|
|
port := 16111
|
|
|
|
// Test NewNetAddress.
|
|
na := NewNetAddress(&net.TCPAddr{IP: ip, Port: port}, 0)
|
|
|
|
// Ensure we get the same ip, port, and services back out.
|
|
if !na.IP.Equal(ip) {
|
|
t.Errorf("NetNetAddress: wrong ip - got %v, want %v", na.IP, ip)
|
|
}
|
|
if na.Port != uint16(port) {
|
|
t.Errorf("NetNetAddress: wrong port - got %v, want %v", na.Port,
|
|
port)
|
|
}
|
|
if na.Services != 0 {
|
|
t.Errorf("NetNetAddress: wrong services - got %v, want %v",
|
|
na.Services, 0)
|
|
}
|
|
if na.HasService(SFNodeNetwork) {
|
|
t.Errorf("HasService: SFNodeNetwork service is set")
|
|
}
|
|
|
|
// Ensure adding the full service node flag works.
|
|
na.AddService(SFNodeNetwork)
|
|
if na.Services != SFNodeNetwork {
|
|
t.Errorf("AddService: wrong services - got %v, want %v",
|
|
na.Services, SFNodeNetwork)
|
|
}
|
|
if !na.HasService(SFNodeNetwork) {
|
|
t.Errorf("HasService: SFNodeNetwork service not set")
|
|
}
|
|
}
|