cmd/devp2p/internal/ethtest: ignore block announcement in tx test (#22957)

This commit is contained in:
Felix Lange 2021-05-27 20:53:33 +02:00 committed by GitHub
parent 04cb5e2be3
commit ee35ddc8fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -732,17 +732,20 @@ func (s *Suite) TestNewPooledTxs66(t *utesting.T) {
if err := s.sendNextBlock(eth66); err != nil { if err := s.sendNextBlock(eth66); err != nil {
t.Fatalf("failed to send next block: %v", err) t.Fatalf("failed to send next block: %v", err)
} }
// generate 50 txs // generate 50 txs
hashMap, _, err := generateTxs(s, 50) hashMap, _, err := generateTxs(s, 50)
if err != nil { if err != nil {
t.Fatalf("failed to generate transactions: %v", err) t.Fatalf("failed to generate transactions: %v", err)
} }
// create new pooled tx hashes announcement // create new pooled tx hashes announcement
hashes := make([]common.Hash, 0) hashes := make([]common.Hash, 0)
for _, hash := range hashMap { for _, hash := range hashMap {
hashes = append(hashes, hash) hashes = append(hashes, hash)
} }
announce := NewPooledTransactionHashes(hashes) announce := NewPooledTransactionHashes(hashes)
// send announcement // send announcement
conn, err := s.dial66() conn, err := s.dial66()
if err != nil { if err != nil {
@ -755,6 +758,7 @@ func (s *Suite) TestNewPooledTxs66(t *utesting.T) {
if err = conn.Write(announce); err != nil { if err = conn.Write(announce); err != nil {
t.Fatalf("failed to write to connection: %v", err) t.Fatalf("failed to write to connection: %v", err)
} }
// wait for GetPooledTxs request // wait for GetPooledTxs request
for { for {
_, msg := conn.readAndServe66(s.chain, timeout) _, msg := conn.readAndServe66(s.chain, timeout)
@ -764,8 +768,13 @@ func (s *Suite) TestNewPooledTxs66(t *utesting.T) {
t.Fatalf("unexpected number of txs requested: wanted %d, got %d", len(hashes), len(msg)) t.Fatalf("unexpected number of txs requested: wanted %d, got %d", len(hashes), len(msg))
} }
return return
// ignore propagated txs from previous tests
case *NewPooledTransactionHashes: case *NewPooledTransactionHashes:
// ignore propagated txs from old tests continue
// ignore block announcements from previous tests
case *NewBlockHashes:
continue
case *NewBlock:
continue continue
default: default:
t.Fatalf("unexpected %s", pretty.Sdump(msg)) t.Fatalf("unexpected %s", pretty.Sdump(msg))