From a22c4a0124ff597b7e0376adc87666d4c18eba8a Mon Sep 17 00:00:00 2001 From: Arunima Chaudhuri Date: Wed, 11 Jun 2025 02:30:10 +0530 Subject: [PATCH] add unit test for GetPooledTransactionsMsg --- eth/protocols/eth/handler_test.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/eth/protocols/eth/handler_test.go b/eth/protocols/eth/handler_test.go index 2fa10dfa9d..f3dfd87a4e 100644 --- a/eth/protocols/eth/handler_test.go +++ b/eth/protocols/eth/handler_test.go @@ -688,14 +688,26 @@ func testGetPooledTransaction(t *testing.T, blobTx bool) { } } - // Send the hash request and verify the response + hashes := []common.Hash{tx.Hash()} + p2p.Send(peer.app, GetPooledTransactionsMsg, GetPooledTransactionsPacket{ RequestId: 123, - GetPooledTransactionsRequest: []common.Hash{tx.Hash()}, + GetPooledTransactionsRequest: hashes, }) + + var expectedTxs []*types.Transaction + peerIDLast4 := peer.ID()[len(peer.ID())-1] & 0x0F + + for _, tx := range []*types.Transaction{tx} { + txHashLast4 := tx.Hash().Bytes()[len(tx.Hash().Bytes())-1] & 0x0F + if peerIDLast4 != txHashLast4 { + expectedTxs = append(expectedTxs, tx) + } + } + if err := p2p.ExpectMsg(peer.app, PooledTransactionsMsg, PooledTransactionsPacket{ RequestId: 123, - PooledTransactionsResponse: []*types.Transaction{tx}, + PooledTransactionsResponse: expectedTxs, }); err != nil { t.Errorf("pooled transaction mismatch: %v", err) }