mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 01:43:47 +00:00
p2p/enode: fix test
This commit is contained in:
parent
42cb347ed7
commit
83f5e0c5f7
2 changed files with 11 additions and 4 deletions
|
|
@ -81,6 +81,8 @@ func newNodeWithID(r *enr.Record, id ID) *Node {
|
|||
n.setIP4(ip4)
|
||||
case valid6:
|
||||
n.setIP6(ip6)
|
||||
default:
|
||||
n.setIPv4Ports()
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
|
@ -107,6 +109,10 @@ func localityScore(ip netip.Addr) int {
|
|||
|
||||
func (n *Node) setIP4(ip netip.Addr) {
|
||||
n.ip = ip
|
||||
n.setIPv4Ports()
|
||||
}
|
||||
|
||||
func (n *Node) setIPv4Ports() {
|
||||
n.Load((*enr.UDP)(&n.udp))
|
||||
n.Load((*enr.TCP)(&n.tcp))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ func TestNodeEndpoints(t *testing.T) {
|
|||
r.Set(enr.UDP(9000))
|
||||
return SignNull(&r, id)
|
||||
}(),
|
||||
wantUDP: 9000,
|
||||
},
|
||||
{
|
||||
name: "tcp-only",
|
||||
|
|
@ -99,6 +100,7 @@ func TestNodeEndpoints(t *testing.T) {
|
|||
r.Set(enr.TCP(9000))
|
||||
return SignNull(&r, id)
|
||||
}(),
|
||||
wantTCP: 9000,
|
||||
},
|
||||
{
|
||||
name: "quic-only",
|
||||
|
|
@ -273,10 +275,9 @@ func TestNodeEndpoints(t *testing.T) {
|
|||
name: "dns-only",
|
||||
node: func() *Node {
|
||||
var r enr.Record
|
||||
n := SignNull(&r, id)
|
||||
n.hostname = "example.com"
|
||||
n.tcp = 30303
|
||||
n.udp = 30303
|
||||
r.Set(enr.UDP(30303))
|
||||
r.Set(enr.TCP(30303))
|
||||
n := SignNull(&r, id).WithHostname("example.com")
|
||||
return n
|
||||
}(),
|
||||
wantTCP: 30303,
|
||||
|
|
|
|||
Loading…
Reference in a new issue