diff options
author | Felix Lange <fjl@twurst.com> | 2015-02-06 21:40:53 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-02-07 07:12:23 +0800 |
commit | 8564eb9f7efcc7a0e639f6a45d7e67037fedac5f (patch) | |
tree | 2b2ebde612d7d084b87b3eff9b6db0e08ea552ed /p2p/discover/udp_test.go | |
parent | 56f777b2fc77275bc636562b66a08b19afe2ec56 (diff) | |
download | dexon-8564eb9f7efcc7a0e639f6a45d7e67037fedac5f.tar.gz dexon-8564eb9f7efcc7a0e639f6a45d7e67037fedac5f.tar.zst dexon-8564eb9f7efcc7a0e639f6a45d7e67037fedac5f.zip |
p2p/discover: add node URL functions, distinguish TCP/UDP ports
The discovery RPC protocol does not yet distinguish TCP and UDP ports.
But it can't hurt to do so in our internal model.
Diffstat (limited to 'p2p/discover/udp_test.go')
-rw-r--r-- | p2p/discover/udp_test.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/p2p/discover/udp_test.go b/p2p/discover/udp_test.go index 8ed6ec9c0..94680d6fc 100644 --- a/p2p/discover/udp_test.go +++ b/p2p/discover/udp_test.go @@ -4,6 +4,7 @@ import ( logpkg "log" "net" "os" + "reflect" "testing" "time" @@ -11,7 +12,7 @@ import ( ) func init() { - logger.AddLogSystem(logger.NewStdLogSystem(os.Stdout, logpkg.LstdFlags, logger.DebugLevel)) + logger.AddLogSystem(logger.NewStdLogSystem(os.Stdout, logpkg.LstdFlags, logger.ErrorLevel)) } func TestUDP_ping(t *testing.T) { @@ -52,7 +53,7 @@ func TestUDP_findnode(t *testing.T) { defer n1.Close() defer n2.Close() - entry := &Node{ID: NodeID{1}, Addr: &net.UDPAddr{IP: net.IP{1, 2, 3, 4}, Port: 15}} + entry := MustParseNode("enode://9d8a19597e312ef32d76e6b4903bb43d7bcd892d17b769d30b404bd3a4c2dca6c86184b17d0fdeeafe3b01e0e912d990ddc853db3f325d5419f31446543c30be@127.0.0.1:54194") n2.add([]*Node{entry}) target := randomID(n1.self.ID, 100) @@ -60,7 +61,7 @@ func TestUDP_findnode(t *testing.T) { if len(result) != 1 { t.Fatalf("wrong number of results: got %d, want 1", len(result)) } - if result[0].ID != entry.ID { + if !reflect.DeepEqual(result[0], entry) { t.Errorf("wrong result: got %v, want %v", result[0], entry) } } @@ -103,8 +104,10 @@ func TestUDP_findnodeMultiReply(t *testing.T) { nodes := make([]*Node, bucketSize) for i := range nodes { nodes[i] = &Node{ - Addr: &net.UDPAddr{IP: net.IP{1, 2, 3, 4}, Port: i + 1}, - ID: randomID(n2.self.ID, i+1), + IP: net.IP{1, 2, 3, 4}, + DiscPort: i + 1, + TCPPort: i + 1, + ID: randomID(n2.self.ID, i+1), } } |