github.com/ledgerwatch/erigon-lib@v1.0.0/types/txn_packets_fuzz_test.go (about)

     1  //go:build !nofuzz
     2  
     3  package types
     4  
     5  import (
     6  	"testing"
     7  
     8  	"github.com/ledgerwatch/erigon-lib/common/hexutility"
     9  	"github.com/ledgerwatch/erigon-lib/common/u256"
    10  )
    11  
    12  func FuzzPooledTransactions66(f *testing.F) {
    13  	f.Add([]byte{})
    14  	f.Add(hexutility.MustDecodeHex("f8d7820457f8d2f867088504a817c8088302e2489435353535353535353535353535353535353535358202008025a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10f867098504a817c809830334509435353535353535353535353535353535353535358202d98025a052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afba052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb"))
    15  	f.Add(hexutility.MustDecodeHex("d78257f8d2f83535358202008025a00010702dfeccc57dd2d2d2d2d2d2322a463ad555a2018d2bad0203390a0a0a0a0a0a0a256d01f62b45b2e1c21c"))
    16  	f.Add(hexutility.MustDecodeHex("e8bfffffffffffffffffffffffff71e866666666955ef90c91f9fa08f96ebfbfbf007d765059effe33"))
    17  	f.Fuzz(func(t *testing.T, in []byte) {
    18  		t.Parallel()
    19  		ctx := NewTxParseContext(*u256.N1)
    20  		slots := TxSlots{}
    21  		reqId, _, err := ParsePooledTransactions66(in, 0, ctx, &slots, nil)
    22  		if err != nil {
    23  			t.Skip()
    24  		}
    25  
    26  		var rlpTxs [][]byte
    27  		for i := range slots.Txs {
    28  			rlpTxs = append(rlpTxs, slots.Txs[i].Rlp)
    29  		}
    30  		_ = EncodePooledTransactions66(rlpTxs, reqId, nil)
    31  		if err != nil {
    32  			t.Skip()
    33  		}
    34  	})
    35  }
    36  
    37  func FuzzGetPooledTransactions66(f *testing.F) {
    38  	f.Add([]byte{})
    39  	f.Add(hexutility.MustDecodeHex("e68306f854e1a0595e27a835cd79729ff1eeacec3120eeb6ed1464a04ec727aaca734ead961328"))
    40  	f.Fuzz(func(t *testing.T, in []byte) {
    41  		t.Parallel()
    42  		reqId, hashes, _, err := ParseGetPooledTransactions66(in, 0, nil)
    43  		if err != nil {
    44  			t.Skip()
    45  		}
    46  
    47  		_, err = EncodeGetPooledTransactions66(hashes, reqId, nil)
    48  		if err != nil {
    49  			t.Skip()
    50  		}
    51  	})
    52  }