@@ -1010,26 +1010,40 @@ func TestSequencer_GetNextBatch_EmptyDABatch_IncreasesDAHeight(t *testing.T) {
10101010 assert .Equal (t , uint64 (0 ), seq .checkpoint .TxIndex )
10111011}
10121012
1013- // mockDATransactionFilter is a mock implementation of execution.DATransactionFilter
1014- type mockDATransactionFilter struct {
1015- filterFunc func (ctx context.Context , txs [][]byte , maxGas uint64 ) ([][]byte , [][]byte , error )
1013+ // mockExecutor is a mock implementation of execution.Executor for testing gas filtering
1014+ type mockExecutor struct {
1015+ maxGas uint64
1016+ getInfoErr error
1017+ filterFunc func (ctx context.Context , txs [][]byte , maxGas uint64 ) ([][]byte , [][]byte , error )
1018+ filterCallCount int
10161019}
10171020
1018- func (m * mockDATransactionFilter ) FilterDATransactions (ctx context.Context , txs [][]byte , maxGas uint64 ) ([][]byte , [][]byte , error ) {
1019- if m .filterFunc != nil {
1020- return m .filterFunc (ctx , txs , maxGas )
1021- }
1022- return txs , nil , nil
1021+ func (m * mockExecutor ) InitChain (ctx context.Context , genesisTime time.Time , initialHeight uint64 , chainID string ) ([]byte , error ) {
1022+ return []byte ("state-root" ), nil
1023+ }
1024+
1025+ func (m * mockExecutor ) GetTxs (ctx context.Context ) ([][]byte , error ) {
1026+ return nil , nil
10231027}
10241028
1025- // mockExecutionInfoProvider is a mock implementation of execution.ExecutionInfoProvider
1026- type mockExecutionInfoProvider struct {
1027- maxGas uint64
1028- err error
1029+ func (m * mockExecutor ) ExecuteTxs (ctx context.Context , txs [][]byte , blockHeight uint64 , timestamp time.Time , prevStateRoot []byte ) ([]byte , error ) {
1030+ return []byte ("new-state-root" ), nil
10291031}
10301032
1031- func (m * mockExecutionInfoProvider ) GetExecutionInfo (ctx context.Context , height uint64 ) (execution.ExecutionInfo , error ) {
1032- return execution.ExecutionInfo {MaxGas : m .maxGas }, m .err
1033+ func (m * mockExecutor ) SetFinal (ctx context.Context , blockHeight uint64 ) error {
1034+ return nil
1035+ }
1036+
1037+ func (m * mockExecutor ) GetExecutionInfo (ctx context.Context , height uint64 ) (execution.ExecutionInfo , error ) {
1038+ return execution.ExecutionInfo {MaxGas : m .maxGas }, m .getInfoErr
1039+ }
1040+
1041+ func (m * mockExecutor ) FilterDATransactions (ctx context.Context , txs [][]byte , maxGas uint64 ) ([][]byte , [][]byte , error ) {
1042+ m .filterCallCount ++
1043+ if m .filterFunc != nil {
1044+ return m .filterFunc (ctx , txs , maxGas )
1045+ }
1046+ return txs , nil , nil
10331047}
10341048
10351049func TestSequencer_GetNextBatch_WithGasFiltering (t * testing.T ) {
@@ -1070,11 +1084,10 @@ func TestSequencer_GetNextBatch_WithGasFiltering(t *testing.T) {
10701084 )
10711085 require .NoError (t , err )
10721086
1073- // Configure the gas filter mock
1074- filterCallCount := 0
1075- mockFilter := & mockDATransactionFilter {
1087+ // Configure the executor mock
1088+ mockExec := & mockExecutor {
1089+ maxGas : 1000000 , // 1M gas limit
10761090 filterFunc : func (ctx context.Context , txs [][]byte , maxGas uint64 ) ([][]byte , [][]byte , error ) {
1077- filterCallCount ++
10781091 // Simulate: first 2 txs fit, third one doesn't
10791092 if len (txs ) >= 3 {
10801093 return txs [:2 ], txs [2 :], nil
@@ -1083,12 +1096,8 @@ func TestSequencer_GetNextBatch_WithGasFiltering(t *testing.T) {
10831096 },
10841097 }
10851098
1086- mockInfoProvider := & mockExecutionInfoProvider {
1087- maxGas : 1000000 , // 1M gas limit
1088- }
1089-
1090- // Set the filter
1091- seq .SetDATransactionFilter (mockFilter , mockInfoProvider )
1099+ // Set the executor
1100+ seq .SetExecutor (mockExec )
10921101
10931102 // Manually set up cached forced txs to simulate DA fetch
10941103 seq .cachedForcedInclusionTxs = forcedTxs
@@ -1118,11 +1127,10 @@ func TestSequencer_GetNextBatch_WithGasFiltering(t *testing.T) {
11181127 assert .Equal (t , uint64 (0 ), seq .checkpoint .TxIndex ) // Reset because we replaced the cache
11191128
11201129 // Filter should have been called
1121- assert .Equal (t , 1 , filterCallCount )
1130+ assert .Equal (t , 1 , mockExec . filterCallCount )
11221131
11231132 // Second call should return the remaining tx
1124- mockFilter .filterFunc = func (ctx context.Context , txs [][]byte , maxGas uint64 ) ([][]byte , [][]byte , error ) {
1125- filterCallCount ++
1133+ mockExec .filterFunc = func (ctx context.Context , txs [][]byte , maxGas uint64 ) ([][]byte , [][]byte , error ) {
11261134 // Now all remaining txs fit
11271135 return txs , nil , nil
11281136 }
@@ -1167,18 +1175,15 @@ func TestSequencer_GetNextBatch_GasFilterError(t *testing.T) {
11671175 )
11681176 require .NoError (t , err )
11691177
1170- // Configure filter that returns error
1171- mockFilter := & mockDATransactionFilter {
1178+ // Configure executor that returns filter error
1179+ mockExec := & mockExecutor {
1180+ maxGas : 1000000 ,
11721181 filterFunc : func (ctx context.Context , txs [][]byte , maxGas uint64 ) ([][]byte , [][]byte , error ) {
11731182 return nil , nil , errors .New ("filter error" )
11741183 },
11751184 }
11761185
1177- mockInfoProvider := & mockExecutionInfoProvider {
1178- maxGas : 1000000 ,
1179- }
1180-
1181- seq .SetDATransactionFilter (mockFilter , mockInfoProvider )
1186+ seq .SetExecutor (mockExec )
11821187
11831188 // Set up cached txs
11841189 forcedTxs := [][]byte {[]byte ("tx1" ), []byte ("tx2" )}
0 commit comments