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

This fixes a race in the test.

Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
Marcin Sobczak 2022-11-07 22:46:21 +01:00 committed by GitHub
parent 055528ae05
commit d629e02047
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 4 deletions

View File

@ -256,6 +256,7 @@ func WrongPacketType(t *utesting.T) {
func BondThenPingWithWrongFrom(t *utesting.T) {
te := newTestEnv(Remote, Listen1, Listen2)
defer te.close()
bond(t, te)
wrongEndpoint := v4wire.Endpoint{IP: net.ParseIP("192.0.2.0")}
@ -265,10 +266,25 @@ func BondThenPingWithWrongFrom(t *utesting.T) {
To: te.remoteEndpoint(),
Expiration: futureExpiration(),
})
if reply, _, err := te.read(te.l1); err != nil {
t.Fatal(err)
} else if err := te.checkPong(reply, pingHash); err != nil {
t.Fatal(err)
waitForPong:
for {
reply, _, err := te.read(te.l1)
if err != nil {
t.Fatal(err)
}
switch reply.Kind() {
case v4wire.PongPacket:
if err := te.checkPong(reply, pingHash); err != nil {
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)
}
}
}