@@ -445,14 +445,20 @@ mod tests {
445445 allocation_ids : Vec < Address > ,
446446 #[ values( "0.0" ) ] api_version : & str ,
447447 ) {
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 ;
448+ // Set the request byte size limit to a value that easily triggers the HTTP 413
449+ // error.
450+ let http_request_size_limit = 100 * 1024 ;
451+
452+ // Number of receipts that is just above the number that would fit within the
453+ // request size limit. This value is hard-coded here because it supports the
454+ // maximum number of receipts per aggregate value we wrote in the spec / docs.
455+ let number_of_receipts_to_exceed_limit = 300 ;
450456
451457 // Start the JSON-RPC server.
452458 let ( handle, local_addr) = server:: run_server (
453459 0 ,
454460 keys. 0 . clone ( ) ,
455- http_request_size_limit_100kb ,
461+ http_request_size_limit ,
456462 http_response_size_limit,
457463 http_max_concurrent_connections,
458464 )
@@ -464,9 +470,9 @@ mod tests {
464470 . build ( format ! ( "http://127.0.0.1:{}" , local_addr. port( ) ) )
465471 . unwrap ( ) ;
466472
467- // Create 300 receipts
473+ // Create receipts
468474 let mut receipts = Vec :: new ( ) ;
469- for _ in 1 ..300 {
475+ for _ in 1 ..number_of_receipts_to_exceed_limit {
470476 receipts. push (
471477 EIP712SignedMessage :: new (
472478 Receipt :: new ( allocation_ids[ 0 ] , u128:: MAX / 1000 ) . unwrap ( ) ,
@@ -479,21 +485,25 @@ mod tests {
479485
480486 // Skipping receipts validation in this test, aggregate_receipts assumes receipts are valid.
481487 // Create RAV through the JSON-RPC server.
482- // Test with only 250 receipts
488+ // Test with a number of receipts that stays within request size limit
483489 let res: Result <
484490 server:: JsonRpcResponse < EIP712SignedMessage < ReceiptAggregateVoucher > > ,
485491 jsonrpsee:: core:: Error ,
486492 > = client
487493 . request (
488494 "aggregate_receipts" ,
489- rpc_params ! ( api_version, & receipts[ ..250 ] , None :: <( ) >) ,
495+ rpc_params ! (
496+ api_version,
497+ & receipts[ ..number_of_receipts_to_exceed_limit - 50 ] ,
498+ None :: <( ) >
499+ ) ,
490500 )
491501 . await ;
492502
493503 assert ! ( res. is_ok( ) ) ;
494504
495505 // Create RAV through the JSON-RPC server.
496- // Test with all 300 receipts
506+ // Test with all receipts to exceed request size limit
497507 let res: Result <
498508 server:: JsonRpcResponse < EIP712SignedMessage < ReceiptAggregateVoucher > > ,
499509 jsonrpsee:: core:: Error ,
0 commit comments