@@ -95,7 +95,7 @@ func sendSuccessfulTx(s *Suite, tx *types.Transaction, prevTx *types.Transaction
9595 }
9696 }
9797 return fmt .Errorf ("missing transaction: got %v missing %v" , recTxs , tx .Hash ())
98- case * NewPooledTransactionHashes :
98+ case * NewPooledTransactionHashes66 :
9999 txHashes := * msg
100100 // if you receive an old tx propagation, read from connection again
101101 if len (txHashes ) == 1 && prevTx != nil {
@@ -110,6 +110,34 @@ func sendSuccessfulTx(s *Suite, tx *types.Transaction, prevTx *types.Transaction
110110 }
111111 }
112112 return fmt .Errorf ("missing transaction announcement: got %v missing %v" , txHashes , tx .Hash ())
113+ case * NewPooledTransactionHashes :
114+ txHashes := msg .Hashes
115+ if len (txHashes ) != len (msg .Sizes ) {
116+ return fmt .Errorf ("invalid msg size lengths: hashes: %v sizes: %v" , len (txHashes ), len (msg .Sizes ))
117+ }
118+ if len (txHashes ) != len (msg .Types ) {
119+ return fmt .Errorf ("invalid msg type lengths: hashes: %v types: %v" , len (txHashes ), len (msg .Types ))
120+ }
121+ // if you receive an old tx propagation, read from connection again
122+ if len (txHashes ) == 1 && prevTx != nil {
123+ if txHashes [0 ] == prevTx .Hash () {
124+ continue
125+ }
126+ }
127+ for index , gotHash := range txHashes {
128+ if gotHash == tx .Hash () {
129+ if msg .Sizes [index ] != uint32 (tx .Size ()) {
130+ return fmt .Errorf ("invalid tx size: got %v want %v" , msg .Sizes [index ], tx .Size ())
131+ }
132+ if msg .Types [index ] != tx .Type () {
133+ return fmt .Errorf ("invalid tx type: got %v want %v" , msg .Types [index ], tx .Type ())
134+ }
135+ // Ok
136+ return nil
137+ }
138+ }
139+ return fmt .Errorf ("missing transaction announcement: got %v missing %v" , txHashes , tx .Hash ())
140+
113141 default :
114142 return fmt .Errorf ("unexpected message in sendSuccessfulTx: %s" , pretty .Sdump (msg ))
115143 }
@@ -201,8 +229,10 @@ func sendMultipleSuccessfulTxs(t *utesting.T, s *Suite, txs []*types.Transaction
201229 for _ , tx := range * msg {
202230 recvHashes = append (recvHashes , tx .Hash ())
203231 }
204- case * NewPooledTransactionHashes :
232+ case * NewPooledTransactionHashes66 :
205233 recvHashes = append (recvHashes , * msg ... )
234+ case * NewPooledTransactionHashes :
235+ recvHashes = append (recvHashes , msg .Hashes ... )
206236 default :
207237 if ! strings .Contains (pretty .Sdump (msg ), "i/o timeout" ) {
208238 return fmt .Errorf ("unexpected message while waiting to receive txs: %s" , pretty .Sdump (msg ))
@@ -246,11 +276,16 @@ func checkMaliciousTxPropagation(s *Suite, txs []*types.Transaction, conn *Conn)
246276 if len (badTxs ) > 0 {
247277 return fmt .Errorf ("received %d bad txs: \n %v" , len (badTxs ), badTxs )
248278 }
249- case * NewPooledTransactionHashes :
279+ case * NewPooledTransactionHashes66 :
250280 badTxs , _ := compareReceivedTxs (* msg , txs )
251281 if len (badTxs ) > 0 {
252282 return fmt .Errorf ("received %d bad txs: \n %v" , len (badTxs ), badTxs )
253283 }
284+ case * NewPooledTransactionHashes :
285+ badTxs , _ := compareReceivedTxs (msg .Hashes , txs )
286+ if len (badTxs ) > 0 {
287+ return fmt .Errorf ("received %d bad txs: \n %v" , len (badTxs ), badTxs )
288+ }
254289 case * Error :
255290 // Transaction should not be announced -> wait for timeout
256291 return nil
0 commit comments