1- // Copyright 2014 The go-ethereum Authors
1+ // Copyright 2020 The go-ethereum Authors
22// This file is part of the go-ethereum library.
33//
44// The go-ethereum library is free software: you can redistribute it and/or modify
@@ -61,10 +61,14 @@ func (h *testEthHandler) Handle(peer *eth.Peer, packet eth.Packet) error {
6161 h .blockBroadcasts .Send (packet .Block )
6262 return nil
6363
64- case * eth.NewPooledTransactionHashesPacket :
64+ case * eth.NewPooledTransactionHashesPacket66 :
6565 h .txAnnounces .Send (([]common.Hash )(* packet ))
6666 return nil
6767
68+ case * eth.NewPooledTransactionHashesPacket68 :
69+ h .txAnnounces .Send (packet .Hashes )
70+ return nil
71+
6872 case * eth.TransactionsPacket :
6973 h .txBroadcasts .Send (([]* types.Transaction )(* packet ))
7074 return nil
@@ -81,6 +85,8 @@ func (h *testEthHandler) Handle(peer *eth.Peer, packet eth.Packet) error {
8185// Tests that peers are correctly accepted (or rejected) based on the advertised
8286// fork IDs in the protocol handshake.
8387func TestForkIDSplit66 (t * testing.T ) { testForkIDSplit (t , eth .ETH66 ) }
88+ func TestForkIDSplit67 (t * testing.T ) { testForkIDSplit (t , eth .ETH67 ) }
89+ func TestForkIDSplit68 (t * testing.T ) { testForkIDSplit (t , eth .ETH68 ) }
8490
8591func testForkIDSplit (t * testing.T , protocol uint ) {
8692 t .Parallel ()
@@ -236,6 +242,8 @@ func testForkIDSplit(t *testing.T, protocol uint) {
236242
237243// Tests that received transactions are added to the local pool.
238244func TestRecvTransactions66 (t * testing.T ) { testRecvTransactions (t , eth .ETH66 ) }
245+ func TestRecvTransactions67 (t * testing.T ) { testRecvTransactions (t , eth .ETH67 ) }
246+ func TestRecvTransactions68 (t * testing.T ) { testRecvTransactions (t , eth .ETH68 ) }
239247
240248func testRecvTransactions (t * testing.T , protocol uint ) {
241249 t .Parallel ()
@@ -293,6 +301,8 @@ func testRecvTransactions(t *testing.T, protocol uint) {
293301
294302// This test checks that pending transactions are sent.
295303func TestSendTransactions66 (t * testing.T ) { testSendTransactions (t , eth .ETH66 ) }
304+ func TestSendTransactions67 (t * testing.T ) { testSendTransactions (t , eth .ETH67 ) }
305+ func TestSendTransactions68 (t * testing.T ) { testSendTransactions (t , eth .ETH68 ) }
296306
297307func testSendTransactions (t * testing.T , protocol uint ) {
298308 t .Parallel ()
@@ -351,7 +361,7 @@ func testSendTransactions(t *testing.T, protocol uint) {
351361 seen := make (map [common.Hash ]struct {})
352362 for len (seen ) < len (insert ) {
353363 switch protocol {
354- case 65 , 66 :
364+ case 65 , 66 , 67 , 68 :
355365 select {
356366 case hashes := <- anns :
357367 for _ , hash := range hashes {
@@ -378,6 +388,8 @@ func testSendTransactions(t *testing.T, protocol uint) {
378388// Tests that transactions get propagated to all attached peers, either via direct
379389// broadcasts or via announcements/retrievals.
380390func TestTransactionPropagation66 (t * testing.T ) { testTransactionPropagation (t , eth .ETH66 ) }
391+ func TestTransactionPropagation67 (t * testing.T ) { testTransactionPropagation (t , eth .ETH67 ) }
392+ func TestTransactionPropagation68 (t * testing.T ) { testTransactionPropagation (t , eth .ETH68 ) }
381393
382394func testTransactionPropagation (t * testing.T , protocol uint ) {
383395 t .Parallel ()
@@ -435,12 +447,13 @@ func testTransactionPropagation(t *testing.T, protocol uint) {
435447
436448 // Iterate through all the sinks and ensure they all got the transactions
437449 for i := range sinks {
438- for arrived := 0 ; arrived < len (txs ); {
450+ for arrived , timeout := 0 , false ; arrived < len (txs ) && ! timeout ; {
439451 select {
440452 case event := <- txChs [i ]:
441453 arrived += len (event .Txs )
442- case <- time .NewTimer (time .Second ). C :
454+ case <- time .After (time .Second ):
443455 t .Errorf ("sink %d: transaction propagation timed out: have %d, want %d" , i , arrived , len (txs ))
456+ timeout = true
444457 }
445458 }
446459 }
@@ -486,7 +499,6 @@ func TestCheckpointChallenge(t *testing.T) {
486499}
487500
488501func testCheckpointChallenge (t * testing.T , syncmode downloader.SyncMode , checkpoint bool , timeout bool , empty bool , match bool , drop bool ) {
489-
490502 // Reduce the checkpoint handshake challenge timeout
491503 defer func (old time.Duration ) { syncChallengeTimeout = old }(syncChallengeTimeout )
492504 syncChallengeTimeout = 250 * time .Millisecond
@@ -676,6 +688,8 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) {
676688// Tests that a propagated malformed block (uncles or transactions don't match
677689// with the hashes in the header) gets discarded and not broadcast forward.
678690func TestBroadcastMalformedBlock66 (t * testing.T ) { testBroadcastMalformedBlock (t , eth .ETH66 ) }
691+ func TestBroadcastMalformedBlock67 (t * testing.T ) { testBroadcastMalformedBlock (t , eth .ETH67 ) }
692+ func TestBroadcastMalformedBlock68 (t * testing.T ) { testBroadcastMalformedBlock (t , eth .ETH68 ) }
679693
680694func testBroadcastMalformedBlock (t * testing.T , protocol uint ) {
681695 t .Parallel ()
0 commit comments