@@ -80,6 +80,7 @@ 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 ) }
8384func TestForkIDSplit66 (t * testing.T ) { testForkIDSplit (t , eth .ETH66 ) }
8485
8586func testForkIDSplit (t * testing.T , protocol uint ) {
@@ -235,6 +236,7 @@ func testForkIDSplit(t *testing.T, protocol uint) {
235236}
236237
237238// Tests that received transactions are added to the local pool.
239+ func TestRecvTransactions65 (t * testing.T ) { testRecvTransactions (t , eth .ETH65 ) }
238240func TestRecvTransactions66 (t * testing.T ) { testRecvTransactions (t , eth .ETH66 ) }
239241
240242func testRecvTransactions (t * testing.T , protocol uint ) {
@@ -292,6 +294,7 @@ func testRecvTransactions(t *testing.T, protocol uint) {
292294}
293295
294296// This test checks that pending transactions are sent.
297+ func TestSendTransactions65 (t * testing.T ) { testSendTransactions (t , eth .ETH65 ) }
295298func TestSendTransactions66 (t * testing.T ) { testSendTransactions (t , eth .ETH66 ) }
296299
297300func testSendTransactions (t * testing.T , protocol uint ) {
@@ -303,7 +306,7 @@ func testSendTransactions(t *testing.T, protocol uint) {
303306
304307 insert := make ([]* types.Transaction , 100 )
305308 for nonce := range insert {
306- tx := types .NewTransaction (uint64 (nonce ), common.Address {}, big .NewInt (0 ), 100000 , big .NewInt (0 ), make ([]byte , 10240 ))
309+ tx := types .NewTransaction (uint64 (nonce ), common.Address {}, big .NewInt (0 ), 100000 , big .NewInt (0 ), make ([]byte , txsyncPackSize / 10 ))
307310 tx , _ = types .SignTx (tx , types.HomesteadSigner {}, testKey )
308311
309312 insert [nonce ] = tx
@@ -377,6 +380,7 @@ func testSendTransactions(t *testing.T, protocol uint) {
377380
378381// Tests that transactions get propagated to all attached peers, either via direct
379382// broadcasts or via announcements/retrievals.
383+ func TestTransactionPropagation65 (t * testing.T ) { testTransactionPropagation (t , eth .ETH65 ) }
380384func TestTransactionPropagation66 (t * testing.T ) { testTransactionPropagation (t , eth .ETH66 ) }
381385
382386func testTransactionPropagation (t * testing.T , protocol uint ) {
@@ -517,8 +521,8 @@ func testCheckpointChallenge(t *testing.T, syncmode downloader.SyncMode, checkpo
517521 defer p2pLocal .Close ()
518522 defer p2pRemote .Close ()
519523
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 )
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 )
522526 defer local .Close ()
523527 defer remote .Close ()
524528
@@ -539,39 +543,30 @@ func testCheckpointChallenge(t *testing.T, syncmode downloader.SyncMode, checkpo
539543 if err := remote .Handshake (1 , td , head .Hash (), genesis .Hash (), forkid .NewIDWithChain (handler .chain ), forkid .NewFilter (handler .chain )); err != nil {
540544 t .Fatalf ("failed to run protocol handshake" )
541545 }
546+
542547 // Connect a new peer and check that we receive the checkpoint challenge.
543548 if checkpoint {
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 )
549+ if err := remote .ExpectRequestHeadersByNumber (response .Number .Uint64 (), 1 , 0 , false ); err != nil {
550+ t .Fatalf ("challenge mismatch: %v" , err )
557551 }
558552 // Create a block to reply to the challenge if no timeout is simulated.
559553 if ! timeout {
560554 if empty {
561- if err := remote .ReplyBlockHeaders ( request . RequestId , []* types.Header {}); err != nil {
555+ if err := remote .SendBlockHeaders ( []* types.Header {}); err != nil {
562556 t .Fatalf ("failed to answer challenge: %v" , err )
563557 }
564558 } else if match {
565- if err := remote .ReplyBlockHeaders ( request . RequestId , []* types.Header {response }); err != nil {
559+ if err := remote .SendBlockHeaders ( []* types.Header {response }); err != nil {
566560 t .Fatalf ("failed to answer challenge: %v" , err )
567561 }
568562 } else {
569- if err := remote .ReplyBlockHeaders ( request . RequestId , []* types.Header {{Number : response .Number }}); err != nil {
563+ if err := remote .SendBlockHeaders ( []* types.Header {{Number : response .Number }}); err != nil {
570564 t .Fatalf ("failed to answer challenge: %v" , err )
571565 }
572566 }
573567 }
574568 }
569+
575570 // Wait until the test timeout passes to ensure proper cleanup
576571 time .Sleep (syncChallengeTimeout + 300 * time .Millisecond )
577572
@@ -624,8 +619,8 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) {
624619 defer sourcePipe .Close ()
625620 defer sinkPipe .Close ()
626621
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 )
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 )
629624 defer sourcePeer .Close ()
630625 defer sinkPeer .Close ()
631626
@@ -676,6 +671,7 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) {
676671
677672// Tests that a propagated malformed block (uncles or transactions don't match
678673// with the hashes in the header) gets discarded and not broadcast forward.
674+ func TestBroadcastMalformedBlock65 (t * testing.T ) { testBroadcastMalformedBlock (t , eth .ETH65 ) }
679675func TestBroadcastMalformedBlock66 (t * testing.T ) { testBroadcastMalformedBlock (t , eth .ETH66 ) }
680676
681677func testBroadcastMalformedBlock (t * testing.T , protocol uint ) {
0 commit comments