Skip to content

Commit e5bb44f

Browse files
committed
fix(jsonrpc): impose the same listed items limit for all requests in a batch
1 parent 9e1fa3b commit e5bb44f

3 files changed

Lines changed: 106 additions & 66 deletions

File tree

internal/jsonrpc/batchcalls_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TestJSONRPCBatchRejectsMoreThanMaximumBeforeDispatch(t *testing.T) {
9898
s := newBatchTestService()
9999
var calls atomic.Int32
100100
const method = "test_batch_cap"
101-
withTestRPCHandler(t, method, func(_ *Service, _ *http.Request, _ RPCRequest) (any, error) {
101+
withTestRPCHandler(t, method, func(_ *Service, _ *uint64, _ *http.Request, _ RPCRequest) (any, error) {
102102
calls.Add(1)
103103
return true, nil
104104
})
@@ -215,7 +215,7 @@ func TestJSONRPCBatchReplacesResponsesAtCumulativeResponseBudget(t *testing.T) {
215215
var calls atomic.Int32
216216
const method = "test_large_batch_result"
217217
largeResult := strings.Repeat("x", testLargeResultSize)
218-
withTestRPCHandler(t, method, func(_ *Service, _ *http.Request, _ RPCRequest) (any, error) {
218+
withTestRPCHandler(t, method, func(_ *Service, _ *uint64, _ *http.Request, _ RPCRequest) (any, error) {
219219
calls.Add(1)
220220
return largeResult, nil
221221
})
@@ -254,7 +254,7 @@ func TestJSONRPCBatchStopsBetweenEntriesWhenContextIsCanceled(t *testing.T) {
254254
s.Logger = slog.New(slog.NewJSONHandler(&logs, &slog.HandlerOptions{Level: slog.LevelDebug}))
255255
ctx, cancel := context.WithCancel(context.Background())
256256
const method = "test_cancel_batch"
257-
withTestRPCHandler(t, method, func(_ *Service, _ *http.Request, _ RPCRequest) (any, error) {
257+
withTestRPCHandler(t, method, func(_ *Service, _ *uint64, _ *http.Request, _ RPCRequest) (any, error) {
258258
calls.Add(1)
259259
cancel()
260260
return true, nil
@@ -287,7 +287,7 @@ func TestJSONRPCBatchReturnsErrorsForIDDRequestsAfterDeadline(t *testing.T) {
287287
s := newBatchTestService()
288288
var calls atomic.Int32
289289
const method = "test_deadline_batch"
290-
withTestRPCHandler(t, method, func(_ *Service, _ *http.Request, _ RPCRequest) (any, error) {
290+
withTestRPCHandler(t, method, func(_ *Service, _ *uint64, _ *http.Request, _ RPCRequest) (any, error) {
291291
calls.Add(1)
292292
return true, nil
293293
})
@@ -331,7 +331,7 @@ func TestJSONRPCBatchUsesOneAdmissionPermit(t *testing.T) {
331331
}
332332
var nestedAcquisitions atomic.Int32
333333
const method = "test_batch_admission"
334-
withTestRPCHandler(t, method, func(s *Service, _ *http.Request, _ RPCRequest) (any, error) {
334+
withTestRPCHandler(t, method, func(s *Service, _ *uint64, _ *http.Request, _ RPCRequest) (any, error) {
335335
if s.admission.TryAcquire() {
336336
nestedAcquisitions.Add(1)
337337
s.admission.Release()

0 commit comments

Comments
 (0)