@@ -428,6 +428,14 @@ mod tests {
428428 handle. stopped ( ) . await ;
429429 }
430430
431+ /// Test that the server returns an error when the request size exceeds the limit.
432+ /// The server should return HTTP 413 (Request Entity Too Large).
433+ /// In this test, the request size limit is set to 100 kB, and we are expecting
434+ /// that to fit about 250 receipts. We also test with 300 receipts, which should
435+ /// exceed the limit.
436+ /// We conclude that a limit of 10MB should fit about 25k receipts, and thus
437+ /// the TAP spec will require that the aggregator supports up to 15k receipts
438+ /// per aggregation request as a safe limit.
431439 #[ rstest]
432440 #[ tokio:: test]
433441 async fn request_size_limit (
@@ -437,14 +445,14 @@ mod tests {
437445 allocation_ids : Vec < Address > ,
438446 #[ values( "0.0" ) ] api_version : & str ,
439447 ) {
440- // Set the request size limit to 10 kB to easily trigger the HTTP 413 error.
441- let small_request_size_limit = 10 * 1024 ;
448+ // Set the request size limit to 100 kB to reproducibly trigger the HTTP 413 error.
449+ let http_request_size_limit_100kb = 100 * 1024 ;
442450
443451 // Start the JSON-RPC server.
444452 let ( handle, local_addr) = server:: run_server (
445453 0 ,
446454 keys. 0 . clone ( ) ,
447- small_request_size_limit ,
455+ http_request_size_limit_100kb ,
448456 http_response_size_limit,
449457 http_max_concurrent_connections,
450458 )
@@ -456,33 +464,36 @@ mod tests {
456464 . build ( format ! ( "http://127.0.0.1:{}" , local_addr. port( ) ) )
457465 . unwrap ( ) ;
458466
459- // Create 100 receipts
467+ // Create 300 receipts
460468 let mut receipts = Vec :: new ( ) ;
461- for _ in 1 ..100 {
469+ for _ in 1 ..300 {
462470 receipts. push (
463- EIP712SignedMessage :: new ( Receipt :: new ( allocation_ids[ 0 ] , 42 ) . unwrap ( ) , & keys. 0 )
464- . await
465- . unwrap ( ) ,
471+ EIP712SignedMessage :: new (
472+ Receipt :: new ( allocation_ids[ 0 ] , u128:: MAX / 1000 ) . unwrap ( ) ,
473+ & keys. 0 ,
474+ )
475+ . await
476+ . unwrap ( ) ,
466477 ) ;
467478 }
468479
469480 // Skipping receipts validation in this test, aggregate_receipts assumes receipts are valid.
470481 // Create RAV through the JSON-RPC server.
471- // Test with only 10 receipts
482+ // Test with only 250 receipts
472483 let res: Result <
473484 server:: JsonRpcResponse < EIP712SignedMessage < ReceiptAggregateVoucher > > ,
474485 jsonrpsee:: core:: Error ,
475486 > = client
476487 . request (
477488 "aggregate_receipts" ,
478- rpc_params ! ( api_version, & receipts[ ..10 ] , None :: <( ) >) ,
489+ rpc_params ! ( api_version, & receipts[ ..250 ] , None :: <( ) >) ,
479490 )
480491 . await ;
481492
482493 assert ! ( res. is_ok( ) ) ;
483494
484495 // Create RAV through the JSON-RPC server.
485- // Test with all 100 receipts
496+ // Test with all 300 receipts
486497 let res: Result <
487498 server:: JsonRpcResponse < EIP712SignedMessage < ReceiptAggregateVoucher > > ,
488499 jsonrpsee:: core:: Error ,
0 commit comments