@@ -80,7 +80,6 @@ func (h *testEthHandler) Handle(peer *eth.Peer, packet eth.Packet) error {
8080
8181// Tests that peers are correctly accepted (or rejected) based on the advertised
8282// fork IDs in the protocol handshake.
83- func TestForkIDSplit65 (t * testing.T ) { testForkIDSplit (t , eth .ETH65 ) }
8483func TestForkIDSplit66 (t * testing.T ) { testForkIDSplit (t , eth .ETH66 ) }
8584
8685func testForkIDSplit (t * testing.T , protocol uint ) {
@@ -236,7 +235,6 @@ func testForkIDSplit(t *testing.T, protocol uint) {
236235}
237236
238237// Tests that received transactions are added to the local pool.
239- func TestRecvTransactions65 (t * testing.T ) { testRecvTransactions (t , eth .ETH65 ) }
240238func TestRecvTransactions66 (t * testing.T ) { testRecvTransactions (t , eth .ETH66 ) }
241239
242240func testRecvTransactions (t * testing.T , protocol uint ) {
@@ -294,7 +292,6 @@ func testRecvTransactions(t *testing.T, protocol uint) {
294292}
295293
296294// This test checks that pending transactions are sent.
297- func TestSendTransactions65 (t * testing.T ) { testSendTransactions (t , eth .ETH65 ) }
298295func TestSendTransactions66 (t * testing.T ) { testSendTransactions (t , eth .ETH66 ) }
299296
300297func testSendTransactions (t * testing.T , protocol uint ) {
@@ -306,7 +303,7 @@ func testSendTransactions(t *testing.T, protocol uint) {
306303
307304 insert := make ([]* types.Transaction , 100 )
308305 for nonce := range insert {
309- tx := types .NewTransaction (uint64 (nonce ), common.Address {}, big .NewInt (0 ), 100000 , big .NewInt (0 ), make ([]byte , txsyncPackSize / 10 ))
306+ tx := types .NewTransaction (uint64 (nonce ), common.Address {}, big .NewInt (0 ), 100000 , big .NewInt (0 ), make ([]byte , 10240 ))
310307 tx , _ = types .SignTx (tx , types.HomesteadSigner {}, testKey )
311308
312309 insert [nonce ] = tx
@@ -380,7 +377,6 @@ func testSendTransactions(t *testing.T, protocol uint) {
380377
381378// Tests that transactions get propagated to all attached peers, either via direct
382379// broadcasts or via announcements/retrievals.
383- func TestTransactionPropagation65 (t * testing.T ) { testTransactionPropagation (t , eth .ETH65 ) }
384380func TestTransactionPropagation66 (t * testing.T ) { testTransactionPropagation (t , eth .ETH66 ) }
385381
386382func testTransactionPropagation (t * testing.T , protocol uint ) {
@@ -521,8 +517,8 @@ func testCheckpointChallenge(t *testing.T, syncmode downloader.SyncMode, checkpo
521517 defer p2pLocal .Close ()
522518 defer p2pRemote .Close ()
523519
524- local := eth .NewPeer (eth .ETH65 , p2p .NewPeerPipe (enode.ID {1 }, "" , nil , p2pLocal ), p2pLocal , handler .txpool )
525- remote := eth .NewPeer (eth .ETH65 , p2p .NewPeerPipe (enode.ID {2 }, "" , nil , p2pRemote ), p2pRemote , handler .txpool )
520+ local := eth .NewPeer (eth .ETH66 , p2p .NewPeerPipe (enode.ID {1 }, "" , nil , p2pLocal ), p2pLocal , handler .txpool )
521+ remote := eth .NewPeer (eth .ETH66 , p2p .NewPeerPipe (enode.ID {2 }, "" , nil , p2pRemote ), p2pRemote , handler .txpool )
526522 defer local .Close ()
527523 defer remote .Close ()
528524
@@ -543,30 +539,39 @@ func testCheckpointChallenge(t *testing.T, syncmode downloader.SyncMode, checkpo
543539 if err := remote .Handshake (1 , td , head .Hash (), genesis .Hash (), forkid .NewIDWithChain (handler .chain ), forkid .NewFilter (handler .chain )); err != nil {
544540 t .Fatalf ("failed to run protocol handshake" )
545541 }
546-
547542 // Connect a new peer and check that we receive the checkpoint challenge.
548543 if checkpoint {
549- if err := remote .ExpectRequestHeadersByNumber (response .Number .Uint64 (), 1 , 0 , false ); err != nil {
550- t .Fatalf ("challenge mismatch: %v" , err )
544+ msg , err := p2pRemote .ReadMsg ()
545+ if err != nil {
546+ t .Fatalf ("failed to read checkpoint challenge: %v" , err )
547+ }
548+ request := new (eth.GetBlockHeadersPacket66 )
549+ if err := msg .Decode (request ); err != nil {
550+ t .Fatalf ("failed to decode checkpoint challenge: %v" , err )
551+ }
552+ query := request .GetBlockHeadersPacket
553+ if query .Origin .Number != response .Number .Uint64 () || query .Amount != 1 || query .Skip != 0 || query .Reverse {
554+ t .Fatalf ("challenge mismatch: have [%d, %d, %d, %v] want [%d, %d, %d, %v]" ,
555+ query .Origin .Number , query .Amount , query .Skip , query .Reverse ,
556+ response .Number .Uint64 (), 1 , 0 , false )
551557 }
552558 // Create a block to reply to the challenge if no timeout is simulated.
553559 if ! timeout {
554560 if empty {
555- if err := remote .SendBlockHeaders ( []* types.Header {}); err != nil {
561+ if err := remote .ReplyBlockHeaders ( request . RequestId , []* types.Header {}); err != nil {
556562 t .Fatalf ("failed to answer challenge: %v" , err )
557563 }
558564 } else if match {
559- if err := remote .SendBlockHeaders ( []* types.Header {response }); err != nil {
565+ if err := remote .ReplyBlockHeaders ( request . RequestId , []* types.Header {response }); err != nil {
560566 t .Fatalf ("failed to answer challenge: %v" , err )
561567 }
562568 } else {
563- if err := remote .SendBlockHeaders ( []* types.Header {{Number : response .Number }}); err != nil {
569+ if err := remote .ReplyBlockHeaders ( request . RequestId , []* types.Header {{Number : response .Number }}); err != nil {
564570 t .Fatalf ("failed to answer challenge: %v" , err )
565571 }
566572 }
567573 }
568574 }
569-
570575 // Wait until the test timeout passes to ensure proper cleanup
571576 time .Sleep (syncChallengeTimeout + 300 * time .Millisecond )
572577
@@ -619,8 +624,8 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) {
619624 defer sourcePipe .Close ()
620625 defer sinkPipe .Close ()
621626
622- sourcePeer := eth .NewPeer (eth .ETH65 , p2p .NewPeerPipe (enode.ID {byte (i )}, "" , nil , sourcePipe ), sourcePipe , nil )
623- sinkPeer := eth .NewPeer (eth .ETH65 , p2p .NewPeerPipe (enode.ID {0 }, "" , nil , sinkPipe ), sinkPipe , nil )
627+ sourcePeer := eth .NewPeer (eth .ETH66 , p2p .NewPeerPipe (enode.ID {byte (i )}, "" , nil , sourcePipe ), sourcePipe , nil )
628+ sinkPeer := eth .NewPeer (eth .ETH66 , p2p .NewPeerPipe (enode.ID {0 }, "" , nil , sinkPipe ), sinkPipe , nil )
624629 defer sourcePeer .Close ()
625630 defer sinkPeer .Close ()
626631
@@ -671,7 +676,6 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) {
671676
672677// Tests that a propagated malformed block (uncles or transactions don't match
673678// with the hashes in the header) gets discarded and not broadcast forward.
674- func TestBroadcastMalformedBlock65 (t * testing.T ) { testBroadcastMalformedBlock (t , eth .ETH65 ) }
675679func TestBroadcastMalformedBlock66 (t * testing.T ) { testBroadcastMalformedBlock (t , eth .ETH66 ) }
676680
677681func testBroadcastMalformedBlock (t * testing.T , protocol uint ) {
0 commit comments