Skip to content

Commit 49f0d49

Browse files
authored
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 a0620f1 commit 49f0d49

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
@@ -59,8 +59,9 @@ func (s *Suite) AllTests() []utesting.Test {
5959
}
6060
}
6161

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

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

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

@@ -104,10 +106,11 @@ func (s *Suite) TestPingLargeRequestID(t *utesting.T) {
104106
}
105107
}
106108

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

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

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

@@ -181,8 +189,10 @@ func (s *Suite) TestPingHandshakeInterrupted(t *utesting.T) {
181189
}
182190
}
183191

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

@@ -202,6 +212,7 @@ func (s *Suite) TestTalkRequest(t *utesting.T) {
202212
}
203213

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

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

@@ -233,9 +245,11 @@ func (s *Suite) TestFindnodeZeroDistance(t *utesting.T) {
233245
}
234246
}
235247

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

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

0 commit comments

Comments
 (0)