mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
p2p/enode: more quic tests
This commit is contained in:
parent
299eff3eb9
commit
3b4a63934c
1 changed files with 59 additions and 5 deletions
|
|
@ -73,6 +73,7 @@ func TestNodeEndpoints(t *testing.T) {
|
|||
wantIP netip.Addr
|
||||
wantUDP int
|
||||
wantTCP int
|
||||
wantQUIC int
|
||||
}
|
||||
tests := []endpointTest{
|
||||
{
|
||||
|
|
@ -106,6 +107,14 @@ func TestNodeEndpoints(t *testing.T) {
|
|||
return SignNull(&r, id)
|
||||
}(),
|
||||
},
|
||||
{
|
||||
name: "quic6-only",
|
||||
node: func() *Node {
|
||||
var r enr.Record
|
||||
r.Set(enr.QUIC6(9000))
|
||||
return SignNull(&r, id)
|
||||
}(),
|
||||
},
|
||||
{
|
||||
name: "ipv4-only-loopback",
|
||||
node: func() *Node {
|
||||
|
|
@ -217,6 +226,48 @@ func TestNodeEndpoints(t *testing.T) {
|
|||
wantIP: netip.MustParseAddr("192.168.2.2"),
|
||||
wantUDP: 30304,
|
||||
},
|
||||
{
|
||||
name: "ipv4-quic",
|
||||
node: func() *Node {
|
||||
var r enr.Record
|
||||
r.Set(enr.IPv4Addr(netip.MustParseAddr("99.22.33.1")))
|
||||
r.Set(enr.QUIC(9001))
|
||||
return SignNull(&r, id)
|
||||
}(),
|
||||
wantIP: netip.MustParseAddr("99.22.33.1"),
|
||||
wantQUIC: 9001,
|
||||
},
|
||||
{ // Because the node is IPv4, the quic6 entry won't be loaded.
|
||||
name: "ipv4-quic6",
|
||||
node: func() *Node {
|
||||
var r enr.Record
|
||||
r.Set(enr.IPv4Addr(netip.MustParseAddr("99.22.33.1")))
|
||||
r.Set(enr.QUIC6(9001))
|
||||
return SignNull(&r, id)
|
||||
}(),
|
||||
wantIP: netip.MustParseAddr("99.22.33.1"),
|
||||
},
|
||||
{
|
||||
name: "ipv6-quic",
|
||||
node: func() *Node {
|
||||
var r enr.Record
|
||||
r.Set(enr.IPv6Addr(netip.MustParseAddr("2001::ff00:0042:8329")))
|
||||
r.Set(enr.QUIC(9001))
|
||||
return SignNull(&r, id)
|
||||
}(),
|
||||
wantIP: netip.MustParseAddr("2001::ff00:0042:8329"),
|
||||
},
|
||||
{
|
||||
name: "ipv6-quic6",
|
||||
node: func() *Node {
|
||||
var r enr.Record
|
||||
r.Set(enr.IPv6Addr(netip.MustParseAddr("2001::ff00:0042:8329")))
|
||||
r.Set(enr.QUIC6(9001))
|
||||
return SignNull(&r, id)
|
||||
}(),
|
||||
wantIP: netip.MustParseAddr("2001::ff00:0042:8329"),
|
||||
wantQUIC: 9001,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
|
@ -230,6 +281,9 @@ func TestNodeEndpoints(t *testing.T) {
|
|||
if test.wantTCP != test.node.TCP() {
|
||||
t.Errorf("node has wrong TCP port %d, want %d", test.node.TCP(), test.wantTCP)
|
||||
}
|
||||
if quic, _ := test.node.QUICEndpoint(); test.wantQUIC != int(quic.Port()) {
|
||||
t.Errorf("node has wrong QUIC port %d, want %d", quic.Port(), test.wantQUIC)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue