Normalize and deduplicate master peer addresses
This commit is contained in:
@@ -43,3 +43,24 @@ func TestCheckPeersCanonicalizesSelfEntry(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckPeersDeduplicatesAliasPeers(t *testing.T) {
|
||||
_, peers := checkPeers("127.0.0.1", 9000, 19000, "127.0.0.1:9002,127.0.0.1:9002.19002,127.0.0.1:9003")
|
||||
|
||||
if len(peers) != 3 {
|
||||
t.Fatalf("expected 3 unique peers after normalization, got %d: %+v", len(peers), peers)
|
||||
}
|
||||
|
||||
count9002 := 0
|
||||
for _, peer := range peers {
|
||||
if peer.ToHttpAddress() == "127.0.0.1:9002" {
|
||||
count9002++
|
||||
if string(peer) != "127.0.0.1:9002.19002" {
|
||||
t.Fatalf("expected canonical peer 127.0.0.1:9002.19002, got %q", peer)
|
||||
}
|
||||
}
|
||||
}
|
||||
if count9002 != 1 {
|
||||
t.Fatalf("expected one peer for 127.0.0.1:9002, got %d in %+v", count9002, peers)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user