|
|
@ -95,7 +95,7 @@ func sendSuccessfulTx(s *Suite, tx *types.Transaction, prevTx *types.Transaction |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return fmt.Errorf("missing transaction: got %v missing %v", recTxs, tx.Hash()) |
|
|
|
return fmt.Errorf("missing transaction: got %v missing %v", recTxs, tx.Hash()) |
|
|
|
case *NewPooledTransactionHashes: |
|
|
|
case *NewPooledTransactionHashes66: |
|
|
|
txHashes := *msg |
|
|
|
txHashes := *msg |
|
|
|
// if you receive an old tx propagation, read from connection again
|
|
|
|
// if you receive an old tx propagation, read from connection again
|
|
|
|
if len(txHashes) == 1 && prevTx != nil { |
|
|
|
if len(txHashes) == 1 && prevTx != nil { |
|
|
@ -110,6 +110,34 @@ func sendSuccessfulTx(s *Suite, tx *types.Transaction, prevTx *types.Transaction |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return fmt.Errorf("missing transaction announcement: got %v missing %v", txHashes, tx.Hash()) |
|
|
|
return fmt.Errorf("missing transaction announcement: got %v missing %v", txHashes, tx.Hash()) |
|
|
|
|
|
|
|
case *NewPooledTransactionHashes: |
|
|
|
|
|
|
|
txHashes := msg.Hashes |
|
|
|
|
|
|
|
if len(txHashes) != len(msg.Sizes) { |
|
|
|
|
|
|
|
return fmt.Errorf("invalid msg size lengths: hashes: %v sizes: %v", len(txHashes), len(msg.Sizes)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if len(txHashes) != len(msg.Types) { |
|
|
|
|
|
|
|
return fmt.Errorf("invalid msg type lengths: hashes: %v types: %v", len(txHashes), len(msg.Types)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// if you receive an old tx propagation, read from connection again
|
|
|
|
|
|
|
|
if len(txHashes) == 1 && prevTx != nil { |
|
|
|
|
|
|
|
if txHashes[0] == prevTx.Hash() { |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for index, gotHash := range txHashes { |
|
|
|
|
|
|
|
if gotHash == tx.Hash() { |
|
|
|
|
|
|
|
if msg.Sizes[index] != uint32(tx.Size()) { |
|
|
|
|
|
|
|
return fmt.Errorf("invalid tx size: got %v want %v", msg.Sizes[index], tx.Size()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if msg.Types[index] != tx.Type() { |
|
|
|
|
|
|
|
return fmt.Errorf("invalid tx type: got %v want %v", msg.Types[index], tx.Type()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Ok
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return fmt.Errorf("missing transaction announcement: got %v missing %v", txHashes, tx.Hash()) |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
return fmt.Errorf("unexpected message in sendSuccessfulTx: %s", pretty.Sdump(msg)) |
|
|
|
return fmt.Errorf("unexpected message in sendSuccessfulTx: %s", pretty.Sdump(msg)) |
|
|
|
} |
|
|
|
} |
|
|
@ -201,8 +229,10 @@ func sendMultipleSuccessfulTxs(t *utesting.T, s *Suite, txs []*types.Transaction |
|
|
|
for _, tx := range *msg { |
|
|
|
for _, tx := range *msg { |
|
|
|
recvHashes = append(recvHashes, tx.Hash()) |
|
|
|
recvHashes = append(recvHashes, tx.Hash()) |
|
|
|
} |
|
|
|
} |
|
|
|
case *NewPooledTransactionHashes: |
|
|
|
case *NewPooledTransactionHashes66: |
|
|
|
recvHashes = append(recvHashes, *msg...) |
|
|
|
recvHashes = append(recvHashes, *msg...) |
|
|
|
|
|
|
|
case *NewPooledTransactionHashes: |
|
|
|
|
|
|
|
recvHashes = append(recvHashes, msg.Hashes...) |
|
|
|
default: |
|
|
|
default: |
|
|
|
if !strings.Contains(pretty.Sdump(msg), "i/o timeout") { |
|
|
|
if !strings.Contains(pretty.Sdump(msg), "i/o timeout") { |
|
|
|
return fmt.Errorf("unexpected message while waiting to receive txs: %s", pretty.Sdump(msg)) |
|
|
|
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) |
|
|
|
if len(badTxs) > 0 { |
|
|
|
if len(badTxs) > 0 { |
|
|
|
return fmt.Errorf("received %d bad txs: \n%v", len(badTxs), badTxs) |
|
|
|
return fmt.Errorf("received %d bad txs: \n%v", len(badTxs), badTxs) |
|
|
|
} |
|
|
|
} |
|
|
|
case *NewPooledTransactionHashes: |
|
|
|
case *NewPooledTransactionHashes66: |
|
|
|
badTxs, _ := compareReceivedTxs(*msg, txs) |
|
|
|
badTxs, _ := compareReceivedTxs(*msg, txs) |
|
|
|
if len(badTxs) > 0 { |
|
|
|
if len(badTxs) > 0 { |
|
|
|
return fmt.Errorf("received %d bad txs: \n%v", len(badTxs), badTxs) |
|
|
|
return fmt.Errorf("received %d bad txs: \n%v", len(badTxs), badTxs) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
case *NewPooledTransactionHashes: |
|
|
|
|
|
|
|
badTxs, _ := compareReceivedTxs(msg.Hashes, txs) |
|
|
|
|
|
|
|
if len(badTxs) > 0 { |
|
|
|
|
|
|
|
return fmt.Errorf("received %d bad txs: \n%v", len(badTxs), badTxs) |
|
|
|
|
|
|
|
} |
|
|
|
case *Error: |
|
|
|
case *Error: |
|
|
|
// Transaction should not be announced -> wait for timeout
|
|
|
|
// Transaction should not be announced -> wait for timeout
|
|
|
|
return nil |
|
|
|
return nil |
|
|
|