4444 cfg * config.Config
4545 testApps * testcontainers.TestcontainerApps
4646 txTypes = []string {"LegacyTx" , "DynamicFeeTx" , "DynamicFeeTx" }
47- txBlob = []* kzg4844.Blob {nil , nil , randBlob () }
47+ txBlob = []* kzg4844.Blob {nil , nil , randBlobs ( 2 )[ 0 ] }
4848 txUint8Types = []uint8 {0 , 2 , 3 }
4949 db * gorm.DB
5050 testContractsAddress common.Address
@@ -185,7 +185,7 @@ func testSendAndRetrieveTransaction(t *testing.T) {
185185 s , err := NewSender (context .Background (), & cfgCopy , signerConfig , "test" , "test" , types .SenderTypeUnknown , db , nil )
186186 assert .NoError (t , err )
187187
188- hash , err := s .SendTransaction ("0" , & common.Address {}, nil , txBlob [i ], 0 )
188+ hash , err := s .SendTransaction ("0" , & common.Address {}, nil , [] * kzg4844. Blob { txBlob [i ]} , 0 )
189189 assert .NoError (t , err )
190190 txs , err := s .pendingTransactionOrm .GetPendingOrReplacedTransactionsBySenderType (context .Background (), s .senderType , 1 )
191191 assert .NoError (t , err )
@@ -225,7 +225,7 @@ func testFallbackGasLimit(t *testing.T) {
225225 assert .NoError (t , err )
226226
227227 // FallbackGasLimit = 0
228- txHash0 , err := s .SendTransaction ("0" , & common.Address {}, nil , txBlob [i ], 0 )
228+ txHash0 , err := s .SendTransaction ("0" , & common.Address {}, nil , [] * kzg4844. Blob { txBlob [i ]} , 0 )
229229 assert .NoError (t , err )
230230 tx0 , _ , err := client .TransactionByHash (context .Background (), txHash0 )
231231 assert .NoError (t , err )
@@ -245,7 +245,7 @@ func testFallbackGasLimit(t *testing.T) {
245245 },
246246 )
247247
248- txHash1 , err := s .SendTransaction ("1" , & common.Address {}, nil , txBlob [i ], 100000 )
248+ txHash1 , err := s .SendTransaction ("1" , & common.Address {}, nil , [] * kzg4844. Blob { txBlob [i ]} , 100000 )
249249 assert .NoError (t , err )
250250 tx1 , _ , err := client .TransactionByHash (context .Background (), txHash1 )
251251 assert .NoError (t , err )
@@ -329,7 +329,7 @@ func testAccessListTransactionGasLimit(t *testing.T) {
329329
330330 var sidecar * gethTypes.BlobTxSidecar
331331 if txBlob [i ] != nil {
332- sidecar , err = makeSidecar (txBlob [i ])
332+ sidecar , err = makeSidecar ([] * kzg4844. Blob { txBlob [i ]} )
333333 assert .NoError (t , err )
334334 }
335335
@@ -370,7 +370,7 @@ func testResubmitNonZeroGasPriceTransaction(t *testing.T) {
370370 }
371371 var sidecar * gethTypes.BlobTxSidecar
372372 if txBlob [i ] != nil {
373- sidecar , err = makeSidecar (txBlob [i ])
373+ sidecar , err = makeSidecar ([] * kzg4844. Blob { txBlob [i ]} )
374374 assert .NoError (t , err )
375375 }
376376 tx , err := s .createTx (feeData , & common.Address {}, nil , sidecar , s .transactionSigner .GetNonce ())
@@ -505,7 +505,7 @@ func testResubmitBlobTransactionWithRisingBaseFeeAndBlobBaseFee(t *testing.T) {
505505 })
506506 defer patchGuard .Reset ()
507507
508- sidecar , err := makeSidecar (randBlob ( ))
508+ sidecar , err := makeSidecar (randBlobs ( 1 ))
509509 assert .NoError (t , err )
510510 tx := gethTypes .NewTx (& gethTypes.BlobTx {
511511 ChainID : uint256 .MustFromBig (s .chainID ),
@@ -579,10 +579,10 @@ func testResubmitNonceGappedTransaction(t *testing.T) {
579579 return nil , errors .New ("simulated transaction receipt error" )
580580 })
581581
582- _ , err = s .SendTransaction ("test-1" , & common.Address {}, nil , txBlob [i ], 0 )
582+ _ , err = s .SendTransaction ("test-1" , & common.Address {}, nil , [] * kzg4844. Blob { txBlob [i ]} , 0 )
583583 assert .NoError (t , err )
584584
585- _ , err = s .SendTransaction ("test-2" , & common.Address {}, nil , txBlob [i ], 0 )
585+ _ , err = s .SendTransaction ("test-2" , & common.Address {}, nil , [] * kzg4844. Blob { txBlob [i ]} , 0 )
586586 assert .NoError (t , err )
587587
588588 s .checkPendingTransaction ()
@@ -623,7 +623,7 @@ func testCheckPendingTransactionTxConfirmed(t *testing.T) {
623623 return nil
624624 })
625625
626- _ , err = s .SendTransaction ("test" , & common.Address {}, nil , randBlob ( ), 0 )
626+ _ , err = s .SendTransaction ("test" , & common.Address {}, nil , randBlobs ( 1 ), 0 )
627627 assert .NoError (t , err )
628628
629629 txs , err := s .pendingTransactionOrm .GetPendingOrReplacedTransactionsBySenderType (context .Background (), s .senderType , 1 )
@@ -665,7 +665,7 @@ func testCheckPendingTransactionResubmitTxConfirmed(t *testing.T) {
665665 return nil
666666 })
667667
668- originTxHash , err := s .SendTransaction ("test" , & common.Address {}, nil , randBlob ( ), 0 )
668+ originTxHash , err := s .SendTransaction ("test" , & common.Address {}, nil , randBlobs ( 1 ), 0 )
669669 assert .NoError (t , err )
670670
671671 txs , err := s .pendingTransactionOrm .GetPendingOrReplacedTransactionsBySenderType (context .Background (), s .senderType , 1 )
@@ -725,7 +725,7 @@ func testCheckPendingTransactionReplacedTxConfirmed(t *testing.T) {
725725 return nil
726726 })
727727
728- txHash , err := s .SendTransaction ("test" , & common.Address {}, nil , randBlob ( ), 0 )
728+ txHash , err := s .SendTransaction ("test" , & common.Address {}, nil , randBlobs ( 1 ), 0 )
729729 assert .NoError (t , err )
730730
731731 txs , err := s .pendingTransactionOrm .GetPendingOrReplacedTransactionsBySenderType (context .Background (), s .senderType , 1 )
@@ -795,7 +795,7 @@ func testCheckPendingTransactionTxMultipleTimesWithOnlyOneTxPending(t *testing.T
795795 return nil
796796 })
797797
798- _ , err = s .SendTransaction ("test" , & common.Address {}, nil , randBlob ( ), 0 )
798+ _ , err = s .SendTransaction ("test" , & common.Address {}, nil , randBlobs ( 1 ), 0 )
799799 assert .NoError (t , err )
800800
801801 txs , err := s .pendingTransactionOrm .GetPendingOrReplacedTransactionsBySenderType (context .Background (), s .senderType , 1 )
@@ -832,8 +832,8 @@ func testBlobTransactionWithBlobhashOpContractCall(t *testing.T) {
832832 assert .NoError (t , err )
833833 assert .NoError (t , migrate .ResetDB (sqlDB ))
834834
835- blob := randBlob ( )
836- sideCar , err := makeSidecar (blob )
835+ blobs := randBlobs ( 1 )
836+ sideCar , err := makeSidecar (blobs )
837837 assert .NoError (t , err )
838838 versionedHash := sideCar .BlobHashes ()[0 ]
839839 blsModulo , ok := new (big.Int ).SetString ("52435875175126190479447740508185965837690552500527637822603658699938581184513" , 10 )
@@ -845,7 +845,7 @@ func testBlobTransactionWithBlobhashOpContractCall(t *testing.T) {
845845 var point kzg4844.Point
846846 copy (point [start :], pointBytes )
847847 commitment := sideCar .Commitments [0 ]
848- proof , claim , err := kzg4844 .ComputeProof (blob , point )
848+ proof , claim , err := kzg4844 .ComputeProof (blobs [ 0 ] , point )
849849 assert .NoError (t , err )
850850
851851 var claimArray [32 ]byte
@@ -869,7 +869,7 @@ func testBlobTransactionWithBlobhashOpContractCall(t *testing.T) {
869869 assert .NoError (t , err )
870870 defer s .Stop ()
871871
872- _ , err = s .SendTransaction ("0" , & testContractsAddress , data , blob , 0 )
872+ _ , err = s .SendTransaction ("0" , & testContractsAddress , data , blobs , 0 )
873873 assert .NoError (t , err )
874874
875875 var txHash common.Hash
@@ -889,13 +889,19 @@ func testBlobTransactionWithBlobhashOpContractCall(t *testing.T) {
889889 }, 30 * time .Second , time .Second )
890890}
891891
892- func randBlob () * kzg4844.Blob {
893- var blob kzg4844.Blob
894- for i := 0 ; i < len (blob ); i += gokzg4844 .SerializedScalarSize {
895- fieldElementBytes := randFieldElement ()
896- copy (blob [i :i + gokzg4844 .SerializedScalarSize ], fieldElementBytes [:])
892+ func randBlobs (count int ) []* kzg4844.Blob {
893+ blobs := make ([]* kzg4844.Blob , 0 , count )
894+
895+ for c := 0 ; c < count ; c ++ {
896+ var blob kzg4844.Blob
897+ for i := 0 ; i < len (blob ); i += gokzg4844 .SerializedScalarSize {
898+ fieldElementBytes := randFieldElement ()
899+ copy (blob [i :i + gokzg4844 .SerializedScalarSize ], fieldElementBytes [:])
900+ }
901+ blobs = append (blobs , & blob )
897902 }
898- return & blob
903+
904+ return blobs
899905}
900906
901907func randFieldElement () [32 ]byte {
@@ -921,10 +927,10 @@ func testSendBlobCarryingTxOverLimit(t *testing.T) {
921927 assert .NoError (t , err )
922928
923929 for i := 0 ; i < int (cfgCopy .MaxPendingBlobTxs ); i ++ {
924- _ , err = s .SendTransaction ("0" , & common.Address {}, nil , randBlob ( ), 0 )
930+ _ , err = s .SendTransaction ("0" , & common.Address {}, nil , randBlobs ( 1 ), 0 )
925931 assert .NoError (t , err )
926932 }
927- _ , err = s .SendTransaction ("0" , & common.Address {}, nil , randBlob ( ), 0 )
933+ _ , err = s .SendTransaction ("0" , & common.Address {}, nil , randBlobs ( 1 ), 0 )
928934 assert .ErrorIs (t , err , ErrTooManyPendingBlobTxs )
929935 s .Stop ()
930936}
0 commit comments