@@ -450,6 +450,49 @@ func testTransactionPropagation(t *testing.T, protocol uint) {
450
450
}
451
451
}
452
452
453
+ // Tests that local pending transactions get propagated to peers.
454
+ func TestTransactionPendingReannounce (t * testing.T ) {
455
+ t .Parallel ()
456
+
457
+ // Create a source handler to send transactions from and a number of sinks
458
+ // to receive them. We need multiple sinks since a one-to-one peering would
459
+ // broadcast all transactions without announcement.
460
+ source := newTestHandler ()
461
+ defer source .close ()
462
+
463
+ sink := newTestHandler ()
464
+ defer sink .close ()
465
+ sink .handler .acceptTxs = 1 // mark synced to accept transactions
466
+
467
+ sourcePipe , sinkPipe := p2p .MsgPipe ()
468
+ defer sourcePipe .Close ()
469
+ defer sinkPipe .Close ()
470
+
471
+ sourcePeer := eth .NewPeer (eth .ETH65 , p2p .NewPeer (enode.ID {0 }, "" , nil ), sourcePipe , source .txpool )
472
+ sinkPeer := eth .NewPeer (eth .ETH65 , p2p .NewPeer (enode.ID {0 }, "" , nil ), sinkPipe , sink .txpool )
473
+ defer sourcePeer .Close ()
474
+ defer sinkPeer .Close ()
475
+
476
+ go source .handler .runEthPeer (sourcePeer , func (peer * eth.Peer ) error {
477
+ return eth .Handle ((* ethHandler )(source .handler ), peer )
478
+ })
479
+ go sink .handler .runEthPeer (sinkPeer , func (peer * eth.Peer ) error {
480
+ return eth .Handle ((* ethHandler )(sink .handler ), peer )
481
+ })
482
+
483
+ txs := make ([]* types.Transaction , 64 )
484
+ for nonce := range txs {
485
+ tx := types .NewTransaction (uint64 (nonce ), common.Address {}, big .NewInt (0 ), 100000 , big .NewInt (0 ), nil )
486
+ tx , _ = types .SignTx (tx , types.HomesteadSigner {}, testKey )
487
+
488
+ txs [nonce ] = tx
489
+ }
490
+ source .txpool .ReannouceTransactions (txs )
491
+
492
+ // How to ensure sink has received announce transaction?
493
+
494
+ }
495
+
453
496
// Tests that post eth protocol handshake, clients perform a mutual checkpoint
454
497
// challenge to validate each other's chains. Hash mismatches, or missing ones
455
498
// during a fast sync should lead to the peer getting dropped.
0 commit comments