mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
add unit test for GetPooledTransactionsMsg
This commit is contained in:
parent
c0991455cd
commit
a22c4a0124
1 changed files with 15 additions and 3 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue