@@ -13,11 +13,12 @@ import (
1313
1414func TestImmediateStrategy (t * testing.T ) {
1515 strategy := & ImmediateStrategy {}
16+ maxBlobSize := common .DefaultMaxBlobSize
1617
1718 tests := []struct {
1819 name string
1920 pendingCount uint64
20- totalSize int
21+ totalSize uint64
2122 expected bool
2223 }{
2324 {
@@ -42,7 +43,7 @@ func TestImmediateStrategy(t *testing.T) {
4243
4344 for _ , tt := range tests {
4445 t .Run (tt .name , func (t * testing.T ) {
45- result := strategy .ShouldSubmit (tt .pendingCount , tt .totalSize , common . DefaultMaxBlobSize , 0 )
46+ result := strategy .ShouldSubmit (tt .pendingCount , tt .totalSize , maxBlobSize , 0 )
4647 assert .Equal (t , tt .expected , result )
4748 })
4849 }
@@ -56,7 +57,7 @@ func TestSizeBasedStrategy(t *testing.T) {
5657 sizeThreshold float64
5758 minItems uint64
5859 pendingCount uint64
59- totalSize int
60+ totalSize uint64
6061 expectedSubmit bool
6162 }{
6263 {
@@ -80,15 +81,15 @@ func TestSizeBasedStrategy(t *testing.T) {
8081 sizeThreshold : 0.8 ,
8182 minItems : 1 ,
8283 pendingCount : 10 ,
83- totalSize : int (float64 (maxBlobSize ) * 0.8 ), // 80% of max
84+ totalSize : uint64 (float64 (maxBlobSize ) * 0.8 ), // 80% of max
8485 expectedSubmit : true ,
8586 },
8687 {
8788 name : "above threshold" ,
8889 sizeThreshold : 0.8 ,
8990 minItems : 1 ,
9091 pendingCount : 20 ,
91- totalSize : int (float64 (maxBlobSize ) * 0.875 ), // 87.5%
92+ totalSize : uint64 (float64 (maxBlobSize ) * 0.875 ), // 87.5%
9293 expectedSubmit : true ,
9394 },
9495 {
@@ -125,39 +126,39 @@ func TestTimeBasedStrategy(t *testing.T) {
125126 name string
126127 minItems uint64
127128 pendingCount uint64
128- totalSize int
129+ totalSize uint64
129130 timeSinceLastSubmit time.Duration
130131 expectedSubmit bool
131132 }{
132133 {
133134 name : "below min items" ,
134135 minItems : 2 ,
135136 pendingCount : 1 ,
136- totalSize : int (float64 (maxBlobSize ) * 0.2 ),
137+ totalSize : uint64 (float64 (maxBlobSize ) * 0.2 ),
137138 timeSinceLastSubmit : 10 * time .Second ,
138139 expectedSubmit : false ,
139140 },
140141 {
141142 name : "before max delay" ,
142143 minItems : 1 ,
143144 pendingCount : 5 ,
144- totalSize : int (float64 (maxBlobSize ) * 0.5 ),
145+ totalSize : uint64 (float64 (maxBlobSize ) * 0.5 ),
145146 timeSinceLastSubmit : 3 * time .Second ,
146147 expectedSubmit : false ,
147148 },
148149 {
149150 name : "at max delay" ,
150151 minItems : 1 ,
151152 pendingCount : 3 ,
152- totalSize : int (float64 (maxBlobSize ) * 0.4 ),
153+ totalSize : uint64 (float64 (maxBlobSize ) * 0.4 ),
153154 timeSinceLastSubmit : 6 * time .Second ,
154155 expectedSubmit : true ,
155156 },
156157 {
157158 name : "after max delay" ,
158159 minItems : 1 ,
159160 pendingCount : 2 ,
160- totalSize : int (float64 (maxBlobSize ) * 0.2 ),
161+ totalSize : uint64 (float64 (maxBlobSize ) * 0.2 ),
161162 timeSinceLastSubmit : 10 * time .Second ,
162163 expectedSubmit : true ,
163164 },
@@ -181,7 +182,7 @@ func TestAdaptiveStrategy(t *testing.T) {
181182 name string
182183 minItems uint64
183184 pendingCount uint64
184- totalSize int
185+ totalSize uint64
185186 timeSinceLastSubmit time.Duration
186187 expectedSubmit bool
187188 reason string
@@ -190,7 +191,7 @@ func TestAdaptiveStrategy(t *testing.T) {
190191 name : "below min items" ,
191192 minItems : 3 ,
192193 pendingCount : 2 ,
193- totalSize : int (float64 (maxBlobSize ) * 0.875 ),
194+ totalSize : uint64 (float64 (maxBlobSize ) * 0.875 ),
194195 timeSinceLastSubmit : 10 * time .Second ,
195196 expectedSubmit : false ,
196197 reason : "not enough items" ,
@@ -199,7 +200,7 @@ func TestAdaptiveStrategy(t *testing.T) {
199200 name : "size threshold reached" ,
200201 minItems : 1 ,
201202 pendingCount : 10 ,
202- totalSize : int (float64 (maxBlobSize ) * 0.85 ), // 85%
203+ totalSize : uint64 (float64 (maxBlobSize ) * 0.85 ), // 85%
203204 timeSinceLastSubmit : 1 * time .Second ,
204205 expectedSubmit : true ,
205206 reason : "size threshold met" ,
@@ -208,7 +209,7 @@ func TestAdaptiveStrategy(t *testing.T) {
208209 name : "time threshold reached" ,
209210 minItems : 1 ,
210211 pendingCount : 2 ,
211- totalSize : int (float64 (maxBlobSize ) * 0.2 ), // Only 20%
212+ totalSize : uint64 (float64 (maxBlobSize ) * 0.2 ), // Only 20%
212213 timeSinceLastSubmit : 7 * time .Second ,
213214 expectedSubmit : true ,
214215 reason : "time threshold met" ,
@@ -217,7 +218,7 @@ func TestAdaptiveStrategy(t *testing.T) {
217218 name : "neither threshold reached" ,
218219 minItems : 1 ,
219220 pendingCount : 5 ,
220- totalSize : int (float64 (maxBlobSize ) * 0.5 ), // 50%
221+ totalSize : uint64 (float64 (maxBlobSize ) * 0.5 ), // 50%
221222 timeSinceLastSubmit : 3 * time .Second ,
222223 expectedSubmit : false ,
223224 reason : "waiting for threshold" ,
@@ -226,7 +227,7 @@ func TestAdaptiveStrategy(t *testing.T) {
226227 name : "both thresholds reached" ,
227228 minItems : 1 ,
228229 pendingCount : 20 ,
229- totalSize : int (float64 (maxBlobSize ) * 0.875 ), // 87.5%
230+ totalSize : uint64 (float64 (maxBlobSize ) * 0.875 ), // 87.5%
230231 timeSinceLastSubmit : 10 * time .Second ,
231232 expectedSubmit : true ,
232233 reason : "both thresholds met" ,
@@ -305,10 +306,9 @@ func TestNewBatchingStrategy(t *testing.T) {
305306}
306307
307308func TestBatchingStrategiesComparison (t * testing.T ) {
308- // This test demonstrates how different strategies behave with the same input
309309 maxBlobSize := common .DefaultMaxBlobSize
310310 pendingCount := uint64 (10 )
311- totalSize := maxBlobSize / 2 // 50% full
311+ totalSize := maxBlobSize / 2
312312 timeSinceLastSubmit := 3 * time .Second
313313
314314 immediate := & ImmediateStrategy {}
0 commit comments