Skip to content

Commit 84cca39

Browse files
fjlucwong
authored andcommitted
cmd/devp2p/internal/v5test: log test descriptions (#31551)
This adds the test description text to the output, instead of keeping it as a Go comment. Logs are visible in the hive UI where these tests run, while Go comments are not.
1 parent caf899c commit 84cca39

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

cmd/devp2p/internal/v5test/discv5tests.go

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ func (s *Suite) AllTests() []utesting.Test {
5858
}
5959
}
6060

61-
// This test sends PING and expects a PONG response.
6261
func (s *Suite) TestPing(t *utesting.T) {
62+
t.Log(`This test is just a sanity check. It sends PING and expects a PONG response.`)
63+
6364
conn, l1 := s.listen1(t)
6465
defer conn.close()
6566

@@ -84,9 +85,10 @@ func checkPong(t *utesting.T, pong *v5wire.Pong, ping *v5wire.Ping, c net.Packet
8485
}
8586
}
8687

87-
// This test sends PING with a 9-byte request ID, which isn't allowed by the spec.
88-
// The remote node should not respond.
8988
func (s *Suite) TestPingLargeRequestID(t *utesting.T) {
89+
t.Log(`This test sends PING with a 9-byte request ID, which isn't allowed by the spec.
90+
The remote node should not respond.`)
91+
9092
conn, l1 := s.listen1(t)
9193
defer conn.close()
9294

@@ -103,10 +105,11 @@ func (s *Suite) TestPingLargeRequestID(t *utesting.T) {
103105
}
104106
}
105107

106-
// In this test, a session is established from one IP as usual. The session is then reused
107-
// on another IP, which shouldn't work. The remote node should respond with WHOAREYOU for
108-
// the attempt from a different IP.
109108
func (s *Suite) TestPingMultiIP(t *utesting.T) {
109+
t.Log(`This test establishes a session from one IP as usual. The session is then reused
110+
on another IP, which shouldn't work. The remote node should respond with WHOAREYOU for
111+
the attempt from a different IP.`)
112+
110113
conn, l1, l2 := s.listen2(t)
111114
defer conn.close()
112115

@@ -119,6 +122,7 @@ func (s *Suite) TestPingMultiIP(t *utesting.T) {
119122
checkPong(t, resp.(*v5wire.Pong), ping, l1)
120123

121124
// Send on l2. This reuses the session because there is only one codec.
125+
t.Log("sending ping from alternate IP", l2.LocalAddr())
122126
ping2 := &v5wire.Ping{ReqID: conn.nextReqID()}
123127
conn.write(l2, ping2, nil)
124128
switch resp := conn.read(l2).(type) {
@@ -157,6 +161,10 @@ func (s *Suite) TestPingMultiIP(t *utesting.T) {
157161
// packet instead of a handshake message packet. The remote node should respond with
158162
// another WHOAREYOU challenge for the second packet.
159163
func (s *Suite) TestPingHandshakeInterrupted(t *utesting.T) {
164+
t.Log(`TestPingHandshakeInterrupted starts a handshake, but doesn't finish it and sends a second ordinary message
165+
packet instead of a handshake message packet. The remote node should respond with
166+
another WHOAREYOU challenge for the second packet.`)
167+
160168
conn, l1 := s.listen1(t)
161169
defer conn.close()
162170

@@ -180,8 +188,10 @@ func (s *Suite) TestPingHandshakeInterrupted(t *utesting.T) {
180188
}
181189
}
182190

183-
// This test sends TALKREQ and expects an empty TALKRESP response.
184191
func (s *Suite) TestTalkRequest(t *utesting.T) {
192+
t.Log(`This test sends some examples of TALKREQ with a protocol-id of "test-protocol"
193+
and expects an empty TALKRESP response.`)
194+
185195
conn, l1 := s.listen1(t)
186196
defer conn.close()
187197

@@ -201,6 +211,7 @@ func (s *Suite) TestTalkRequest(t *utesting.T) {
201211
}
202212

203213
// Empty request ID.
214+
t.Log("sending TALKREQ with empty request-id")
204215
resp = conn.reqresp(l1, &v5wire.TalkRequest{Protocol: "test-protocol"})
205216
switch resp := resp.(type) {
206217
case *v5wire.TalkResponse:
@@ -215,8 +226,9 @@ func (s *Suite) TestTalkRequest(t *utesting.T) {
215226
}
216227
}
217228

218-
// This test checks that the remote node returns itself for FINDNODE with distance zero.
219229
func (s *Suite) TestFindnodeZeroDistance(t *utesting.T) {
230+
t.Log(`This test checks that the remote node returns itself for FINDNODE with distance zero.`)
231+
220232
conn, l1 := s.listen1(t)
221233
defer conn.close()
222234

@@ -232,9 +244,11 @@ func (s *Suite) TestFindnodeZeroDistance(t *utesting.T) {
232244
}
233245
}
234246

235-
// In this test, multiple nodes ping the node under test. After waiting for them to be
236-
// accepted into the remote table, the test checks that they are returned by FINDNODE.
237247
func (s *Suite) TestFindnodeResults(t *utesting.T) {
248+
t.Log(`This test pings the node under test from multiple other endpoints and node identities
249+
(the 'bystanders'). After waiting for them to be accepted into the remote table, the test checks
250+
that they are returned by FINDNODE.`)
251+
238252
// Create bystanders.
239253
nodes := make([]*bystander, 5)
240254
added := make(chan enode.ID, len(nodes))
@@ -272,6 +286,7 @@ func (s *Suite) TestFindnodeResults(t *utesting.T) {
272286
}
273287

274288
// Send FINDNODE for all distances.
289+
t.Log("requesting nodes")
275290
conn, l1 := s.listen1(t)
276291
defer conn.close()
277292
foundNodes, err := conn.findnode(l1, dists)

0 commit comments

Comments
 (0)