@@ -80,7 +80,6 @@ func (h *testEthHandler) Handle(peer *eth.Peer, packet eth.Packet) error {
80
80
81
81
// Tests that peers are correctly accepted (or rejected) based on the advertised
82
82
// fork IDs in the protocol handshake.
83
- func TestForkIDSplit65 (t * testing.T ) { testForkIDSplit (t , eth .ETH65 ) }
84
83
func TestForkIDSplit66 (t * testing.T ) { testForkIDSplit (t , eth .ETH66 ) }
85
84
86
85
func testForkIDSplit (t * testing.T , protocol uint ) {
@@ -236,7 +235,6 @@ func testForkIDSplit(t *testing.T, protocol uint) {
236
235
}
237
236
238
237
// Tests that received transactions are added to the local pool.
239
- func TestRecvTransactions65 (t * testing.T ) { testRecvTransactions (t , eth .ETH65 ) }
240
238
func TestRecvTransactions66 (t * testing.T ) { testRecvTransactions (t , eth .ETH66 ) }
241
239
242
240
func testRecvTransactions (t * testing.T , protocol uint ) {
@@ -294,7 +292,6 @@ func testRecvTransactions(t *testing.T, protocol uint) {
294
292
}
295
293
296
294
// This test checks that pending transactions are sent.
297
- func TestSendTransactions65 (t * testing.T ) { testSendTransactions (t , eth .ETH65 ) }
298
295
func TestSendTransactions66 (t * testing.T ) { testSendTransactions (t , eth .ETH66 ) }
299
296
300
297
func testSendTransactions (t * testing.T , protocol uint ) {
@@ -306,7 +303,7 @@ func testSendTransactions(t *testing.T, protocol uint) {
306
303
307
304
insert := make ([]* types.Transaction , 100 )
308
305
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 ))
310
307
tx , _ = types .SignTx (tx , types.HomesteadSigner {}, testKey )
311
308
312
309
insert [nonce ] = tx
@@ -380,7 +377,6 @@ func testSendTransactions(t *testing.T, protocol uint) {
380
377
381
378
// Tests that transactions get propagated to all attached peers, either via direct
382
379
// broadcasts or via announcements/retrievals.
383
- func TestTransactionPropagation65 (t * testing.T ) { testTransactionPropagation (t , eth .ETH65 ) }
384
380
func TestTransactionPropagation66 (t * testing.T ) { testTransactionPropagation (t , eth .ETH66 ) }
385
381
386
382
func testTransactionPropagation (t * testing.T , protocol uint ) {
@@ -521,8 +517,8 @@ func testCheckpointChallenge(t *testing.T, syncmode downloader.SyncMode, checkpo
521
517
defer p2pLocal .Close ()
522
518
defer p2pRemote .Close ()
523
519
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 )
526
522
defer local .Close ()
527
523
defer remote .Close ()
528
524
@@ -543,30 +539,39 @@ func testCheckpointChallenge(t *testing.T, syncmode downloader.SyncMode, checkpo
543
539
if err := remote .Handshake (1 , td , head .Hash (), genesis .Hash (), forkid .NewIDWithChain (handler .chain ), forkid .NewFilter (handler .chain )); err != nil {
544
540
t .Fatalf ("failed to run protocol handshake" )
545
541
}
546
-
547
542
// Connect a new peer and check that we receive the checkpoint challenge.
548
543
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 )
551
557
}
552
558
// Create a block to reply to the challenge if no timeout is simulated.
553
559
if ! timeout {
554
560
if empty {
555
- if err := remote .SendBlockHeaders ( []* types.Header {}); err != nil {
561
+ if err := remote .ReplyBlockHeaders ( request . RequestId , []* types.Header {}); err != nil {
556
562
t .Fatalf ("failed to answer challenge: %v" , err )
557
563
}
558
564
} 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 {
560
566
t .Fatalf ("failed to answer challenge: %v" , err )
561
567
}
562
568
} 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 {
564
570
t .Fatalf ("failed to answer challenge: %v" , err )
565
571
}
566
572
}
567
573
}
568
574
}
569
-
570
575
// Wait until the test timeout passes to ensure proper cleanup
571
576
time .Sleep (syncChallengeTimeout + 300 * time .Millisecond )
572
577
@@ -619,8 +624,8 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) {
619
624
defer sourcePipe .Close ()
620
625
defer sinkPipe .Close ()
621
626
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 )
624
629
defer sourcePeer .Close ()
625
630
defer sinkPeer .Close ()
626
631
@@ -671,7 +676,6 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) {
671
676
672
677
// Tests that a propagated malformed block (uncles or transactions don't match
673
678
// with the hashes in the header) gets discarded and not broadcast forward.
674
- func TestBroadcastMalformedBlock65 (t * testing.T ) { testBroadcastMalformedBlock (t , eth .ETH65 ) }
675
679
func TestBroadcastMalformedBlock66 (t * testing.T ) { testBroadcastMalformedBlock (t , eth .ETH66 ) }
676
680
677
681
func testBroadcastMalformedBlock (t * testing.T , protocol uint ) {
0 commit comments