@@ -64,23 +64,23 @@ func NewSuite(dest *enode.Node, chainDir, engineURL, jwt string) (*Suite, error)
64
64
func (s * Suite ) EthTests () []utesting.Test {
65
65
return []utesting.Test {
66
66
// status
67
- {Name : "TestStatus " , Fn : s .TestStatus },
67
+ {Name : "Status " , Fn : s .TestStatus },
68
68
// get block headers
69
- {Name : "TestGetBlockHeaders " , Fn : s .TestGetBlockHeaders },
70
- {Name : "TestSimultaneousRequests " , Fn : s .TestSimultaneousRequests },
71
- {Name : "TestSameRequestID " , Fn : s .TestSameRequestID },
72
- {Name : "TestZeroRequestID " , Fn : s .TestZeroRequestID },
69
+ {Name : "GetBlockHeaders " , Fn : s .TestGetBlockHeaders },
70
+ {Name : "SimultaneousRequests " , Fn : s .TestSimultaneousRequests },
71
+ {Name : "SameRequestID " , Fn : s .TestSameRequestID },
72
+ {Name : "ZeroRequestID " , Fn : s .TestZeroRequestID },
73
73
// get block bodies
74
- {Name : "TestGetBlockBodies " , Fn : s .TestGetBlockBodies },
74
+ {Name : "GetBlockBodies " , Fn : s .TestGetBlockBodies },
75
75
// // malicious handshakes + status
76
- {Name : "TestMaliciousHandshake " , Fn : s .TestMaliciousHandshake },
77
- {Name : "TestMaliciousStatus " , Fn : s .TestMaliciousStatus },
76
+ {Name : "MaliciousHandshake " , Fn : s .TestMaliciousHandshake },
77
+ {Name : "MaliciousStatus " , Fn : s .TestMaliciousStatus },
78
78
// test transactions
79
- {Name : "TestLargeTxRequest " , Fn : s .TestLargeTxRequest , Slow : true },
80
- {Name : "TestTransaction " , Fn : s .TestTransaction },
81
- {Name : "TestInvalidTxs " , Fn : s .TestInvalidTxs },
82
- {Name : "TestNewPooledTxs " , Fn : s .TestNewPooledTxs },
83
- {Name : "TestBlobViolations " , Fn : s .TestBlobViolations },
79
+ {Name : "LargeTxRequest " , Fn : s .TestLargeTxRequest , Slow : true },
80
+ {Name : "Transaction " , Fn : s .TestTransaction },
81
+ {Name : "InvalidTxs " , Fn : s .TestInvalidTxs },
82
+ {Name : "NewPooledTxs " , Fn : s .TestNewPooledTxs },
83
+ {Name : "BlobViolations " , Fn : s .TestBlobViolations },
84
84
}
85
85
}
86
86
@@ -94,9 +94,9 @@ func (s *Suite) SnapTests() []utesting.Test {
94
94
}
95
95
}
96
96
97
- // TestStatus attempts to connect to the given node and exchange a status
98
- // message with it on the eth protocol.
99
97
func (s * Suite ) TestStatus (t * utesting.T ) {
98
+ t .Log (`This test is just a sanity check. It performs an eth protocol handshake.` )
99
+
100
100
conn , err := s .dial ()
101
101
if err != nil {
102
102
t .Fatalf ("dial failed: %v" , err )
@@ -112,9 +112,9 @@ func headersMatch(expected []*types.Header, headers []*types.Header) bool {
112
112
return reflect .DeepEqual (expected , headers )
113
113
}
114
114
115
- // TestGetBlockHeaders tests whether the given node can respond to an eth
116
- // `GetBlockHeaders` request and that the response is accurate.
117
115
func (s * Suite ) TestGetBlockHeaders (t * utesting.T ) {
116
+ t .Log (`This test requests block headers from the node.` )
117
+
118
118
conn , err := s .dial ()
119
119
if err != nil {
120
120
t .Fatalf ("dial failed: %v" , err )
@@ -154,10 +154,10 @@ func (s *Suite) TestGetBlockHeaders(t *utesting.T) {
154
154
}
155
155
}
156
156
157
- // TestSimultaneousRequests sends two simultaneous `GetBlockHeader` requests
158
- // from the same connection with different request IDs and checks to make sure
159
- // the node responds with the correct headers per request.
160
157
func (s * Suite ) TestSimultaneousRequests (t * utesting.T ) {
158
+ t .Log (`This test requests blocks headers from the node, performing two requests
159
+ concurrently, with different request IDs.` )
160
+
161
161
conn , err := s .dial ()
162
162
if err != nil {
163
163
t .Fatalf ("dial failed: %v" , err )
@@ -228,9 +228,10 @@ func (s *Suite) TestSimultaneousRequests(t *utesting.T) {
228
228
}
229
229
}
230
230
231
- // TestSameRequestID sends two requests with the same request ID to a single
232
- // node.
233
231
func (s * Suite ) TestSameRequestID (t * utesting.T ) {
232
+ t .Log (`This test requests block headers, performing two concurrent requests with the
233
+ same request ID. The node should handle the request by responding to both requests.` )
234
+
234
235
conn , err := s .dial ()
235
236
if err != nil {
236
237
t .Fatalf ("dial failed: %v" , err )
@@ -298,9 +299,10 @@ func (s *Suite) TestSameRequestID(t *utesting.T) {
298
299
}
299
300
}
300
301
301
- // TestZeroRequestID checks that a message with a request ID of zero is still handled
302
- // by the node.
303
302
func (s * Suite ) TestZeroRequestID (t * utesting.T ) {
303
+ t .Log (`This test sends a GetBlockHeaders message with a request-id of zero,
304
+ and expects a response.` )
305
+
304
306
conn , err := s .dial ()
305
307
if err != nil {
306
308
t .Fatalf ("dial failed: %v" , err )
@@ -333,9 +335,9 @@ func (s *Suite) TestZeroRequestID(t *utesting.T) {
333
335
}
334
336
}
335
337
336
- // TestGetBlockBodies tests whether the given node can respond to a
337
- // `GetBlockBodies` request and that the response is accurate.
338
338
func (s * Suite ) TestGetBlockBodies (t * utesting.T ) {
339
+ t .Log (`This test sends GetBlockBodies requests to the node for known blocks in the test chain.` )
340
+
339
341
conn , err := s .dial ()
340
342
if err != nil {
341
343
t .Fatalf ("dial failed: %v" , err )
@@ -376,12 +378,12 @@ func randBuf(size int) []byte {
376
378
return buf
377
379
}
378
380
379
- // TestMaliciousHandshake tries to send malicious data during the handshake.
380
381
func (s * Suite ) TestMaliciousHandshake (t * utesting.T ) {
381
- key , _ := crypto . GenerateKey ( )
382
+ t . Log ( `This test tries to send malicious data during the devp2p handshake, in various ways.` )
382
383
383
384
// Write hello to client.
384
385
var (
386
+ key , _ = crypto .GenerateKey ()
385
387
pub0 = crypto .FromECDSAPub (& key .PublicKey )[1 :]
386
388
version = eth .ProtocolVersions [0 ]
387
389
)
@@ -451,8 +453,9 @@ func (s *Suite) TestMaliciousHandshake(t *utesting.T) {
451
453
}
452
454
}
453
455
454
- // TestMaliciousStatus sends a status package with a large total difficulty.
455
456
func (s * Suite ) TestMaliciousStatus (t * utesting.T ) {
457
+ t .Log (`This test sends a malicious eth Status message to the node and expects a disconnect.` )
458
+
456
459
conn , err := s .dial ()
457
460
if err != nil {
458
461
t .Fatalf ("dial failed: %v" , err )
@@ -486,9 +489,10 @@ func (s *Suite) TestMaliciousStatus(t *utesting.T) {
486
489
}
487
490
}
488
491
489
- // TestTransaction sends a valid transaction to the node and checks if the
490
- // transaction gets propagated.
491
492
func (s * Suite ) TestTransaction (t * utesting.T ) {
493
+ t .Log (`This test sends a valid transaction to the node and checks if the
494
+ transaction gets propagated.` )
495
+
492
496
// Nudge client out of syncing mode to accept pending txs.
493
497
if err := s .engine .sendForkchoiceUpdated (); err != nil {
494
498
t .Fatalf ("failed to send next block: %v" , err )
@@ -507,15 +511,16 @@ func (s *Suite) TestTransaction(t *utesting.T) {
507
511
if err != nil {
508
512
t .Fatalf ("failed to sign tx: %v" , err )
509
513
}
510
- if err := s .sendTxs ([]* types.Transaction {tx }); err != nil {
514
+ if err := s .sendTxs (t , []* types.Transaction {tx }); err != nil {
511
515
t .Fatal (err )
512
516
}
513
517
s .chain .IncNonce (from , 1 )
514
518
}
515
519
516
- // TestInvalidTxs sends several invalid transactions and tests whether
517
- // the node will propagate them.
518
520
func (s * Suite ) TestInvalidTxs (t * utesting.T ) {
521
+ t .Log (`This test sends several kinds of invalid transactions and checks that the node
522
+ does not propagate them.` )
523
+
519
524
// Nudge client out of syncing mode to accept pending txs.
520
525
if err := s .engine .sendForkchoiceUpdated (); err != nil {
521
526
t .Fatalf ("failed to send next block: %v" , err )
@@ -534,7 +539,7 @@ func (s *Suite) TestInvalidTxs(t *utesting.T) {
534
539
if err != nil {
535
540
t .Fatalf ("failed to sign tx: %v" , err )
536
541
}
537
- if err := s .sendTxs ([]* types.Transaction {tx }); err != nil {
542
+ if err := s .sendTxs (t , []* types.Transaction {tx }); err != nil {
538
543
t .Fatalf ("failed to send txs: %v" , err )
539
544
}
540
545
s .chain .IncNonce (from , 1 )
@@ -590,14 +595,15 @@ func (s *Suite) TestInvalidTxs(t *utesting.T) {
590
595
}
591
596
txs = append (txs , tx )
592
597
}
593
- if err := s .sendInvalidTxs (txs ); err != nil {
598
+ if err := s .sendInvalidTxs (t , txs ); err != nil {
594
599
t .Fatalf ("failed to send invalid txs: %v" , err )
595
600
}
596
601
}
597
602
598
- // TestLargeTxRequest tests whether a node can fulfill a large GetPooledTransactions
599
- // request.
600
603
func (s * Suite ) TestLargeTxRequest (t * utesting.T ) {
604
+ t .Log (`This test first send ~2000 transactions to the node, then requests them
605
+ on another peer connection using GetPooledTransactions.` )
606
+
601
607
// Nudge client out of syncing mode to accept pending txs.
602
608
if err := s .engine .sendForkchoiceUpdated (); err != nil {
603
609
t .Fatalf ("failed to send next block: %v" , err )
@@ -630,7 +636,7 @@ func (s *Suite) TestLargeTxRequest(t *utesting.T) {
630
636
s .chain .IncNonce (from , uint64 (count ))
631
637
632
638
// Send txs.
633
- if err := s .sendTxs (txs ); err != nil {
639
+ if err := s .sendTxs (t , txs ); err != nil {
634
640
t .Fatalf ("failed to send txs: %v" , err )
635
641
}
636
642
@@ -667,13 +673,15 @@ func (s *Suite) TestLargeTxRequest(t *utesting.T) {
667
673
}
668
674
}
669
675
670
- // TestNewPooledTxs tests whether a node will do a GetPooledTransactions request
671
- // upon receiving a NewPooledTransactionHashes announcement.
672
676
func (s * Suite ) TestNewPooledTxs (t * utesting.T ) {
677
+ t .Log (`This test announces transaction hashes to the node and expects it to fetch
678
+ the transactions using a GetPooledTransactions request.` )
679
+
673
680
// Nudge client out of syncing mode to accept pending txs.
674
681
if err := s .engine .sendForkchoiceUpdated (); err != nil {
675
682
t .Fatalf ("failed to send next block: %v" , err )
676
683
}
684
+
677
685
var (
678
686
count = 50
679
687
from , nonce = s .chain .GetSender (1 )
@@ -762,7 +770,7 @@ func (s *Suite) makeBlobTxs(count, blobs int, discriminator byte) (txs types.Tra
762
770
from , nonce := s .chain .GetSender (5 )
763
771
for i := 0 ; i < count ; i ++ {
764
772
// Make blob data, max of 2 blobs per tx.
765
- blobdata := make ([]byte , blobs % 2 )
773
+ blobdata := make ([]byte , blobs % 3 )
766
774
for i := range blobdata {
767
775
blobdata [i ] = discriminator
768
776
blobs -= 1
@@ -787,6 +795,8 @@ func (s *Suite) makeBlobTxs(count, blobs int, discriminator byte) (txs types.Tra
787
795
}
788
796
789
797
func (s * Suite ) TestBlobViolations (t * utesting.T ) {
798
+ t .Log (`This test sends some invalid blob tx announcements and expects the node to disconnect.` )
799
+
790
800
if err := s .engine .sendForkchoiceUpdated (); err != nil {
791
801
t .Fatalf ("send fcu failed: %v" , err )
792
802
}
0 commit comments