Unverified Commit d629e020 authored by Marcin Sobczak's avatar Marcin Sobczak Committed by GitHub

cmd/devp2p/internal/v4test: ignore FINDNODE in BondThenPingWithWrongFrom (#26085)

This fixes a race in the test.
Co-authored-by: 's avatarFelix Lange <fjl@twurst.com>
parent 055528ae
...@@ -256,6 +256,7 @@ func WrongPacketType(t *utesting.T) { ...@@ -256,6 +256,7 @@ func WrongPacketType(t *utesting.T) {
func BondThenPingWithWrongFrom(t *utesting.T) { func BondThenPingWithWrongFrom(t *utesting.T) {
te := newTestEnv(Remote, Listen1, Listen2) te := newTestEnv(Remote, Listen1, Listen2)
defer te.close() defer te.close()
bond(t, te) bond(t, te)
wrongEndpoint := v4wire.Endpoint{IP: net.ParseIP("192.0.2.0")} wrongEndpoint := v4wire.Endpoint{IP: net.ParseIP("192.0.2.0")}
...@@ -265,11 +266,26 @@ func BondThenPingWithWrongFrom(t *utesting.T) { ...@@ -265,11 +266,26 @@ func BondThenPingWithWrongFrom(t *utesting.T) {
To: te.remoteEndpoint(), To: te.remoteEndpoint(),
Expiration: futureExpiration(), Expiration: futureExpiration(),
}) })
if reply, _, err := te.read(te.l1); err != nil {
waitForPong:
for {
reply, _, err := te.read(te.l1)
if err != nil {
t.Fatal(err) t.Fatal(err)
} else if err := te.checkPong(reply, pingHash); err != nil { }
switch reply.Kind() {
case v4wire.PongPacket:
if err := te.checkPong(reply, pingHash); err != nil {
t.Fatal(err) t.Fatal(err)
} }
break waitForPong
case v4wire.FindnodePacket:
// FINDNODE from the node is acceptable here since the endpoint
// verification was performed earlier.
default:
t.Fatalf("Expected PONG, got %v %v", reply.Name(), reply)
}
}
} }
// This test just sends FINDNODE. The remote node should not reply // This test just sends FINDNODE. The remote node should not reply
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment