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,11 @@ 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+ var blobs []* kzg4844.Blob
189+ if txBlob [i ] != nil {
190+ blobs = []* kzg4844.Blob {txBlob [i ]}
191+ }
192+ hash , err := s .SendTransaction ("0" , & common.Address {}, nil , blobs , 0 )
189193 assert .NoError (t , err )
190194 txs , err := s .pendingTransactionOrm .GetPendingOrReplacedTransactionsBySenderType (context .Background (), s .senderType , 1 )
191195 assert .NoError (t , err )
@@ -224,8 +228,12 @@ func testFallbackGasLimit(t *testing.T) {
224228 client , err := ethclient .Dial (cfgCopy .Endpoint )
225229 assert .NoError (t , err )
226230
231+ var blobs []* kzg4844.Blob
232+ if txBlob [i ] != nil {
233+ blobs = []* kzg4844.Blob {txBlob [i ]}
234+ }
227235 // FallbackGasLimit = 0
228- txHash0 , err := s .SendTransaction ("0" , & common.Address {}, nil , txBlob [ i ] , 0 )
236+ txHash0 , err := s .SendTransaction ("0" , & common.Address {}, nil , blobs , 0 )
229237 assert .NoError (t , err )
230238 tx0 , _ , err := client .TransactionByHash (context .Background (), txHash0 )
231239 assert .NoError (t , err )
@@ -245,7 +253,7 @@ func testFallbackGasLimit(t *testing.T) {
245253 },
246254 )
247255
248- txHash1 , err := s .SendTransaction ("1" , & common.Address {}, nil , txBlob [ i ] , 100000 )
256+ txHash1 , err := s .SendTransaction ("1" , & common.Address {}, nil , blobs , 100000 )
249257 assert .NoError (t , err )
250258 tx1 , _ , err := client .TransactionByHash (context .Background (), txHash1 )
251259 assert .NoError (t , err )
@@ -329,7 +337,7 @@ func testAccessListTransactionGasLimit(t *testing.T) {
329337
330338 var sidecar * gethTypes.BlobTxSidecar
331339 if txBlob [i ] != nil {
332- sidecar , err = makeSidecar (txBlob [i ])
340+ sidecar , err = makeSidecar ([] * kzg4844. Blob { txBlob [i ]} )
333341 assert .NoError (t , err )
334342 }
335343
@@ -370,7 +378,7 @@ func testResubmitNonZeroGasPriceTransaction(t *testing.T) {
370378 }
371379 var sidecar * gethTypes.BlobTxSidecar
372380 if txBlob [i ] != nil {
373- sidecar , err = makeSidecar (txBlob [i ])
381+ sidecar , err = makeSidecar ([] * kzg4844. Blob { txBlob [i ]} )
374382 assert .NoError (t , err )
375383 }
376384 tx , err := s .createTx (feeData , & common.Address {}, nil , sidecar , s .transactionSigner .GetNonce ())
@@ -505,7 +513,7 @@ func testResubmitBlobTransactionWithRisingBaseFeeAndBlobBaseFee(t *testing.T) {
505513 })
506514 defer patchGuard .Reset ()
507515
508- sidecar , err := makeSidecar (randBlob ( ))
516+ sidecar , err := makeSidecar (randBlobs ( 1 ))
509517 assert .NoError (t , err )
510518 tx := gethTypes .NewTx (& gethTypes.BlobTx {
511519 ChainID : uint256 .MustFromBig (s .chainID ),
@@ -579,10 +587,14 @@ func testResubmitNonceGappedTransaction(t *testing.T) {
579587 return nil , errors .New ("simulated transaction receipt error" )
580588 })
581589
582- _ , err = s .SendTransaction ("test-1" , & common.Address {}, nil , txBlob [i ], 0 )
590+ var blobs []* kzg4844.Blob
591+ if txBlob [i ] != nil {
592+ blobs = []* kzg4844.Blob {txBlob [i ]}
593+ }
594+ _ , err = s .SendTransaction ("test-1" , & common.Address {}, nil , blobs , 0 )
583595 assert .NoError (t , err )
584596
585- _ , err = s .SendTransaction ("test-2" , & common.Address {}, nil , txBlob [ i ] , 0 )
597+ _ , err = s .SendTransaction ("test-2" , & common.Address {}, nil , blobs , 0 )
586598 assert .NoError (t , err )
587599
588600 s .checkPendingTransaction ()
@@ -623,7 +635,7 @@ func testCheckPendingTransactionTxConfirmed(t *testing.T) {
623635 return nil
624636 })
625637
626- _ , err = s .SendTransaction ("test" , & common.Address {}, nil , randBlob ( ), 0 )
638+ _ , err = s .SendTransaction ("test" , & common.Address {}, nil , randBlobs ( 1 ), 0 )
627639 assert .NoError (t , err )
628640
629641 txs , err := s .pendingTransactionOrm .GetPendingOrReplacedTransactionsBySenderType (context .Background (), s .senderType , 1 )
@@ -665,7 +677,7 @@ func testCheckPendingTransactionResubmitTxConfirmed(t *testing.T) {
665677 return nil
666678 })
667679
668- originTxHash , err := s .SendTransaction ("test" , & common.Address {}, nil , randBlob ( ), 0 )
680+ originTxHash , err := s .SendTransaction ("test" , & common.Address {}, nil , randBlobs ( 1 ), 0 )
669681 assert .NoError (t , err )
670682
671683 txs , err := s .pendingTransactionOrm .GetPendingOrReplacedTransactionsBySenderType (context .Background (), s .senderType , 1 )
@@ -725,7 +737,7 @@ func testCheckPendingTransactionReplacedTxConfirmed(t *testing.T) {
725737 return nil
726738 })
727739
728- txHash , err := s .SendTransaction ("test" , & common.Address {}, nil , randBlob ( ), 0 )
740+ txHash , err := s .SendTransaction ("test" , & common.Address {}, nil , randBlobs ( 1 ), 0 )
729741 assert .NoError (t , err )
730742
731743 txs , err := s .pendingTransactionOrm .GetPendingOrReplacedTransactionsBySenderType (context .Background (), s .senderType , 1 )
@@ -795,7 +807,7 @@ func testCheckPendingTransactionTxMultipleTimesWithOnlyOneTxPending(t *testing.T
795807 return nil
796808 })
797809
798- _ , err = s .SendTransaction ("test" , & common.Address {}, nil , randBlob ( ), 0 )
810+ _ , err = s .SendTransaction ("test" , & common.Address {}, nil , randBlobs ( 1 ), 0 )
799811 assert .NoError (t , err )
800812
801813 txs , err := s .pendingTransactionOrm .GetPendingOrReplacedTransactionsBySenderType (context .Background (), s .senderType , 1 )
@@ -832,8 +844,8 @@ func testBlobTransactionWithBlobhashOpContractCall(t *testing.T) {
832844 assert .NoError (t , err )
833845 assert .NoError (t , migrate .ResetDB (sqlDB ))
834846
835- blob := randBlob ( )
836- sideCar , err := makeSidecar (blob )
847+ blobs := randBlobs ( 1 )
848+ sideCar , err := makeSidecar (blobs )
837849 assert .NoError (t , err )
838850 versionedHash := sideCar .BlobHashes ()[0 ]
839851 blsModulo , ok := new (big.Int ).SetString ("52435875175126190479447740508185965837690552500527637822603658699938581184513" , 10 )
@@ -845,7 +857,7 @@ func testBlobTransactionWithBlobhashOpContractCall(t *testing.T) {
845857 var point kzg4844.Point
846858 copy (point [start :], pointBytes )
847859 commitment := sideCar .Commitments [0 ]
848- proof , claim , err := kzg4844 .ComputeProof (blob , point )
860+ proof , claim , err := kzg4844 .ComputeProof (blobs [ 0 ] , point )
849861 assert .NoError (t , err )
850862
851863 var claimArray [32 ]byte
@@ -869,7 +881,7 @@ func testBlobTransactionWithBlobhashOpContractCall(t *testing.T) {
869881 assert .NoError (t , err )
870882 defer s .Stop ()
871883
872- _ , err = s .SendTransaction ("0" , & testContractsAddress , data , blob , 0 )
884+ _ , err = s .SendTransaction ("0" , & testContractsAddress , data , blobs , 0 )
873885 assert .NoError (t , err )
874886
875887 var txHash common.Hash
@@ -889,13 +901,19 @@ func testBlobTransactionWithBlobhashOpContractCall(t *testing.T) {
889901 }, 30 * time .Second , time .Second )
890902}
891903
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 [:])
904+ func randBlobs (count int ) []* kzg4844.Blob {
905+ blobs := make ([]* kzg4844.Blob , 0 , count )
906+
907+ for c := 0 ; c < count ; c ++ {
908+ var blob kzg4844.Blob
909+ for i := 0 ; i < len (blob ); i += gokzg4844 .SerializedScalarSize {
910+ fieldElementBytes := randFieldElement ()
911+ copy (blob [i :i + gokzg4844 .SerializedScalarSize ], fieldElementBytes [:])
912+ }
913+ blobs = append (blobs , & blob )
897914 }
898- return & blob
915+
916+ return blobs
899917}
900918
901919func randFieldElement () [32 ]byte {
@@ -921,10 +939,10 @@ func testSendBlobCarryingTxOverLimit(t *testing.T) {
921939 assert .NoError (t , err )
922940
923941 for i := 0 ; i < int (cfgCopy .MaxPendingBlobTxs ); i ++ {
924- _ , err = s .SendTransaction ("0" , & common.Address {}, nil , randBlob ( ), 0 )
942+ _ , err = s .SendTransaction ("0" , & common.Address {}, nil , randBlobs ( 1 ), 0 )
925943 assert .NoError (t , err )
926944 }
927- _ , err = s .SendTransaction ("0" , & common.Address {}, nil , randBlob ( ), 0 )
945+ _ , err = s .SendTransaction ("0" , & common.Address {}, nil , randBlobs ( 1 ), 0 )
928946 assert .ErrorIs (t , err , ErrTooManyPendingBlobTxs )
929947 s .Stop ()
930948}
0 commit comments